X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=tests%2Forg.simantics.scl.compiler.tests%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fmarkdown%2Fspec.txt;h=64a60b19dece4400682bab148c4c54ab9eb09d32;hb=3ccd513530bc718ef384780d3151ddbb85600986;hp=bdaed436dd9e20ae200ea1e49be4b10c679c730f;hpb=bb5a3edf299cb943999c72c69dd68fb740c8a506;p=simantics%2Fplatform.git
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/spec.txt b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/spec.txt
index bdaed436d..64a60b19d 100644
--- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/spec.txt
+++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/markdown/spec.txt
@@ -1,8 +1,8 @@
---
title: CommonMark Spec
author: John MacFarlane
-version: 0.25
-date: '2016-03-24'
+version: 0.27
+date: '2016-11-18'
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
...
@@ -11,14 +11,94 @@ license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
## What is Markdown?
Markdown is a plain text format for writing structured documents,
-based on conventions used for indicating formatting in email and
-usenet posts. It was developed in 2004 by John Gruber, who wrote
-the first Markdown-to-HTML converter in perl, and it soon became
-widely used in websites. By 2014 there were dozens of
-implementations in many languages. Some of them extended basic
-Markdown syntax with conventions for footnotes, definition lists,
-tables, and other constructs, and some allowed output not just in
-HTML but in LaTeX and many other formats.
+based on conventions for indicating formatting in email
+and usenet posts. It was developed by John Gruber (with
+help from Aaron Swartz) and released in 2004 in the form of a
+[syntax description](http://daringfireball.net/projects/markdown/syntax)
+and a Perl script (`Markdown.pl`) for converting Markdown to
+HTML. In the next decade, dozens of implementations were
+developed in many languages. Some extended the original
+Markdown syntax with conventions for footnotes, tables, and
+other document elements. Some allowed Markdown documents to be
+rendered in formats other than HTML. Websites like Reddit,
+StackOverflow, and GitHub had millions of people using Markdown.
+And Markdown started to be used beyond the web, to author books,
+articles, slide shows, letters, and lecture notes.
+
+What distinguishes Markdown from many other lightweight markup
+syntaxes, which are often easier to write, is its readability.
+As Gruber writes:
+
+> The overriding design goal for Markdown's formatting syntax is
+> to make it as readable as possible. The idea is that a
+> Markdown-formatted document should be publishable as-is, as
+> plain text, without looking like it's been marked up with tags
+> or formatting instructions.
+> (
#âfoo
-```````````````````````````````` - - This is not a heading, because the first `#` is escaped: ```````````````````````````````` example @@ -1890,7 +1987,7 @@ by their start and end conditions. The block begins with a line that meets a [start condition](@) (after up to three spaces optional indentation). It ends with the first subsequent line that meets a matching [end condition](@), or the last line of -the document, if no line is encountered that meets the +the document or other [container block]), if no line is encountered that meets the [end condition]. If the first line meets both the [start condition] and the [end condition], the block will contain just that line. @@ -1920,7 +2017,8 @@ followed by one of the strings (case-insensitive) `address`, `article`, `aside`, `base`, `basefont`, `blockquote`, `body`, `caption`, `center`, `col`, `colgroup`, `dd`, `details`, `dialog`, `dir`, `div`, `dl`, `dt`, `fieldset`, `figcaption`, `figure`, -`footer`, `form`, `frame`, `frameset`, `h1`, `head`, `header`, `hr`, +`footer`, `form`, `frame`, `frameset`, +`h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `head`, `header`, `hr`, `html`, `iframe`, `legend`, `li`, `link`, `main`, `menu`, `menuitem`, `meta`, `nav`, `noframes`, `ol`, `optgroup`, `option`, `p`, `param`, `section`, `source`, `summary`, `table`, `tbody`, `td`, @@ -2224,6 +2322,7 @@ import Text.HTML.TagSoup main :: IO () main = print $ parseTags tags +okay .
import Text.HTML.TagSoup
@@ -2231,6 +2330,7 @@ import Text.HTML.TagSoup
main :: IO ()
main = print $ parseTags tags
+okay
```````````````````````````````` @@ -2242,12 +2342,14 @@ A script tag (type 1): document.getElementById("demo").innerHTML = "Hello JavaScript!"; +okay . +okay
```````````````````````````````` @@ -2260,6 +2362,7 @@ h1 {color:red;} p {color:blue;} +okay . +okay
```````````````````````````````` @@ -2355,11 +2459,13 @@ A comment (type 2): bar baz --> +okay . +okay
```````````````````````````````` @@ -2372,12 +2478,14 @@ A processing instruction (type 3): echo '>'; ?> +okay . '; ?> +okay
```````````````````````````````` @@ -2405,6 +2513,7 @@ function matchwo(a,b) } } ]]> +okay . +okay
```````````````````````````````` @@ -3162,8 +3272,8 @@ Four spaces gives us a code block: ```````````````````````````````` -The Laziness clause allows us to omit the `>` before a -paragraph continuation line: +The Laziness clause allows us to omit the `>` before +[paragraph continuation text]: ```````````````````````````````` example > # Foo @@ -3269,8 +3379,8 @@ foo ```````````````````````````````` -Note that in the following case, we have a paragraph -continuation line: +Note that in the following case, we have a [lazy +continuation line]: ```````````````````````````````` example > foo @@ -3292,7 +3402,7 @@ To see why, note that in the `- bar` is indented too far to start a list, and can't be an indented code block because indented code blocks cannot -interrupt paragraphs, so it is a [paragraph continuation line]. +interrupt paragraphs, so it is [paragraph continuation text]. A block quote can be empty: @@ -3521,7 +3631,7 @@ The following rules define [list items]: 1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of blocks *Bs* starting with a [non-whitespace character] and not separated from each other by more than one blank line, and *M* is a list - marker of width *W* followed by 0 < *N* < 5 spaces, then the result + marker of width *W* followed by 1 ⤠*N* ⤠4 spaces, then the result of prepending *M* and the following spaces to the first line of *Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a list item with *Bs* as its contents. The type of the list item @@ -3529,6 +3639,12 @@ The following rules define [list items]: If the list item is ordered, then it is also assigned a start number, based on the ordered list marker. + Exceptions: When the first list item in a [list] interrupts + a paragraph---that is, when it starts on a line that would + otherwise count as [paragraph continuation text]---then (a) + the lines *Ls* must not begin with a blank line, and (b) if + the list item is ordered, the start number must be 1. + For example, let *Ls* be the lines ```````````````````````````````` example @@ -3703,66 +3819,20 @@ any following content, so these are not list items: ```````````````````````````````` -A list item may not contain blocks that are separated by more than -one blank line. Thus, two blank lines will end a list, unless the -two blanks are contained in a [fenced code block]. +A list item may contain blocks that are separated by more than +one blank line. ```````````````````````````````` example - foo - bar - -- foo - - - bar - -- ``` - foo - bar - ``` - -- baz - - + ``` - foo - - - bar - ``` .foo
bar
foo
-bar
-foo
-
-
-bar
-
-baz
-foo
-
-
-bar
-
-Foo
bar
-baz
-
-
-
-````````````````````````````````
-
-
-```````````````````````````````` example
-- Foo
-
- bar
-
- baz
-.
-Foo
-bar
+baz
baz
-
````````````````````````````````
-
Note that ordered list start numbers must be nine digits or less:
```````````````````````````````` example
@@ -4164,6 +4213,20 @@ A list may start or end with an empty list item:
````````````````````````````````
+However, an empty list item cannot interrupt a paragraph:
+
+```````````````````````````````` example
+foo
+*
+
+foo
+1.
+.
+foo +*
+foo +1.
+```````````````````````````````` 4. **Indentation.** If a sequence of lines *Ls* constitutes a list item @@ -4361,13 +4424,18 @@ So, in this case we need two spaces indent: - foo - bar - baz + - boo .The number of windows in my house is
-` tags, since the list is "tight"), then - I need to buy - - new shoes - - a coat - - a plane ticket +``` markdown +I need to buy +- new shoes +- a coat +- a plane ticket +``` by itself should be a paragraph followed by a nested sublist. -Our adherence to the [principle of uniformity] -thus inclines us to think that there are two coherent packages: +Since it is well established Markdown practice to allow lists to +interrupt paragraphs inside list items, the [principle of +uniformity] requires us to allow this outside list items as +well. ([reStructuredText](http://docutils.sourceforge.net/rst.html) +takes a different approach, requiring blank lines before lists +even inside other list items.) -1. Require blank lines before *all* lists and blockquotes, - including lists that occur as sublists inside other list items. +In order to solve of unwanted lists in paragraphs with +hard-wrapped numerals, we allow only lists starting with `1` to +interrupt paragraphs. Thus, -2. Require blank lines in none of these places. +```````````````````````````````` example +The number of windows in my house is +14. The number of doors is 6. +. +
The number of windows in my house is +14. The number of doors is 6.
+```````````````````````````````` + +We may still get an unintended result in cases like + +```````````````````````````````` example +The number of windows in my house is +1. The number of doors is 6. +. +The number of windows in my house is
+bar
bar
-baz
+baz
+bim
+ bim
-
````````````````````````````````
-Thus, two blank lines can be used to separate consecutive lists of
-the same type, or to separate a list from an indented code block
-that would otherwise be parsed as a subparagraph of the final list
-item:
+To separate consecutive lists of the same type, or to separate a
+list from an indented code block that would otherwise be parsed
+as a subparagraph of the final list item, you can insert a blank HTML
+comment:
```````````````````````````````` example
- foo
- bar
+
- baz
- bim
@@ -4895,6 +4961,7 @@ item:
foo
code
````````````````````````````````
@@ -5611,6 +5680,16 @@ single spaces, just as they would be by a browser:
````````````````````````````````
+Not all [Unicode whitespace] (for instance, non-breaking space) is
+collapsed, however:
+
+```````````````````````````````` example
+`a  b`
+.
+a  b
`foo
```````````````````````````````` +The following case also illustrates the need for opening and +closing backtick strings to be equal in length: + +```````````````````````````````` example +`foo``bar`` +. +`foobar
*foo bar
-*foo bar +*
```````````````````````````````` @@ -6484,18 +6572,30 @@ __foo_ bar_foo bar baz
```````````````````````````````` - -But note: - ```````````````````````````````` example *foo**bar**baz* . -foobarbaz
+foobarbaz
```````````````````````````````` +Note that in the preceding case, the interpretation + +``` markdown +foobarbaz
+``` + + +is precluded by the condition that a delimiter that +can both open and close (like the `*` after `foo`) +cannot form emphasis if the sum of the lengths of +the delimiter runs containing the opening and +closing delimiters is a multiple of 3. + +The same condition ensures that the following +cases are all strong emphasis nested inside +emphasis, even when the interior spaces are +omitted: -The difference is that in the preceding case, the internal delimiters -[can close emphasis], while in the cases with spaces, they cannot. ```````````````````````````````` example ***foo** bar* @@ -6511,18 +6611,13 @@ The difference is that in the preceding case, the internal delimiters ```````````````````````````````` -Note, however, that in the following case we get no strong -emphasis, because the opening delimiter is closed by the first -`*` before `bar`: - ```````````````````````````````` example *foo**bar*** . -foobar**
+foobar
```````````````````````````````` - Indefinite levels of nesting are possible: ```````````````````````````````` example @@ -6615,18 +6710,13 @@ ____foo__ bar__ ```````````````````````````````` -But note: - ```````````````````````````````` example **foo*bar*baz** . -foobarbaz**
+foobarbaz
```````````````````````````````` -The difference is that in the preceding case, the internal delimiters -[can close emphasis], while in the cases with spaces, they cannot. - ```````````````````````````````` example ***foo* bar** . @@ -6921,14 +7011,14 @@ Rule 14: ```````````````````````````````` example ***foo*** . -foo
+foo
```````````````````````````````` ```````````````````````````````` example _____foo_____ . -foo
+foo
```````````````````````````````` @@ -6941,13 +7031,6 @@ Rule 15: ```````````````````````````````` -```````````````````````````````` example -**foo*bar** -. -foobar*
-```````````````````````````````` - - ```````````````````````````````` example *foo __bar *baz bim__ bam* . @@ -7076,8 +7159,7 @@ A [link destination](@) consists of either - a nonempty sequence of characters that does not include ASCII space or control characters, and includes parentheses only if (a) they are backslash-escaped or (b) they are part of - a balanced pair of unescaped parentheses that is not itself - inside a balanced pair of unescaped parentheses. + a balanced pair of unescaped parentheses. A [link title](@) consists of either @@ -7183,35 +7265,29 @@ Parentheses inside the link destination may be escaped: ```````````````````````````````` -One level of balanced parentheses is allowed without escaping: - -```````````````````````````````` example -[link]((foo)and(bar)) -. - -```````````````````````````````` - -However, if you have parentheses within parentheses, you need to escape -or use the `<...>` form: +Any number parentheses are allowed without escaping, as long as they are +balanced: ```````````````````````````````` example [link](foo(and(bar))) . -[link](foo(and(bar)))
+ ```````````````````````````````` +However, if you have unbalanced parentheses, you need to escape or use the +`<...>` form: ```````````````````````````````` example -[link](foo(and\(bar\))) +[link](foo\(and\(bar\)) . - + ```````````````````````````````` ```````````````````````````````` example -[link](foo(not a link)
+```````````````````````````````` In the following case `[bar][baz]` is parsed as a reference, `[foo]` as normal text: @@ -8218,11 +8330,11 @@ The link labels are case-insensitive: ```````````````````````````````` -If you just want bracketed text, you can backslash-escape the -opening `!` and `[`: +If you just want a literal `!` followed by bracketed text, you can +backslash-escape the opening `[`: ```````````````````````````````` example -\!\[foo] +!\[foo] [foo]: /url "title" . @@ -8853,7 +8965,7 @@ foo A regular line break (not in a code span or HTML tag) that is not preceded by two or more spaces or a backslash is parsed as a -softbreak. (A softbreak may be rendered in HTML either as a +[softbreak](@). (A softbreak may be rendered in HTML either as a [line ending] or as a space. The result will be the same in browsers. In the examples here, a [line ending] will be used.) @@ -8984,7 +9096,7 @@ blocks. But we cannot close unmatched blocks yet, because we may have a [lazy continuation line]. 2. Next, after consuming the continuation markers for existing -blocks, we look for new block starts (e.g. `>` for a block quote. +blocks, we look for new block starts (e.g. `>` for a block quote). If we encounter a new block start, we close any blocks unmatched in step 1 before creating the new block as a child of the last matched block.