- When parsing starting markers, consider the rest of the line to be in a new
paragraph after one marker is parsed.
- FmtCodec: Escape info string in fenced code blocks.
- FmtCodec: Use "_" as emphasis marker also after end of emphasis or strong emphasis.
- Avoid reformatting "- - *" as "- - -"; the former is a 3-level list with no
content, the latter is a thematic break.
- Escape "~~~" at the start of line.
- When handling escapes inside ATX headings, use "i == 0" as a condition for
start of line, since we are actually not at the literal start of line after
writing the heading starter.
- Fix the definition of Unicode punctuations to be consistent with the spec.
- Only escape "!" when followed by a link.
- Only escape "#" when it is either at the start of line in a paragraph and
introduce an ATX heading, or is at the end of the line in an ATX heading and
can be parsed as the optional ATX heading closer.
- Escape "-" and "+" if and only if they can introduce a bullet list.
- Escape "." and ")" if and only if they come after a number and can introduce
an ordered list.
- Escape ">" when it can introduce blockquote.
- Escape spaces and tabs at start and end of line.
This avoids a dependency on the html package, which has a huge entity table.
The pkg/md package is not used by Elvish now, but its impact on the binary size
can be measured by exposing md.Render as a builtin function.
- With the dependency on the html package, Elvish's binary size would increase by
206KiB.
- Without the dependency, the binary size would only increase by 125KiB.
- Use a Codec interface to specify output format.
This gives more control over how output is built, and will make it possible to
build a terminal renderer.
- Refactor block tree logic into its own type.
- Handle the opening and closing of list containers in one place.
- Use lookahead to implement the rule allowing only one blank line to start a
list item.
- Remove handling for non-\n line endings.
This is required by the spec, but there is no test for it. It was also not
handled consistently before; if there is a need, it is easier to just
normalize the line ending at the very beginning rather than handling it
everywhere.
Entities in link destination and title need to be handled as part of the parsing
procedure, instead of after it. The spec doesn't have test cases for this, so
added new supplemental test cases.
Entity support in autolinks also don't have test cases in the spec, so add a
supplemental test case too.
Indented code blocks and link reference definitions are used a lot in other
sections, and they used to be skipped by matching the markdown with regexp
patterns. However, this has some false positives, so list the individual example
IDs instead.