diff --git a/README.md b/README.md index adbd320..bb1be2f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ md_proc [![Build Status](https://travis-ci.org/dikmax/md_proc.svg?branch=master)](https://travis-ci.org/dikmax/md_proc) [![codecov](https://codecov.io/gh/dikmax/md_proc/branch/master/graph/badge.svg)](https://codecov.io/gh/dikmax/md_proc) [![Pub](https://img.shields.io/pub/v/md_proc.svg)](https://pub.dartlang.org/packages/md_proc) -[![CommonMark spec](https://img.shields.io/badge/commonmark-0.26-green.svg)](http://spec.commonmark.org/) +[![CommonMark spec](https://img.shields.io/badge/commonmark-0.27-green.svg)](http://spec.commonmark.org/) Fast and [CommonMark]-compliant Markdown parser. diff --git a/pubspec.yaml b/pubspec.yaml index 656a779..57e93e6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: md_proc -version: 0.10.0 +version: 0.10.1 description: Fast CommonMark-compliant markdown parser author: Maxim Dikun homepage: https://github.com/dikmax/md_proc @@ -12,5 +12,4 @@ dev_dependencies: benchmark_harness: any coverage: any test: any - linter: ">=0.1.29" source_gen: '>=0.5.0 <0.6.0' diff --git a/test/data/spec.txt b/test/data/spec.txt index e2b6834..c66f93b 100644 --- a/test/data/spec.txt +++ b/test/data/spec.txt @@ -1,8 +1,8 @@ --- title: CommonMark Spec author: John MacFarlane -version: 0.26 -date: '2016-07-15' +version: 0.27 +date: '2016-11-18' license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' ... @@ -1985,7 +1985,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 or other [container block](@), 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. @@ -2015,7 +2015,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`, @@ -3636,11 +3637,11 @@ 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 list item 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. + 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 @@ -4730,8 +4731,7 @@ takes four spaces (a common case), but diverge in other cases. A [list](@) is a sequence of one or more list items [of the same type]. The list items -may be separated by single [blank lines], but two -blank lines end all containing lists. +may be separated by any number of blank lines. Two list items are [of the same type](@) if they begin with a [list marker] of the same type. @@ -4809,10 +4809,11 @@ Foo `Markdown.pl` does not allow this, through fear of triggering a list via a numeral in a hard-wrapped line: -```````````````````````````````` markdown +``` markdown The number of windows in my house is 14. The number of doors is 6. -```````````````````````````````` +``` + Oddly, though, `Markdown.pl` *does* allow a blockquote to interrupt a paragraph, even though the same considerations might apply. @@ -4821,10 +4822,12 @@ In CommonMark, we do allow lists to interrupt paragraphs, for two reasons. First, it is natural and not uncommon for people to start lists without blank lines: - I need to buy - - new shoes - - a coat - - a plane ticket +``` markdown +I need to buy +- new shoes +- a coat +- a plane ticket +``` Second, we are attracted to a @@ -4836,20 +4839,24 @@ Second, we are attracted to a (Indeed, the spec for [list items] and [block quotes] presupposes this principle.) This principle implies that if - * I need to buy - - new shoes - - a coat - - a plane ticket +``` markdown + * I need to buy + - new shoes + - a coat + - a plane ticket +``` is a list item containing a paragraph followed by a nested sublist, as all Markdown implementations agree it is (though the paragraph may be rendered without `

` 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. @@ -5671,6 +5678,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

+```````````````````````````````` + + Q: Why not just leave the spaces, since browsers will collapse them anyway? A: Because we might be targeting a non-HTML format, and we shouldn't rely on HTML-specific rendering assumptions. @@ -6558,7 +6575,7 @@ Note that in the preceding case, the interpretation is precluded by the condition that a delimiter that -can both open and close (like the `*` after `foo` +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. @@ -6590,12 +6607,6 @@ omitted: ```````````````````````````````` -```````````````````````````````` example -*foo**bar*** -. -

foobar

-```````````````````````````````` - Indefinite levels of nesting are possible: ```````````````````````````````` example @@ -7361,6 +7372,16 @@ may be used in titles: ```````````````````````````````` +Titles must be separated from the link using a [whitespace]. +Other [Unicode whitespace] like non-breaking space doesn't work. + +```````````````````````````````` example +[link](/url "title") +. +

link

+```````````````````````````````` + + Nested balanced quotes are not allowed without escaping: ```````````````````````````````` example @@ -8025,7 +8046,8 @@ following closing bracket: ```````````````````````````````` -Full references take precedence over shortcut references: +Full and compact references take precedence over shortcut +references: ```````````````````````````````` example [foo][bar] @@ -8036,6 +8058,31 @@ Full references take precedence over shortcut references:

foo

```````````````````````````````` +```````````````````````````````` example +[foo][] + +[foo]: /url1 +. +

foo

+```````````````````````````````` + +Inline links also take precedence: + +```````````````````````````````` example +[foo]() + +[foo]: /url1 +. +

foo

+```````````````````````````````` + +```````````````````````````````` example +[foo](not a link) + +[foo]: /url1 +. +

foo(not a link)

+```````````````````````````````` In the following case `[bar][baz]` is parsed as a reference, `[foo]` as normal text: @@ -9045,7 +9092,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. diff --git a/test/data/test_data.g.dart b/test/data/test_data.g.dart index 1bca95d..9f44d56 100644 --- a/test/data/test_data.g.dart +++ b/test/data/test_data.g.dart @@ -2626,6 +2626,9 @@ foo r'''`foo bar baz` ''': r'''

foo bar baz

+''', + r'''`a  b` +''': r'''

a  b

''', r'''`foo `` bar` ''': r'''

foo `` bar

@@ -3126,6 +3129,9 @@ bar>)

''', r'''[link](/url "title \""") ''': r'''

link

+''', + r'''[link](/url "title") +''': r'''

link

''', r'''[link](/url "title "and" title") ''': r'''

[link](/url "title "and" title")

@@ -3396,6 +3402,21 @@ bar>)

[foo]: /url1 [bar]: /url2 ''': r'''

foo

+''', + r'''[foo][] + +[foo]: /url1 +''': r'''

foo

+''', + r'''[foo]() + +[foo]: /url1 +''': r'''

foo

+''', + r'''[foo](not a link) + +[foo]: /url1 +''': r'''

foo(not a link)

''', r'''[foo][bar][baz] diff --git a/test/library_test.dart b/test/library_test.dart index c8ace56..09fb4e9 100644 --- a/test/library_test.dart +++ b/test/library_test.dart @@ -144,7 +144,7 @@ void main() { texSingleMHMHTestFunc); final Set texMathSingleBackslashContradictions = - new Set.from([287, 479, 495]); + new Set.from([287, 481, 497]); final TestFunc texSingleSpecMHTestFunc = mhTest( new Options(texMathSingleBackslash: true), (_, int num) => !texMathSingleBackslashContradictions.contains(num));