16 |
17 |
18 |
commonmark.js dingus
19 |
20 |
21 |
22 |
42 |
43 |
48 |
58 |
Parsed in
59 | ms. Rendered in ms.
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
$title$
6 |
72 |
73 |
74 |
75 | $if(title)$
76 |
$title$
77 | $endif$
78 | $if(version)$
79 |
Version $version$ ($date$)
80 | $endif$
81 |
82 | $for(author)$$author$$sep$; $endfor$
83 |
84 |
99 |
100 | $toc$
101 |
102 |
103 | $body$
104 |
105 |
106 |
--------------------------------------------------------------------------------
/changelog.spec.txt:
--------------------------------------------------------------------------------
1 | [0.16]
2 |
3 | * Rewrote beginning of Entities section, clarifying that only
4 | entities not in code blocks or spans are decoded.
5 | * Removed defective Example 449 (#284).
6 | * Fixed typo (#283).
7 | * Added intended two-space hard-breaks in Examples 521, 523.
8 | * Clarified that brackets in general don't take precedence over emph
9 | (#258).
10 | * Clarified that final newline is removed from paragraph content
11 | (#176).
12 | * Talk of "info string" rather than "attributes" for code blocks
13 | (#262).
14 | * Clarified precedence of code spans, HTML tags, autolinks (#259).
15 | * Fixed a number of internal links and duplicate references in the spec.
16 | * Linkify "info string" in spec.
17 | * Use shortcut reference links when possible in spec.txt.
18 | * cmark itself is now used to build spec.html, rather than pandoc.
19 | * Use shortcut reference links when possible in spec.txt. This
20 | relies on the new `spec2md.py` behavior of creating references
21 | for all internal anchors.
22 | * Moved some examples from block to inline HTML section.
23 | * Added examples of non-comments (#264).
24 | * Changed rule for comments to conform to HTML5 spec.
25 | * Made clear that any sequence of characters is a valid document
26 | (#266).
27 | * Changed wording: "is preferred" -> "takes precedence."
28 | * Regularized spelling of "non-space character" and added links
29 | (#260).
30 | * Use four spaces rather than five to show "four spaces is too much"
31 | (#261).
32 |
33 | [0.15]
34 |
35 | * Fixed some typos with "left-" and "right-flanking" delimiters in the
36 | section on emphasis and strong emphasis (#257).
37 |
38 | [0.14]
39 |
40 | * Clarified indented code blocks. Previously the spec said, wrongly,
41 | that a blank line was needed between a paragraph and a following
42 | code block. It is only needed between a code block and a following
43 | paragraph (due to lazy continuations). (Thanks to textnut.)
44 | * Added definitions of whitespace, unicode whitespace, punctuation,
45 | ASCII punctuation (#108).
46 | * Improved rules for emphasis and strong emphasis. This improves
47 | parsing of emphasis around punctuation. For background see
48 |
. The basic idea of the change
49 | is that if the delimiter is part of a delimiter clump that has
50 | punctuation to the left and a normal character (non-space,
51 | non-punctuation) to the right, it can only be an opener. If it has
52 | punctuation to the right and a normal character (non-space,
53 | non-punctuation) to the left, it can only be a closer. This handles
54 | cases like
55 |
56 | **Gomphocarpus (*Gomphocarpus physocarpus*, syn. *Asclepias
57 | physocarpa*)**
58 |
59 | and
60 |
61 | **foo "*bar*" foo**
62 |
63 | better than before.
64 | * Added test case for link-in-link-in-image (#252).
65 | * Fixed broken internal references.
66 | * Added another example of an unclarity in the canonical Markdown
67 | syntax description.
68 | * Reworded the principle of uniformity to be more general; it applies
69 | to all container blocks, not just list items.
70 | * Added a rule for empty list items (#242).
71 | * Clarified precedence of empty list items over setext header lines
72 | (#95).
73 | * Added an example with two blank lines in fenced code in a sublist (#180).
74 | * Added an explicit CC-BY-SA license to the spec (#55).
75 |
76 | [0.13]
77 |
78 | * Updated path of test program.
79 | * Use terminology "plain textual content" instead of "string."
80 | * Added condition that conforming parsers strip or replace NULL characters.
81 | * Changed Example 196 to reflect the spec's rules. It should not be a loose
82 | list as it has no blank lines.
83 | * Adjusted semantically insignificant formatting of HTML output.
84 | * Added example to spec of shortcut link with following space (#214).
85 |
--------------------------------------------------------------------------------
/dingus/dingus.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | /*eslint-env browser*/
4 | /*global $, _ */
5 |
6 | var commonmark = window.commonmark;
7 | var writer = new commonmark.HtmlRenderer({ sourcepos: true });
8 | var xmlwriter = new commonmark.XmlRenderer({ sourcepos: true });
9 | var reader = new commonmark.Parser();
10 |
11 | function getQueryVariable(variable) {
12 | var query = window.location.search.substring(1);
13 | var vars = query.split("&");
14 | for (var i = 0; i < vars.length; i++) {
15 | var pair = vars[i].split("=");
16 | if (pair[0] === variable){
17 | return decodeURIComponent(pair[1]);
18 | }
19 | }
20 | return null;
21 | }
22 |
23 | var render = function(parsed) {
24 | if (parsed === undefined) {
25 | return;
26 | }
27 | var startTime = new Date().getTime();
28 | var result = writer.render(parsed);
29 | var endTime = new Date().getTime();
30 | var renderTime = endTime - startTime;
31 | $("#preview").html(result);
32 | $("#html").text(result);
33 | $("#ast").text(xmlwriter.render(parsed));
34 | $("#rendertime").text(renderTime);
35 | };
36 |
37 | var syncScroll = function() {
38 | var textarea = $("#text");
39 | var lineHeight = parseFloat(textarea.css('line-height'));
40 | // NOTE this assumes we don't have wrapped lines,
41 | // so we set white-space: nowrap on the textarea:
42 | var lineNumber = Math.floor(textarea.scrollTop() / lineHeight) + 1;
43 | var elt = $("#preview [data-sourcepos^='" + lineNumber + ":']").last();
44 | if (elt.length > 0) {
45 | if (elt.offset()) {
46 | var curTop = $("#preview").scrollTop();
47 | $("#preview").animate({
48 | scrollTop: curTop + elt.offset().top - 100
49 | }, 50);
50 | }
51 | }
52 | };
53 |
54 | var markSelection = function() {
55 | var cursorPos = $("#text").prop("selectionStart");
56 | // now count newline up to this pos
57 | var textval = $("#text").val();
58 | var lineNumber = 1;
59 | for (var i = 0; i < cursorPos; i++) {
60 | if (textval.charAt(i) === '\n') {
61 | lineNumber++;
62 | }
63 | }
64 | var elt = $("#preview [data-sourcepos^='" + lineNumber + ":']").last();
65 | if (elt.length > 0) {
66 | $("#preview .selected").removeClass("selected");
67 | elt.addClass("selected");
68 | syncScroll();
69 | }
70 | };
71 |
72 | var parseAndRender = function() {
73 | var textarea = $("#text");
74 | var startTime = new Date().getTime();
75 | var parsed = reader.parse(textarea.val());
76 | var endTime = new Date().getTime();
77 | var parseTime = endTime - startTime;
78 | $("#parsetime").text(parseTime);
79 | $(".timing").css('visibility', 'visible');
80 | render(parsed);
81 | markSelection();
82 | };
83 |
84 | $(document).ready(function() {
85 | var textarea = $("#text");
86 | var initial_text = getQueryVariable("text");
87 | var smartSelected = getQueryVariable("smart") === "1";
88 | $("#smart").prop('checked', smartSelected);
89 | reader.options.smart = smartSelected;
90 | if (initial_text) {
91 | textarea.val(initial_text);
92 | // show HTML tab if text is from query
93 | $('#result-tabs a[href="#result"]').tab('show');
94 | }
95 |
96 | parseAndRender();
97 |
98 | $("#clear-text-box").click(function() {
99 | textarea.val('');
100 | parseAndRender();
101 | });
102 |
103 | $("#permalink").click(function() {
104 | var smart = $("#smart").prop('checked');
105 | window.location.pathname = "/index.html";
106 | window.location.search = "text=" + encodeURIComponent(textarea.val()) +
107 | (smart ? '&smart=1' : '');
108 | });
109 |
110 | textarea.bind('input propertychange',
111 | _.debounce(parseAndRender, 50, { maxWait: 100 }));
112 | textarea.on('scroll', _.debounce(syncScroll, 50, { maxWait: 50 }));
113 | textarea.on('keydown click focus',
114 | _.debounce(markSelection, 50, { maxWait: 100}));
115 |
116 | $("#smart").click(function() {
117 | reader.options.smart = $("#smart").prop('checked');
118 | parseAndRender();
119 | });
120 | });
121 |
--------------------------------------------------------------------------------
/js/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, John MacFarlane
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above
12 | copyright notice, this list of conditions and the following
13 | disclaimer in the documentation and/or other materials provided
14 | with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
28 | ---
29 |
30 | lib/normalize-reference.js is a slightly modified version of
31 | https://github.com/dmoscrop/fold-case:
32 |
33 | Copyright Mathias Bynens
34 |
35 | Permission is hereby granted, free of charge, to any person obtaining
36 | a copy of this software and associated documentation files (the
37 | "Software"), to deal in the Software without restriction, including
38 | without limitation the rights to use, copy, modify, merge, publish,
39 | distribute, sublicense, and/or sell copies of the Software, and to
40 | permit persons to whom the Software is furnished to do so, subject to
41 | the following conditions:
42 |
43 | The above copyright notice and this permission notice shall be
44 | included in all copies or substantial portions of the Software.
45 |
46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
47 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
48 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
49 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
50 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
51 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
52 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 |
54 | ---
55 |
56 | lib/from-code-point.js is derived from a polyfill
57 | Copyright Mathias Bynens
58 |
59 | Permission is hereby granted, free of charge, to any person obtaining
60 | a copy of this software and associated documentation files (the
61 | "Software"), to deal in the Software without restriction, including
62 | without limitation the rights to use, copy, modify, merge, publish,
63 | distribute, sublicense, and/or sell copies of the Software, and to
64 | permit persons to whom the Software is furnished to do so, subject to
65 | the following conditions:
66 |
67 | The above copyright notice and this permission notice shall be
68 | included in all copies or substantial portions of the Software.
69 |
70 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
71 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
72 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
73 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
74 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
75 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
76 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77 |
78 | ---
79 |
80 | bench/samples/*.md:
81 |
82 | With the exception of `bench/samples/README.md`, the samples in
83 | `bench/samples` are taken from https://github.com/markdown-it/markdown-it.
84 |
85 | Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin.
86 |
87 | Permission is hereby granted, free of charge, to any person
88 | obtaining a copy of this software and associated documentation
89 | files (the "Software"), to deal in the Software without
90 | restriction, including without limitation the rights to use,
91 | copy, modify, merge, publish, distribute, sublicense, and/or sell
92 | copies of the Software, and to permit persons to whom the
93 | Software is furnished to do so, subject to the following
94 | conditions:
95 |
96 | The above copyright notice and this permission notice shall be
97 | included in all copies or substantial portions of the Software.
98 |
99 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
100 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
101 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
102 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
103 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
104 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
105 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
106 | OTHER DEALINGS IN THE SOFTWARE.
107 |
108 | ---
109 |
110 | The CommonMark spec (spec.txt) in test/ is
111 |
112 | Copyright (C) 2014-15 John MacFarlane
113 |
114 | Released under the Creative Commons CC-BY-SA 4.0 license:
115 | .
116 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CommonMark Spec
6 |
72 |
73 |
74 |
75 | CommonMark Spec
76 |
77 |
78 |
79 |
94 |
95 |
96 |
97 |
98 | Latest version (0.22) (2015-08-23) (view changes)
99 | discussion forum | interactive dingus | repository | changelog
100 | Older versions:
101 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/changelog.txt:
--------------------------------------------------------------------------------
1 | [0.22]
2 |
3 | * Don't list `title` twice as HTML block tag (Robin Stocker).
4 | * More direct example of type 7 HTML block starting with closing tag.
5 | * Clarified rule 7 for HTML blocks. `pre`, `script`, and `style`
6 | are excluded because they're covered by other rules.
7 | * Clarified that type 7 HTML blocks can start with a closing tag (#349).
8 | * Removed `pre` tag from rule 6 of HTML blocks (#355).
9 | It is already covered by rule 1, so this removes an ambiguity.
10 | * Added `iframe` to list of tags that always start HTML blocks (#352).
11 | * Added example of list item starting with two blanks (#332).
12 | * Added test case clarifying laziness in block quotes (see
13 | jgm/commonmark.js#60).
14 | * Add an example with mixed indentation code block in "Tabs" section
15 | (Robin Stocker). This makes sure that implementations skip columns instead
16 | of offsets for continued indented code blocks.
17 | * Clarified that in ATX headers, the closing `#`s must be unescaped,
18 | and removed misleading reference to "non-whitespace character" in
19 | an example (#356).
20 | * Changed anchor for "non-whitespace character" to reflect new name.
21 | * Removed ambiguities concerning lines and line endings (#357, Lasse
22 | R.H. Nielsen). The previous spec allowed, technically, that a line
23 | ending in `\r\n` might be considered to have two line endings,
24 | or that the `\r` might be considered part of the line and the
25 | `\n` the line ending. These fixes rule out those interpretations.
26 | * Clarify that a character is any code point.
27 | * Space in "code point".
28 | * Capitalize "Unicode".
29 | * Reflow paragraph to avoid unwanted list item (#360, #361).
30 | * Avoid extra space before section number in `spec.md`.
31 | * `makespec.py`: Use `check_output` for simpler `pipe_through_prog`.
32 | * In README, clarified build requirements for `spec.html`, `spec.pdf`.
33 | * Fixed some encoding issues in `makespec.py` (#353).
34 | * Fixed various problems with `spec.pdf` generation (#353).
35 | * Added version to coverpage in PDF version of spec.
36 |
37 | [0.21.1]
38 |
39 | * Added date.
40 |
41 | [0.21]
42 |
43 | * Changed handling of tabs. Instead of having a preprocessing step
44 | where tabs are converted to spaces, we now handle tabs directly in
45 | the parser. This allows tabs to be retained in code blocks and code
46 | spans. This change adds some general language to the effect that,
47 | for purposes of determining block structure, tabs are to be treated
48 | just like equivalent spaces.
49 | * Completely rewrote spec for HTML blocks. The new spec provides
50 | better handling of tags like ``, which can be either block
51 | or inline level content, better handling of custom tags, and
52 | better handling of verbatim contexts like ``, comments,
53 | and `