diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb5f8c178..17e470514 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,12 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
with the exception that 0.x versions can break between minor versions.
## Unreleased
+### Added
+- `InlineParserContext.getLinkReferenceDefinition` was added to allow
+ custom inline parsers to look up definitions for reference links.
### Changed
+- Link reference definition parsing has been changed according to the
+ spec: Definitions can now be in setext headings too.
- Check non-null arguments early and provide a nicer message
## [0.12.1] - 2018-11-13
diff --git a/commonmark-ext-gfm-strikethrough/src/test/java/org/commonmark/ext/gfm/strikethrough/StrikethroughTest.java b/commonmark-ext-gfm-strikethrough/src/test/java/org/commonmark/ext/gfm/strikethrough/StrikethroughTest.java
index 85ae72eb2..225977854 100644
--- a/commonmark-ext-gfm-strikethrough/src/test/java/org/commonmark/ext/gfm/strikethrough/StrikethroughTest.java
+++ b/commonmark-ext-gfm-strikethrough/src/test/java/org/commonmark/ext/gfm/strikethrough/StrikethroughTest.java
@@ -44,7 +44,7 @@ public void unmatched() {
@Test
public void threeInnerThree() {
- assertRendering("~~~foo~~~", "
~foo~
\n");
+ assertRendering("a ~~~foo~~~", "a ~foo~
\n");
}
@Test
diff --git a/commonmark-test-util/src/main/resources/cmark-regression.txt b/commonmark-test-util/src/main/resources/cmark-regression.txt
index 2984a3bef..62b1e7efe 100644
--- a/commonmark-test-util/src/main/resources/cmark-regression.txt
+++ b/commonmark-test-util/src/main/resources/cmark-regression.txt
@@ -4,8 +4,7 @@ Issue #113: EOL character weirdness on Windows
(Important: first line ends with CR + CR + LF)
```````````````````````````````` example
-line1
-
+line1
line2
.
line1
@@ -82,7 +81,8 @@ Issue #193 - unescaped left angle brackets in link destination
[a]:
.
-a
+[a]
+[a]: <te
````````````````````````````````
Issue #192 - escaped spaces in link destination
@@ -93,3 +93,64 @@ Issue #192 - escaped spaces in link destination
.
[a](te\ st)
````````````````````````````````
+
+Issue #527 - meta tags in inline contexts
+
+```````````````````````````````` example
+City:
+
+
+
+.
+City:
+
+
+
+````````````````````````````````
+
+Issue #530 - link parsing corner cases
+
+```````````````````````````````` example
+[a](\ b)
+
+[a](<[a](\ b)
+[a](<<b)
+[a](<b
+)
+````````````````````````````````
+
+Issue commonmark#526 - unescaped ( in link title
+
+```````````````````````````````` example
+[link](url ((title))
+.
+[link](url ((title))
+````````````````````````````````
+
+Issue commonamrk#517 - script, pre, style close tag without
+opener.
+
+```````````````````````````````` example
+
+
+
+
+
+.
+
+
+
+````````````````````````````````
+
+Issue #289.
+
+```````````````````````````````` example
+[a](
+.
+[a](<b) c>
+````````````````````````````````
diff --git a/commonmark-test-util/src/main/resources/commonmark.js-regression.txt b/commonmark-test-util/src/main/resources/commonmark.js-regression.txt
index 7300952fe..ec5143eff 100644
--- a/commonmark-test-util/src/main/resources/commonmark.js-regression.txt
+++ b/commonmark-test-util/src/main/resources/commonmark.js-regression.txt
@@ -15,10 +15,10 @@ bar
Type 7 HTML block followed by whitespace (#98).
```````````````````````````````` example
-
+
x
.
-
+
x
````````````````````````````````
@@ -95,10 +95,67 @@ Issue #116 - tabs before and after ATX closing heading
foo
````````````````````````````````
-commonmark/CommonMark#493 - escaped space not allowed in link
-destination.
+commonmark/CommonMark#493 - escaped space not allowed in link destination.
+
```````````````````````````````` example
[link](a\ b)
.
[link](a\ b)
````````````````````````````````
+
+Issue #527 - meta tags in inline contexts
+
+```````````````````````````````` example
+City:
+
+
+
+.
+City:
+
+
+
+````````````````````````````````
+
+Double-encoding.
+
+```````````````````````````````` example
+[XSS](javascript:alert%28'XSS'%29)
+.
+XSS
+````````````````````````````````
+
+Issue commonamrk#517 - script, pre, style close tag without
+opener.
+
+```````````````````````````````` example
+
+
+
+
+
+.
+
+
+
+````````````````````````````````
+
+Issue #289.
+
+```````````````````````````````` example
+[a](
+.
+[a](<b) c>
+````````````````````````````````
+
+Issue #161.
+
+```````````````````````````````` example
+*failed to be italic!*\
+text
+.
+failed to be italic!
+text
+````````````````````````````````
+
+
diff --git a/commonmark-test-util/src/main/resources/spec.txt b/commonmark-test-util/src/main/resources/spec.txt
index 9fd584139..3913de442 100644
--- a/commonmark-test-util/src/main/resources/spec.txt
+++ b/commonmark-test-util/src/main/resources/spec.txt
@@ -1,8 +1,8 @@
---
title: CommonMark Spec
author: John MacFarlane
-version: 0.28
-date: '2017-08-01'
+version: 0.29
+date: '2019-04-06'
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
...
@@ -248,7 +248,7 @@ satisfactory replacement for a spec.
Because there is no unambiguous spec, implementations have diverged
considerably. As a result, users are often surprised to find that
-a document that renders one way on one system (say, a github wiki)
+a document that renders one way on one system (say, a GitHub wiki)
renders differently on another (say, converting to docbook using
pandoc). To make matters worse, because nothing in Markdown counts
as a "syntax error," the divergence often isn't discovered right away.
@@ -328,8 +328,10 @@ that is not a [whitespace character].
An [ASCII punctuation character](@)
is `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`,
-`*`, `+`, `,`, `-`, `.`, `/`, `:`, `;`, `<`, `=`, `>`, `?`, `@`,
-`[`, `\`, `]`, `^`, `_`, `` ` ``, `{`, `|`, `}`, or `~`.
+`*`, `+`, `,`, `-`, `.`, `/` (U+0021–2F),
+`:`, `;`, `<`, `=`, `>`, `?`, `@` (U+003A–0040),
+`[`, `\`, `]`, `^`, `_`, `` ` `` (U+005B–0060),
+`{`, `|`, `}`, or `~` (U+007B–007E).
A [punctuation character](@) is an [ASCII
punctuation character] or anything in
@@ -514,8 +516,8 @@ one block element does not affect the inline parsing of any other.
## Container blocks and leaf blocks
We can divide blocks into two types:
-[container block](@)s,
-which can contain other blocks, and [leaf block](@)s,
+[container blocks](@),
+which can contain other blocks, and [leaf blocks](@),
which cannot.
# Leaf blocks
@@ -527,7 +529,7 @@ Markdown document.
A line consisting of 0-3 spaces of indentation, followed by a sequence
of three or more matching `-`, `_`, or `*` characters, each followed
-optionally by any number of spaces, forms a
+optionally by any number of spaces or tabs, forms a
[thematic break](@).
```````````````````````````````` example
@@ -825,7 +827,7 @@ Contents are parsed as inlines:
````````````````````````````````
-Leading and trailing blanks are ignored in parsing inline content:
+Leading and trailing [whitespace] is ignored in parsing inline content:
```````````````````````````````` example
# foo
@@ -1024,6 +1026,20 @@ baz*
baz
````````````````````````````````
+The contents are the result of parsing the headings's raw
+content as inlines. The heading's raw content is formed by
+concatenating the lines and removing initial and final
+[whitespace].
+
+```````````````````````````````` example
+ Foo *bar
+baz*→
+====
+.
+Foo bar
+baz
+````````````````````````````````
+
The underlining can be any length:
@@ -1584,8 +1600,8 @@ begins with a code fence, indented no more than three spaces.
The line with the opening code fence may optionally contain some text
following the code fence; this is trimmed of leading and trailing
-spaces and called the [info string](@).
-The [info string] may not contain any backtick
+whitespace and called the [info string](@). If the [info string] comes
+after a backtick fence, it may not contain any backtick
characters. (The reason for this restriction is that otherwise
some inline code would be incorrectly interpreted as the
beginning of a fenced code block.)
@@ -1870,7 +1886,7 @@ Code fences (opening and closing) cannot contain internal spaces:
``` ```
aaa
.
-
+
aaa
````````````````````````````````
@@ -1922,9 +1938,11 @@ bar
An [info string] can be provided after the opening code fence.
-Opening and closing spaces will be stripped, and the first word, prefixed
-with `language-`, is used as the value for the `class` attribute of the
-`code` element within the enclosing `pre` element.
+Although this spec doesn't mandate any particular treatment of
+the info string, the first word is typically used to specify
+the language of the code block. In HTML output, the language is
+normally indicated by adding a class to the `code` element consisting
+of `language-` followed by the language name.
```````````````````````````````` example
```ruby
@@ -1973,6 +1991,18 @@ foo
````````````````````````````````
+[Info strings] for tilde code blocks can contain backticks and tildes:
+
+```````````````````````````````` example
+~~~ aa ``` ~~~
+foo
+~~~
+.
+foo
+
+````````````````````````````````
+
+
Closing code fences cannot have [info strings]:
```````````````````````````````` example
@@ -1991,14 +2021,15 @@ Closing code fences cannot have [info strings]:
An [HTML block](@) is a group of lines that is treated
as raw HTML (and will not be escaped in HTML output).
-There are seven kinds of [HTML block], which can be defined
-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
-[end condition]. If the first line meets both the [start condition]
-and the [end condition], the block will contain just that line.
+There are seven kinds of [HTML block], which can be defined 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 the last line of
+the [container block](#container-blocks) containing the current HTML
+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.
1. **Start condition:** line begins with the string `