diff --git a/.gitignore b/.gitignore index e69de29..a45c9cc 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +/marked-0.2.8.tgz +/tests-v0.2.8.tar.bz2 diff --git a/dl-tests.sh b/dl-tests.sh new file mode 100744 index 0000000..b25b1b2 --- /dev/null +++ b/dl-tests.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +tag=v0.2.8 + +set -e + +tmp=$(mktemp -d) + +trap cleanup EXIT +cleanup() { + set +e + [ -z "$tmp" -o ! -d "$tmp" ] || rm -rf "$tmp" +} + +unset CDPATH +pwd=$(pwd) + +pushd "$tmp" +git clone git://github.com/chjj/marked.git +cd marked +git archive --prefix="test/" --format=tar tags/${tag}:test/ \ + | bzip2 > "$pwd"/tests-${tag}.tar.bz2 +popd diff --git a/marked-0.2.8-fix-link-defs-after-blocks.patch b/marked-0.2.8-fix-link-defs-after-blocks.patch new file mode 100644 index 0000000..d32bebf --- /dev/null +++ b/marked-0.2.8-fix-link-defs-after-blocks.patch @@ -0,0 +1,61 @@ +--- a/lib/marked.js ++++ b/lib/marked.js +@@ -18,8 +18,8 @@ + heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, + nptable: noop, + lheading: /^([^\n]+)\n *(=|-){3,} *\n*/, +- blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/, +- list: /^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, ++ blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/, ++ list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, + html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/, + def: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, + table: noop, +@@ -36,6 +36,11 @@ + block.list = replace(block.list) + (/bull/g, block.bullet) + ('hr', /\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/) ++ ('def', '\\n+(?=' + block.def.source + ')') ++ (); ++ ++block.blockquote = replace(block.blockquote) ++ ('def', block.def) + (); + + block._tag = '(?!(?:' +@@ -139,7 +144,7 @@ + * Lexing + */ + +-Lexer.prototype.token = function(src, top) { ++Lexer.prototype.token = function(src, top, bq) { + var src = src.replace(/^ +$/gm, '') + , next + , loose +@@ -262,7 +267,7 @@ + // Pass `top` to keep the current + // "toplevel" state. This is exactly + // how markdown.pl works. +- this.token(cap, top); ++ this.token(cap, top, true); + + this.tokens.push({ + type: 'blockquote_end' +@@ -335,7 +340,7 @@ + }); + + // Recurse. +- this.token(item, false); ++ this.token(item, false, bq); + + this.tokens.push({ + type: 'list_item_end' +@@ -363,7 +368,7 @@ + } + + // def +- if (top && (cap = this.rules.def.exec(src))) { ++ if ((!bq && top) && (cap = this.rules.def.exec(src))) { + src = src.substring(cap[0].length); + this.tokens.links[cap[1].toLowerCase()] = { + href: cap[2], diff --git a/marked.spec b/marked.spec new file mode 100644 index 0000000..287f48a --- /dev/null +++ b/marked.spec @@ -0,0 +1,97 @@ +%global enable_tests 1 + +Name: marked +Version: 0.2.8 +Release: 2%{?dist} +Summary: A markdown parser for Node.js built for speed +License: MIT +Group: System Environment/Libraries +URL: https://github.com/chjj/marked +Source0: http://registry.npmjs.org/marked/-/marked-%{version}.tgz +# The test files are not included in the npm tarball. +# Source1 is generated by running Source10, which pulls from the upstream +# version control repository. +Source1: tests-v%{version}.tar.bz2 +Source10: dl-tests.sh +BuildArch: noarch + +Patch0: %{name}-0.2.8-fix-link-defs-after-blocks.patch + +BuildRequires: nodejs-devel + +%if 0%{?enable_tests} +BuildRequires: npm(express) +%endif + +%description +marked is a full-featured markdown compiler that can parse huge chunks of +markdown without having to worry about caching the compiled output or +blocking for an unnecessarily long time. + +marked is extremely fast and frequently outperforms similar markdown parsers. +marked is very concise and still implements all markdown features, as well +as GitHub Flavored Markdown features. + +marked more or less passes the official markdown test suite in its entirety. +This is important because a surprising number of markdown compilers cannot +pass more than a few tests. + + +%prep +%setup -q -n package +%setup -q -T -D -a 1 -n package +%patch0 -p1 + + +%build +#nothing to do + + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/marked +cp -pr package.json lib/ \ + %{buildroot}%{nodejs_sitelib}/marked +mkdir -p %{buildroot}%{nodejs_sitelib}/marked/bin +install -p -D -m0755 bin/marked \ + %{buildroot}%{nodejs_sitelib}/marked/bin/marked +mkdir -p %{buildroot}/%{_bindir} +ln -sf %{nodejs_sitelib}/marked/bin/marked \ + %{buildroot}%{_bindir}/marked + +mkdir -p %{buildroot}%{_mandir}/man1 +install -p -D -m0644 man/marked.1 \ + %{buildroot}%{_mandir}/man1/marked.1 + +%nodejs_symlink_deps + + +%if 0%{?enable_tests} +%check +# gfm_break test will always fail due to author's choice not to include gfm +# line breaks: https://github.com/chjj/marked/issues/49 + +# gfm_code_hr_list test is known to fail but the author has not yet arrived +# at a satisfactory solution: https://github.com/chjj/marked/pull/118 + +# def_blocks and double_link tests also fail and author has been queried +# about whether these are meant to fail or not: +# https://github.com/chjj/marked/issues/136 + +cp -pr %{nodejs_sitelib} . +%__nodejs ./test/ +%endif + + +%files +%doc LICENSE README.md +%{nodejs_sitelib}/marked +%{_bindir}/marked +%{_mandir}/man1/marked.1* + + +%changelog +* Tue Mar 12 2013 Jamie Nguyen - 0.2.8-2 +- add information about test failures + +* Thu Feb 14 2013 Jamie Nguyen - 0.2.8-1 +- initial package diff --git a/sources b/sources index e69de29..95ece2d 100644 --- a/sources +++ b/sources @@ -0,0 +1,2 @@ +729305a61c3c739039ede41c802a75c6 marked-0.2.8.tgz +ebc9669eadecbc1b839528dbf40e4e3f tests-v0.2.8.tar.bz2