Using strings in helper functions causes a lot of string-to-[]byte
allocations. This fix is centered around converging the tag() helper
func to the []byte lingo. In order to do that, a lot of string literals
have moved to global variables, where string to []byte conversion can
happen once.
Clean up footnotes part of an AST: don't force HTML-specific pieces
there, just keep a clean list of footnotes. Since some renderers might
want to process footnotes differently, let them know about footnotes by
having a flag on that list.
Move reference and footnote extraction code from firstPass to a
paragraph block parser. This makes firstPass a little bit slimmer, ergo
closer to elimination.
When parseRefsToAST constructs a list of footnotes, it hardcoded the
item flags to ListTypeOrdered and omitted ListItemBeginningOfList.
However, a quick look around indicates that ListItemBeginningOfList
might have lost its meaning altogether in v2 (it used to control item
spacing in v1, which is now extracted from the AST structure). So add a
TODO to clean that up one day.
Most of its body was redundant, as it was moved to parseRefsToAST. After
removal of that code, only a single line remains, so move it out to the
caller of secondPass.
* Only split when inline callbacks consume some bytes
The former hacks around maybeLineBreak and Smartypants are no longer
needed.
The algorithm has been streamlined: shorter, simpler, faster.
The 'currBlock' field of the parser is gone.
* Remove spurious logs
When passed a non-container root node, or when the visitor whould return
SkipChildren for the root node, the former algorithm would go on walking
down the rest of the tree beyond the root.
This commit also removes unneeded functions and variables.
* Unpublish and rename LinkType constants
The constants are only used in the parsing phase, they are not recorded
in the AST directly, so make them private. Improve their names along the
way. Fix tagLength to return two values instead of taking an output
parameter.
* autoLinkType -> autolinkType
And remove unnecessary comment.