Skip to content

Commit

Permalink
Update commonmark spec to 0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
dikmax committed Nov 21, 2016
1 parent cace677 commit 9e647ad
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: md_proc
version: 0.10.0
version: 0.10.1
description: Fast CommonMark-compliant markdown parser
author: Maxim Dikun <[email protected]>
homepage: https://github.com/dikmax/md_proc
Expand All @@ -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'
115 changes: 81 additions & 34 deletions test/data/spec.txt
Original file line number Diff line number Diff line change
@@ -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/)'
...

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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`,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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 `<p>` 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.

Expand Down Expand Up @@ -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`
.
<p><code>a  b</code></p>
````````````````````````````````


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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -6590,12 +6607,6 @@ omitted:
````````````````````````````````


```````````````````````````````` example
*foo**bar***
.
<p><em>foo<strong>bar</strong></em></p>
````````````````````````````````

Indefinite levels of nesting are possible:

```````````````````````````````` example
Expand Down Expand Up @@ -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")
.
<p><a href="/url%C2%A0%22title%22">link</a></p>
````````````````````````````````


Nested balanced quotes are not allowed without escaping:

```````````````````````````````` example
Expand Down Expand Up @@ -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]
Expand All @@ -8036,6 +8058,31 @@ Full references take precedence over shortcut references:
<p><a href="/url2">foo</a></p>
````````````````````````````````

```````````````````````````````` example
[foo][]

[foo]: /url1
.
<p><a href="/url1">foo</a></p>
````````````````````````````````

Inline links also take precedence:

```````````````````````````````` example
[foo]()

[foo]: /url1
.
<p><a href="">foo</a></p>
````````````````````````````````

```````````````````````````````` example
[foo](not a link)

[foo]: /url1
.
<p><a href="/url1">foo</a>(not a link)</p>
````````````````````````````````

In the following case `[bar][baz]` is parsed as a reference,
`[foo]` as normal text:
Expand Down Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions test/data/test_data.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/library_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void main() {
texSingleMHMHTestFunc);

final Set<int> texMathSingleBackslashContradictions =
new Set<int>.from(<int>[287, 479, 495]);
new Set<int>.from(<int>[287, 481, 497]);
final TestFunc texSingleSpecMHTestFunc = mhTest(
new Options(texMathSingleBackslash: true),
(_, int num) => !texMathSingleBackslashContradictions.contains(num));
Expand Down

0 comments on commit 9e647ad

Please sign in to comment.