From adfa8750cd771688156e0f386b980f9214c4063b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bengt=20L=C3=BCers?= Date: Fri, 12 Sep 2014 20:22:58 +0200 Subject: Add example from issue #94 about indented code block closing fences --- spec.txt | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/spec.txt b/spec.txt index 82ae0b6..dbe779b 100644 --- a/spec.txt +++ b/spec.txt @@ -1219,6 +1219,56 @@ aaa . +Closing fences may be indented by 0-3 spaces: + +. +``` +code +``` +. +
code
+
+. + +. +``` +code + ``` +. +
code
+
+. + +. +``` +code + ``` +. +
code
+
+. + +. +``` +code + ``` +. +
code
+
+. + +But not by 4: + +. +``` +aaa + ``` +. +
aaa
+    ```
+
+. + Four spaces indentation produces an indented code block: . @@ -6133,5 +6183,3 @@ an `emph`. The document can be rendered as HTML, or in any other format, given an appropriate renderer. - - -- cgit v1.2.3 From a4cfaa7aacaebd2c03a4e091f3ff1687d8f223e2 Mon Sep 17 00:00:00 2001 From: Till Varoquaux Date: Tue, 7 Oct 2014 11:36:19 -0400 Subject: Build a very simple shared library. --- Makefile | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 671d30d..99c1356 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ -CFLAGS?=-g -O3 -Wall -Wextra -std=c99 -Isrc -Wno-missing-field-initializers $(OPTFLAGS) +CFLAGS?=-g -O3 -Wall -Wextra -std=c99 -Isrc -Wno-missing-field-initializers -fPIC $(OPTFLAGS) LDFLAGS?=-g -O3 -Wall -Werror SRCDIR?=src DATADIR?=data +PREFIX?=/usr/local PROG?=./stmd .PHONY: all oldtests test spec benchjs testjs -all: $(SRCDIR)/case_fold_switch.inc $(PROG) +all: $(SRCDIR)/case_fold_switch.inc $(PROG) libstmd.so README.html: README.md template.html pandoc --template template.html -S -s -t html5 -o $@ $< @@ -43,7 +44,14 @@ benchjs: HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o -STMD_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.c +STMD_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.o $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.o + +STMD_HDR = $(SRCDIR)/stmd.h $(SRCDIR)/buffer.h $(SRCDIR)/references.h \ + $(SRCDIR)/chunk.h $(SRCDIR)/debug.h $(SRCDIR)/utf8.h \ + $(SRCDIR)/scanners.h $(SRCDIR)/inlines.h + +HTML_HDR = $(SRCDIR)/html/html_unescape.h $(SRCDIR)/html/houdini.h + $(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c $(CC) $(LDFLAGS) -o $@ $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c @@ -57,6 +65,15 @@ $(SRCDIR)/case_fold_switch.inc: $(DATADIR)/CaseFolding-3.2.0.txt $(SRCDIR)/html/html_unescape.h: $(SRCDIR)/html/html_unescape.gperf gperf -I -t -N find_entity -H hash_entity -K entity -C -l --null-strings -m5 $< > $@ +libstmd.so: $(HTML_OBJ) $(STMD_OBJ) + $(CC) $(LDFLAGS) -shared -o $@ $^ + +install: libstmd.so $(STMD_HDR) $(HTML_HDR) + install -d $(PREFIX)/lib $(PREFIX)/include/stmd/html + install libstmd.so $(PREFIX)/lib/ + install $(STMD_HDR) $(PREFIX)/include/stmd/ + install $(HTML_HDR) $(PREFIX)/include/stmd/html/ + .PHONY: leakcheck clean fuzztest dingus upload dingus: @@ -79,7 +96,7 @@ update-site: spec.html narrative.html (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, narrative, js" ; git push; cd ..) clean: - -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o + -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libstmd.so -rm -rf *.dSYM -rm -f README.html -rm -f spec.md fuzz.txt spec.html -- cgit v1.2.3 From 15422f68253bd5d877f0b308b1bf6caec6e0eb79 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 00:26:38 -0700 Subject: Tweaked the closing fence section added in last commit. --- spec.txt | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/spec.txt b/spec.txt index c226866..e5953bd 100644 --- a/spec.txt +++ b/spec.txt @@ -1288,45 +1288,41 @@ aaa . -Closing fences may be indented by 0-3 spaces: +Four spaces indentation produces an indented code block: . -``` -code -``` -. -
code
-
-. - + ``` + aaa + ``` . +
```
+aaa
 ```
-code
- ```
-.
-
code
 
. +Closing fences may be indented by 0-3 spaces, and their indentation +need not match that of the opening fence: + . ``` -code +aaa ``` . -
code
+
aaa
 
. . -``` -code ``` +aaa + ``` . -
code
+
aaa
 
. -But not by 4: +This is not a closing fence, because it is indented 4 spaces: . ``` @@ -1338,18 +1334,6 @@ aaa
. -Four spaces indentation produces an indented code block: - -. - ``` - aaa - ``` -. -
```
-aaa
-```
-
-. Code fences (opening and closing) cannot contain internal spaces: -- cgit v1.2.3 From c3f9a7caecbf5239f29b6fd1a7edf47df4fc6d21 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 11:57:43 -0700 Subject: Add EMPHASIS_STACK_LIMIT. If we get more than 1000 deep in potential emphasis/strong emphasis openers, we refuse to add more to the stack. This prevents the sort of stack overflow we previously got with python -c 'print "*a **a " * 100000; print " a** a*" * 100000' | ./cmark Partially addresses #166. --- src/cmark.h | 1 + src/inlines.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmark.h b/src/cmark.h index ff2f9a2..5e508e4 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -9,6 +9,7 @@ #define VERSION "0.1" #define CODE_INDENT 4 +#define EMPHASIS_STACK_LIMIT 1000 struct node_inl { enum { diff --git a/src/inlines.c b/src/inlines.c index 7a7f08a..928a3ac 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -23,6 +23,7 @@ typedef struct Subject { int label_nestlevel; reference_map *refmap; inline_stack *emphasis_openers; + int number_of_emphasis_openers; } subject; static node_inl *parse_chunk_inlines(chunk *chunk, reference_map *refmap); @@ -177,6 +178,7 @@ static void subject_from_buf(subject *e, strbuf *buffer, reference_map *refmap) e->label_nestlevel = 0; e->refmap = refmap; e->emphasis_openers = NULL; + e->number_of_emphasis_openers = 0; chunk_rtrim(&e->input); } @@ -190,6 +192,7 @@ static void subject_from_chunk(subject *e, chunk *chunk, reference_map *refmap) e->label_nestlevel = 0; e->refmap = refmap; e->emphasis_openers = NULL; + e->number_of_emphasis_openers = 0; chunk_rtrim(&e->input); } @@ -309,6 +312,7 @@ static void free_openers(subject* subj, inline_stack* istack) while (subj->emphasis_openers != istack) { tempstack = subj->emphasis_openers; subj->emphasis_openers = subj->emphasis_openers->previous; + subj->number_of_emphasis_openers--; free(tempstack); } } @@ -389,7 +393,7 @@ static node_inl* handle_strong_emph(subject* subj, unsigned char c, node_inl **l cannotClose: inl_text = make_str(chunk_dup(&subj->input, subj->pos - numdelims, numdelims)); - if (can_open) + if (can_open && subj->number_of_emphasis_openers < EMPHASIS_STACK_LIMIT) { istack = (inline_stack*)malloc(sizeof(inline_stack)); if (istack == NULL) { @@ -400,6 +404,7 @@ cannotClose: istack->first_inline = inl_text; istack->previous = subj->emphasis_openers; subj->emphasis_openers = istack; + subj->number_of_emphasis_openers++; } return inl_text; -- cgit v1.2.3 From 9918827edd3dd6630f7417f1efca673bae55e6dd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 12:02:43 -0700 Subject: Moved TODO item to tracker --- TODO | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index fb82e4c..0000000 --- a/TODO +++ /dev/null @@ -1,4 +0,0 @@ -- should space be required before the closing ### in an ATX header? - http://talk.commonmark.org/t/atx-header-closing-space-confusion/333 - perhaps so - symmetrically with beginning, and for equally good reasons - -- cgit v1.2.3 From e618715636a3bd60930bea34d214b3aaf8e9e766 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 12:37:59 -0700 Subject: Require space before closing # sequence in ATX header. Closes #169. --- js/lib/blocks.js | 2 +- spec.txt | 24 ++++++++++++++++-------- src/blocks.c | 12 ++++++------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/js/lib/blocks.js b/js/lib/blocks.js index 109661f..175cc2a 100644 --- a/js/lib/blocks.js +++ b/js/lib/blocks.js @@ -366,7 +366,7 @@ var incorporateLine = function(ln, line_number) { container.level = match[0].trim().length; // number of #s // remove trailing ###s: container.strings = - [ln.slice(offset).replace(/(?:(\\#) *#*| *#+) *$/,'$1')]; + [ln.slice(offset).replace(/^ *#+ *$/, '').replace(/ +#+ *$/,'')]; break; } else if ((match = ln.slice(first_nonspace).match(/^`{3,}(?!.*`)|^~{3,}(?!.*~)/))) { diff --git a/spec.txt b/spec.txt index e5953bd..5070b3b 100644 --- a/spec.txt +++ b/spec.txt @@ -479,11 +479,11 @@ consists of a string of characters, parsed as inline content, between an opening sequence of 1--6 unescaped `#` characters and an optional closing sequence of any number of `#` characters. The opening sequence of `#` characters cannot be followed directly by a nonspace character. -The closing `#` characters may be followed by spaces only. The opening -`#` character may be indented 0-3 spaces. The raw contents of the -header are stripped of leading and trailing spaces before being parsed -as inline content. The header level is equal to the number of `#` -characters in the opening sequence. +The optional closing sequence of `#`s must be preceded by a space and may be +followed by spaces only. The opening `#` character may be indented 0-3 +spaces. The raw contents of the header are stripped of leading and +trailing spaces before being parsed as inline content. The header level +is equal to the number of `#` characters in the opening sequence. Simple headers: @@ -614,16 +614,24 @@ header:

foo ### b

. +The closing sequence must be preceded by a space: + +. +# foo# +. +

foo#

+. + Backslash-escaped `#` characters do not count as part of the closing sequence: . ### foo \### -## foo \#\## +## foo #\## # foo \# . -

foo #

-

foo ##

+

foo ###

+

foo ###

foo #

. diff --git a/src/blocks.c b/src/blocks.c index ae106d2..7613c82 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -432,15 +432,15 @@ static void chop_trailing_hashtags(chunk *ch) chunk_rtrim(ch); orig_n = n = ch->len - 1; - // if string ends in #s, remove these: + // if string ends in space followed by #s, remove these: while (n >= 0 && peek_at(ch, n) == '#') n--; - // the last # was escaped, so we include it. - if (n != orig_n && n >= 0 && peek_at(ch, n) == '\\') - n++; - - ch->len = n + 1; + // Check for a be a space before the final #s: + if (n != orig_n && n >= 0 && peek_at(ch, n) == ' ') { + ch->len = n; + chunk_rtrim(ch); + } } // Process one line at a time, modifying a node_block. -- cgit v1.2.3 From 652ac3088bd40df5a2db9a14c0f50d9c17ffd221 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 13:27:38 -0700 Subject: Removed narrative.md, moved its content to README.md. --- Makefile | 11 ++--- README.md | 79 +++++++++++++++++++++++++++++++++ narrative.md | 140 ----------------------------------------------------------- 3 files changed, 83 insertions(+), 147 deletions(-) delete mode 100644 narrative.md diff --git a/Makefile b/Makefile index e545794..9ca8eb2 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CFLAGS?=-g -O3 -Wall -Wextra -std=c99 -Isrc -Wno-missing-field-initializers -fPI LDFLAGS?=-g -O3 -Wall -Werror SRCDIR?=src DATADIR?=data -BENCHINP?=narrative.md +BENCHINP?=README.md PROG?=./cmark JSMODULES=$(wildcard js/lib/*.js) PREFIX?=/usr/local @@ -22,9 +22,6 @@ spec.md: spec.txt spec.html: spec.md template.html pandoc --no-highlight --number-sections --template template.html -s --toc -S $< > $@ # | perl -pe 's/␣/ <\/span>/g' > $@ -narrative.html: narrative.md template.html - pandoc --template template.html -s -S $< -o $@ - spec.pdf: spec.md template.tex specfilter.hs pandoc -s $< --template template.tex \ --filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \ @@ -90,13 +87,13 @@ fuzztest: for i in `seq 1 10`; do \ time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done -update-site: spec.html narrative.html js/commonmark.js +update-site: spec.html js/commonmark.js cp spec.html _site/ - cp narrative.html _site/index.html + echo "TODO" > _site/index.html cp js/index.html _site/js/ cp js/commonmark.js _site/js/ cp js/LICENSE _site/js/ - (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, narrative, js" ; git push; cd ..) + (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..) clean: -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so diff --git a/README.md b/README.md index 358f63f..a59c461 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,75 @@ like footnotes and definition lists. It is important to get the core right before considering such things. However, I have included a visible syntax for line breaks and fenced code blocks. +There are only a few places where this spec says things that contradict +the canonical syntax description: + +- It [allows all punctuation symbols to be + backslash-escaped](http://jgm.github.io/stmd/spec.html#backslash-escapes), + not just the symbols with special meanings in Markdown. I found + that it was just too hard to remember which symbols could be + escaped. + +- It introduces an [alternative syntax for hard line + breaks](http://jgm.github.io/stmd/spec.html#hard-line-breaks), a + backslash at the end of the line, supplementing the + two-spaces-at-the-end-of-line rule. This is motivated by persistent + complaints about the “invisible” nature of the two-space rule. + +- Link syntax has been made a bit more predictable (in a + backwards-compatible way). For example, `Markdown.pl` allows single + quotes around a title in inline links, but not in reference links. + This kind of difference is really hard for users to remember, so the + spec [allows single quotes in both + contexts](http://jgm.github.io/stmd/spec.html#links). + +- The rule for HTML blocks differs, though in most real cases it + shouldn't make a difference. (See + [here](http://jgm.github.io/stmd/spec.html#html-blocks) for + details.) The spec's proposal makes it easy to include Markdown + inside HTML block-level tags, if you want to, but also allows you to + exclude this. It is also makes parsing much easier, avoiding + expensive backtracking. + +- It does not collapse adjacent bird-track blocks into a single + blockquote: + + > this is two + + > blockquotes + + > this is a single + > + > blockquote with two paragraphs + +- Rules for content in lists differ in a few respects, though (as with + HTML blocks), most lists in existing documents should render as + intended. There is some discussion of the choice points and + differences [here](http://jgm.github.io/stmd/spec.html#motivation). + I think that the spec's proposal does better than any existing + implementation in rendering lists the way a human writer or reader + would intuitively understand them. (I could give numerous examples + of perfectly natural looking lists that nearly every existing + implementation flubs up.) + +- The spec stipulates that two blank lines break out of all list + contexts. This is an attempt to deal with issues that often come up + when someone wants to have two adjacent lists, or a list followed by + an indented code block. + +- Changing bullet characters, or changing from bullets to numbers or + vice versa, starts a new list. I think that is almost always going + to be the writer's intent. + +- The number that begins an ordered list item may be followed by + either `.` or `)`. Changing the delimiter style starts a new + list. + +- The start number of an ordered list is significant. + +- [Fenced code blocks](http://jgm.github.io/stmd/spec.html#fenced-code-blocks) are supported, delimited by either + backticks (` ``` `) or tildes (` ~~~ `). + In all of this, I have been guided by eight years experience writing Markdown implementations in several languages, including the first Markdown parser not based on regular expression substitutions @@ -113,3 +182,13 @@ Markdown implementations extensively using [babelmark working out the spec, I benefited greatly from collaboration with David Greenspan, and from feedback from several industrial users of Markdown, including Jeff Atwood, Vincent Marti, and Neil Williams. + +Contributing +------------ + +There is a [forum for discussing +CommonMark](http://talk.commonmark.org); you should use it instead of +github issues for questions and possibly open-ended discussions. +Use the [github issue tracker](http://github.com/jgm/stmd/issues) +only for simple, clear, actionable issues. + diff --git a/narrative.md b/narrative.md deleted file mode 100644 index 7390662..0000000 --- a/narrative.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -title: CommonMark -... - -CommonMark is a [specification of Markdown -syntax](http://jgm.github.io/stmd/spec.html), together with -BSD3-licensed implementations in C and JavaScript. The source -for the spec and the two implementations can be found in [this -repository](http://github.com/jgm/stmd). - -The C implementation provides both a library and a standalone program -`cmark` that converts Markdown to HTML. It is written in standard C99 -and has no library dependencies. - -The JavaScript implementation is a single JavaScript file, with no -dependencies. [Try it now!](http://jgm.github.io/stmd/js/) - -[The spec](http://jgm.github.io/stmd/spec.html) contains over 400 -embedded examples which serve as conformance tests. (The source contains -a perl script that will run the tests against any Markdown program.) - -The spec is written from the point of view of the human writer, not the -computer reader. It is not an algorithm—an English translation of a -computer program—but a declarative description of what counts as a block -quote, a code block, and each of the other structural elements that can -make up a Markdown document. For the most part, the spec limits itself -to the basic elements described in John Gruber’s [canonical syntax -description](http://daringfireball.net/projects/markdown/syntax), -eschewing extensions like footnotes and definition lists. It is -important to get the core right before considering such things. - -Because Gruber’s syntax description leaves many aspects of the syntax -undetermined, writing a precise spec requires making a large number of -decisions, many of them somewhat arbitrary. In making them, I have -appealed to existing conventions and considerations of simplicity, -readability, expressive power, and consistency. I have tried to ensure -that “normal” documents in the many incompatible existing -implementations of Markdown will render, as far as possible, as their -authors intended. And I have tried to make the rules for different -elements work together harmoniously. In places where different decisions -could have been made (for example, the rules governing list -indentation), I have explained the rationale for my choices. In a few -cases, I have departed slightly from the canonical syntax description, -in ways that I think further the goals of Markdown as stated in that -description. - -There are only a few places where this spec says things that contradict -the canonical syntax description: - -- It [allows all punctuation symbols to be - backslash-escaped](http://jgm.github.io/stmd/spec.html#backslash-escapes), - not just the symbols with special meanings in Markdown. I found - that it was just too hard to remember which symbols could be - escaped. - -- It introduces an [alternative syntax for hard line - breaks](http://jgm.github.io/stmd/spec.html#hard-line-breaks), a - backslash at the end of the line, supplementing the - two-spaces-at-the-end-of-line rule. This is motivated by persistent - complaints about the “invisible” nature of the two-space rule. - -- Link syntax has been made a bit more predictable (in a - backwards-compatible way). For example, `Markdown.pl` allows single - quotes around a title in inline links, but not in reference links. - This kind of difference is really hard for users to remember, so the - spec [allows single quotes in both - contexts](http://jgm.github.io/stmd/spec.html#links). - -- The rule for HTML blocks differs, though in most real cases it - shouldn't make a difference. (See - [here](http://jgm.github.io/stmd/spec.html#html-blocks) for - details.) The spec's proposal makes it easy to include Markdown - inside HTML block-level tags, if you want to, but also allows you to - exclude this. It is also makes parsing much easier, avoiding - expensive backtracking. - -- It does not collapse adjacent bird-track blocks into a single - blockquote: - - > this is two - - > blockquotes - - > this is a single - > - > blockquote with two paragraphs - -- Rules for content in lists differ in a few respects, though (as with - HTML blocks), most lists in existing documents should render as - intended. There is some discussion of the choice points and - differences [here](http://jgm.github.io/stmd/spec.html#motivation). - I think that the spec's proposal does better than any existing - implementation in rendering lists the way a human writer or reader - would intuitively understand them. (I could give numerous examples - of perfectly natural looking lists that nearly every existing - implementation flubs up.) - -- The spec stipulates that two blank lines break out of all list - contexts. This is an attempt to deal with issues that often come up - when someone wants to have two adjacent lists, or a list followed by - an indented code block. - -- Changing bullet characters, or changing from bullets to numbers or - vice versa, starts a new list. I think that is almost always going - to be the writer's intent. - -- The number that begins an ordered list item may be followed by - either `.` or `)`. Changing the delimiter style starts a new - list. - -- The start number of an ordered list is significant. - -- [Fenced code blocks](http://jgm.github.io/stmd/spec.html#fenced-code-blocks) are supported, delimited by either - backticks (` ``` `) or tildes (` ~~~ `). - -In all of this, I have been guided by eight years experience writing -Markdown implementations in several languages, including the first -Markdown parser not based on regular expression substitutions -([pandoc](http://github.com/jgm/pandoc)) and the first Markdown parsers -based on PEG grammars -([peg-markdown](http://github.com/jgm/peg-markdown), -[lunamark](http://github.com/jgm/lunamark)). Maintaining these projects -and responding to years of user feedback have given me a good sense of -the complexities involved in parsing Markdown, and of the various design -decisions that can be made. I have also explored differences between -Markdown implementations extensively using [babelmark -2](http://johnmacfarlane.net/babelmark2/). In the early phases of -working out the spec, I benefited greatly from collaboration with David -Greenspan, and from extensive discussions with a group of industrial -users of Markdown, including Jeff Atwood, Vincent Marti, and Neil -Williams. - -### Contributing - -There is a [forum for discussing -CommonMark](http://talk.commonmark.org); you should use it instead of -github issues for questions and possibly open-ended discussions. -Use the [github issue tracker](http://github.com/jgm/stmd/issues) -only for simple, clear, actionable issues. - -- cgit v1.2.3 From d248d95dd066fd4e508bca96b9c35db3aeda259c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 14:14:55 -0700 Subject: Put multiple versions of spec on website. --- Makefile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9ca8eb2..363772c 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ BENCHINP?=README.md PROG?=./cmark JSMODULES=$(wildcard js/lib/*.js) PREFIX?=/usr/local +SPEC=spec.txt +SPECVERSION=$(shell grep version: $(SPEC) | sed -e 's/version: *//') .PHONY: all spec leakcheck clean fuzztest dingus upload jshint test testjs benchjs @@ -16,7 +18,7 @@ README.html: README.md template.html spec: test spec.html -spec.md: spec.txt +spec.md: $(SPEC) perl spec2md.pl < $< > $@ spec.html: spec.md template.html @@ -28,13 +30,13 @@ spec.pdf: spec.md template.tex specfilter.hs --number-sections -V documentclass=report -V tocdepth=2 \ -V classoption=twosides -test: spec.txt +test: $(SPEC) perl runtests.pl $< $(PROG) js/commonmark.js: js/lib/index.js ${JSMODULES} browserify --standalone commonmark $< -o $@ -testjs: spec.txt +testjs: $(SPEC) node js/test.js jshint: @@ -87,16 +89,27 @@ fuzztest: for i in `seq 1 10`; do \ time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done -update-site: spec.html js/commonmark.js - cp spec.html _site/ - echo "TODO" > _site/index.html +index.md: _site/$(SPECVERSION)/index.html + echo "" > $@ + for vers in $(shell cd _site; ls -d -t 0.*) ; do \ + echo "- [Version $$vers](/$$vers/)" >> $@ ; done + +_site/index.html: index.md + pandoc --template template.html -S -s -t html5 -o $@ $< + +_site/$(SPECVERSION)/index.html: spec.html + mkdir -p _site/$(SPECVERSION) + cp $< $@ + cd _site; git add $(SPECVERSION)/index.html; git commit -a -m "Added version $(SPECVERSION) of spec"; cd .. + +update-site: spec.html js/commonmark.js _site/index.html _site/$(SPECVERSION)/index.html cp js/index.html _site/js/ cp js/commonmark.js _site/js/ cp js/LICENSE _site/js/ (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..) clean: - -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so + -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so index.md -rm js/commonmark.js -rm -rf *.dSYM -rm -f README.html -- cgit v1.2.3 From c5a0fdf28119c60baf755ce9de676c0d7b98740a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 14:17:35 -0700 Subject: Add title to list of versions at spec. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 363772c..2c293d1 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ fuzztest: time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done index.md: _site/$(SPECVERSION)/index.html - echo "" > $@ + echo "% CommonMark Spec\n" > $@ for vers in $(shell cd _site; ls -d -t 0.*) ; do \ echo "- [Version $$vers](/$$vers/)" >> $@ ; done -- cgit v1.2.3 From ee570cab6af160bd50262f81f0e1f17e988b6e45 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 18:02:24 -0700 Subject: spec2md.pl: Make Example numbers into links. --- spec2md.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec2md.pl b/spec2md.pl index 1b4f26e..1426095 100644 --- a/spec2md.pl +++ b/spec2md.pl @@ -12,7 +12,7 @@ while () { if ($stage == 0) { $example++; print "\n
\n"; - print "
Example $example
\n\n"; + print "\n\n"; print "````````````````````````````````````````````````````````` markdown\n"; } elsif ($stage == 1) { print "`````````````````````````````````````````````````````````\n\n"; -- cgit v1.2.3 From 76df41816c4e57a6c8ada845a2ead90d4d3b5b97 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 18:52:10 -0700 Subject: Have index.html on web page redirect to latest version. --- Makefile | 14 ++++++-------- spec.redirect.in | 11 +++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 spec.redirect.in diff --git a/Makefile b/Makefile index 2c293d1..c2899ea 100644 --- a/Makefile +++ b/Makefile @@ -89,27 +89,25 @@ fuzztest: for i in `seq 1 10`; do \ time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done -index.md: _site/$(SPECVERSION)/index.html - echo "% CommonMark Spec\n" > $@ - for vers in $(shell cd _site; ls -d -t 0.*) ; do \ - echo "- [Version $$vers](/$$vers/)" >> $@ ; done +_site/spec.html: spec.redirect.in + perl -pe 's/VERSION/$(SPECVERSION)/g' $< > $@ -_site/index.html: index.md - pandoc --template template.html -S -s -t html5 -o $@ $< +_site/index.html: _site/spec.html + cp $< $@ _site/$(SPECVERSION)/index.html: spec.html mkdir -p _site/$(SPECVERSION) cp $< $@ cd _site; git add $(SPECVERSION)/index.html; git commit -a -m "Added version $(SPECVERSION) of spec"; cd .. -update-site: spec.html js/commonmark.js _site/index.html _site/$(SPECVERSION)/index.html +update-site: spec.html js/commonmark.js _site/index.html _site/$(SPECVERSION)/index.html _site/spec.html cp js/index.html _site/js/ cp js/commonmark.js _site/js/ cp js/LICENSE _site/js/ (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..) clean: - -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so index.md + -rm -f test $(SRCDIR)/*.o $(SRCDIR)/scanners.c $(SRCDIR)/html/*.o libcmark.so -rm js/commonmark.js -rm -rf *.dSYM -rm -f README.html diff --git a/spec.redirect.in b/spec.redirect.in new file mode 100644 index 0000000..1727497 --- /dev/null +++ b/spec.redirect.in @@ -0,0 +1,11 @@ + + + + CommonMark Spec + + + +

The most recent version of the CommonMark Spec can be found +at http://spec.commonmark.org/VERSION/.

+ + -- cgit v1.2.3 From f22281f2d15a786d512269ddd546b5b4c0462f4c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 20:50:01 -0700 Subject: Added clear and permalink to dingus. Serve dingus from dingus.html. Add redirect page as index.html. --- js/dingus.html | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ js/index.html | 118 +++++--------------------------------------------- 2 files changed, 145 insertions(+), 107 deletions(-) create mode 100644 js/dingus.html diff --git a/js/dingus.html b/js/dingus.html new file mode 100644 index 0000000..ecaeb33 --- /dev/null +++ b/js/dingus.html @@ -0,0 +1,134 @@ + + + + + commonmark.js demo + + + + + + + + +
+
+

commonmark.js dingus

+
+
+
+
Parsed in + ms. Rendered in ms.
+

clear 

+ +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + diff --git a/js/index.html b/js/index.html index 6f462a9..3f6c904 100644 --- a/js/index.html +++ b/js/index.html @@ -1,108 +1,12 @@ - - - - - commonmark.js demo - - - - - - - - -
    -
    -

    commonmark.js dingus

    -
    -
    -
    -
    Parsed in - ms. Rendered in ms.
    - -
      -
      -
      - -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      - + + + + CommonMark dingus + + + +

      The most recent version of the CommonMark dingus can be found +at /dingus.html/.

      + -- cgit v1.2.3 From 695b5f3705fbdb42dd7422e4dc88f25e895d1406 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 21:17:10 -0700 Subject: Dingus improvements; moved to top level. --- Makefile | 4 +- dingus.html | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ js/dingus.html | 134 -------------------------------------------------------- 3 files changed, 137 insertions(+), 136 deletions(-) create mode 100644 dingus.html delete mode 100644 js/dingus.html diff --git a/Makefile b/Makefile index c2899ea..b1a950b 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ install: libcmark.so $(cmark_HDR) $(HTML_HDR) install $(HTML_HDR) $(PREFIX)/include/cmark/html/ dingus: js/commonmark.js - cd js && echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000 + echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000 leakcheck: $(PROG) cat leakcheck.md | valgrind --leak-check=full --dsymutil=yes $(PROG) @@ -101,7 +101,7 @@ _site/$(SPECVERSION)/index.html: spec.html cd _site; git add $(SPECVERSION)/index.html; git commit -a -m "Added version $(SPECVERSION) of spec"; cd .. update-site: spec.html js/commonmark.js _site/index.html _site/$(SPECVERSION)/index.html _site/spec.html - cp js/index.html _site/js/ + cp dingus.html _site/ cp js/commonmark.js _site/js/ cp js/LICENSE _site/js/ (cd _site ; git pull ; git commit -a -m "Updated site for latest spec, js" ; git push; cd ..) diff --git a/dingus.html b/dingus.html new file mode 100644 index 0000000..8c35fe5 --- /dev/null +++ b/dingus.html @@ -0,0 +1,135 @@ + + + + + commonmark.js demo + + + + + + + + +
      +
      +

      commonmark.js dingus

      +
      +
      +
      +
      Parsed in + ms. Rendered in ms.
      +

      clear 

      + +
        +
        +
        + +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        + + diff --git a/js/dingus.html b/js/dingus.html deleted file mode 100644 index ecaeb33..0000000 --- a/js/dingus.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - commonmark.js demo - - - - - - - - -
        -
        -

        commonmark.js dingus

        -
        -
        -
        -
        Parsed in - ms. Rendered in ms.
        -

        clear 

        - -
          -
          -
          - -
          -
          -
          -
          -
          -
          -
          -
          -
          -
          -
          -
          - - -- cgit v1.2.3 From 9d8dba5acd00edec29e385ac859bc28c9991dae9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 26 Oct 2014 21:42:22 -0700 Subject: Added (interact) links to spec, to open examples in dingus. --- spec2md.pl | 2 +- template.html | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spec2md.pl b/spec2md.pl index 1426095..f93aad8 100644 --- a/spec2md.pl +++ b/spec2md.pl @@ -12,7 +12,7 @@ while () { if ($stage == 0) { $example++; print "\n
          \n"; - print "\n\n"; + print "\n\n"; print "````````````````````````````````````````````````````````` markdown\n"; } elsif ($stage == 1) { print "`````````````````````````````````````````````````````````\n\n"; diff --git a/template.html b/template.html index 0eaf299..b17d285 100644 --- a/template.html +++ b/template.html @@ -47,6 +47,7 @@ pre.html span.space:after { border: 1px solid #666; } div.examplenum { font-size: 82%; text-align: left; } +a.dingus { color: red; } a.footnoteRef > sup:before { content: "["; } @@ -58,6 +59,20 @@ a.footnoteRef > sup { font-size: 100%; } + + $if(title)$ -- cgit v1.2.3 From 6c3ed4e899bfba4dddd763045fcec2375341e4fc Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 27 Oct 2014 08:48:19 -0700 Subject: dingus: Show HTML tab if query has text. This should be a safer default; if someone sends you dangerous HTML, you'll see it immediately. --- dingus.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dingus.html b/dingus.html index 8c35fe5..7c3a7c7 100644 --- a/dingus.html +++ b/dingus.html @@ -20,7 +20,7 @@ function getQueryVariable(variable) var pair = vars[i].split("="); if(pair[0] == variable){return decodeURIComponent(pair[1]);} } - return(''); + return null; } @@ -64,7 +64,12 @@ $(document).ready(function() { render(); }, 0); // ms delay }; - $("#text").val(getQueryVariable("text")); + var initial_text = getQueryVariable("text"); + if (initial_text) { + $("#text").val(initial_text); + // show HTML tab if text is from query + $('#result-tabs a[href="#result"]').tab('show'); + } parseAndRender(); $("#clear-text-box").click(function(e) { $("#text").val(''); @@ -114,7 +119,7 @@ $(document).ready(function() {
            -