Unexport a bunch of constants private to HTML renderer
They were cluttering the documentation and are not useful otherwise.
Rearrange constants in descending dependencies order
Improve Renderer to be less confusing. Fix documentation for it.
OmitContents flag got dropped along the way. First, it would fit poorly
into the new design and second, it's unclear how widely this feature is
used. But most importantly, it's trivial to roll your own with the v2
API: https://gist.github.com/rtfb/2693f6bfcc1760661e8d2fb832763a15Fixes#368.
The check was introduced with d28de22, when fixing #172 and #173.
Then I removed it with bcd6dd8 when fixing #180
And then it was reintroduced with 232d06c when fixing regression.
It seems that the check can be removed again. All these cases now have
tests (including the one from 69f51af, which seems to have landed to v1
only, copying it here) and they all pass.
The root problem this commit fixes is the duplication of Extensions
field in HTMLRendererParameters. The duplication crept in there only to
support these two flags, so moving the flags solves the problem. They're
only used in renderer anyway.
Fixes#277.
* Move handler call inside the inner loop's 'if handler != nil' clause
* Move appender of possible tail bytes outside of loop
* Get rid of outer loop
* Rename i -> beg
Again, this does not seem to gain much performance, but makes the code
significantly more readable.
Rearrange inline parser a little bit to check less conditionals for
every byte.
* Add early check for len(data) == 0
* Move 'for i < len(data)' check inside the (rarer) positive clause of
trigger result handling
* A check for newline turned out to be redundant
* Look up p.inlineCallback only once
All that does not gain much performance in itself, but doesn't hurt and
makes the code structure simpler, which will hopefully allow further
streamlining.
Simplify and optimize escapeHTML as per @Ambrevar's suggestion: lean on
the fact that we're dealing with bytes: declare a 256-element array with
most of it filled with zeros, except for the few slots that need
escaping. This avoids some conditionals in a tight loop.
Also, uncomment it's benchmark.
When passed a non-container root node, the former algorithm would go on
walking down the rest of the tree beyond the root.
The former walk fix was supposed to do that but somehow the code
disappeared in the process.
Some renderers might not care to have an explicit list of footnotes at
the end of the document, instead they're interested in the content of
the footnote at the location of a referer. Make their lives easier by
providing such a link
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.