Vytautas Šaltenis
c60ee1aab0
Avoid allocating []byte for every written newline
...
This shaves off another ~25% of allocs.
2016-10-08 18:17:00 +03:00
Vytautas Šaltenis
993325d13f
Roll our own implementation of HTML escaper
2016-09-10 14:33:37 +03:00
Vytautas Šaltenis
31f2685bfe
Remove lots of string literals
...
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.
2016-09-10 13:17:42 +03:00
Vytautas Šaltenis
6947216efb
Move footnote rendering to the renderer
...
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.
2016-09-03 12:39:16 +03:00
Pierre Neidhardt
225250ddf1
html.go: Lint RenderNode()
2016-08-12 09:16:14 +05:30
Pierre Neidhardt
02da1dfe9d
Factor Smartypants to HTML
...
Smartypants is HTML-specific.
There is no need to run Smartypants from `Render()`.
This simplifies extensions built upon the HTML renderer.
2016-08-10 09:58:33 +05:30
Vytautas Šaltenis
37141d5b5a
Merge pull request #296 from Ambrevar/v2icon
...
v2: Add Icon parameter to the HTML renderer
2016-08-09 22:22:31 +03:00
Pierre Neidhardt
413328d30b
Add Icon parameter to the HTML renderer
2016-08-09 17:54:34 +05:30
Pierre Neidhardt
b5ff8e0286
Break lines properly in TOC generation and omit content if required
2016-08-09 15:11:40 +05:30
Pierre Neidhardt
4d756003cd
Move TOC generation to the HTML Renderer
2016-08-09 12:37:44 +05:30
Vytautas Šaltenis
e054c962e7
More lint: markdown.go and ripples to other files
2016-07-27 21:28:41 +03:00
Vytautas Šaltenis
f7ec3b0e34
Fix a few lint errors, a.k.a. improve docs
2016-07-27 10:11:13 +03:00
Vytautas Šaltenis
89653c9927
Merge pull request #274 from Ambrevar/v2misc
...
v2: Implicit interface and Stringer
2016-07-27 09:39:58 +03:00
Vytautas Šaltenis
6291a00f2f
Remove dead fields from HTMLRenderer
2016-07-05 07:33:21 +03:00
Vytautas Šaltenis
cb6bd67271
Remove dead HTMLWriter code
2016-07-04 22:02:22 +03:00
Vytautas Šaltenis
f90a576a05
Untangle some mess with attribute escaping
...
1. Remove unused preserveEntities parameters
2. Move attrEscape() implementation inside esc()
3. Delegate most of esc() work to escCode()
2016-07-02 10:45:06 +03:00
Pierre Neidhardt
20aa621387
Fix empty path to CSS
2016-07-01 18:18:51 +02:00
Pierre Neidhardt
2e53c20b2f
Return a *HTMLRenderer from NewHTMLRenderer
...
Interfaces should be satisfied implicitly.
2016-07-01 17:23:30 +02:00
Vytautas Šaltenis
3575453f08
Move a couple helpers to parser where they're used
2016-04-11 15:55:50 +03:00
Vytautas Šaltenis
76d8c71d70
Unduplicate attrEscape funcs
2016-04-11 15:55:50 +03:00
Vytautas Šaltenis
e95d23065a
Rename HTML to HTMLRenderer
2016-04-11 11:45:40 +03:00
Vytautas Šaltenis
c26fdef40e
Move html entity regexp to where it's used
...
And unify regexp variable names.
2016-04-11 11:45:19 +03:00
Vytautas Šaltenis
c207eca993
Clean up Renderer interface: remove all callbacks
...
We now expose the structure of the document in the form of AST, there's
no longer need to have all those callbacks to represent structure.
2016-04-11 11:22:38 +03:00
Vytautas Šaltenis
98ddf98997
Get rid of unneeded method in Renderer
2016-04-11 11:12:41 +03:00
Vytautas Šaltenis
24e146a727
Make HTMLRendererParameters a substruct of HTML
2016-04-05 14:44:14 +03:00
Vytautas Šaltenis
9f5de868aa
Go style: take advantage of zero value init
2016-04-05 14:34:30 +03:00
Vytautas Šaltenis
1303ea1427
Cleanup renderer constructors
...
Move all parameters under HTMLRendererParameters struct, rename
constructors to New{HTML|Latex}Renderer.
2016-04-05 14:24:27 +03:00
Vytautas Šaltenis
4f8d2881a2
Remove a bit of cruft from HTML renderer
2016-04-05 13:54:57 +03:00
Vytautas Šaltenis
83b4cb6062
Implement SkipHTML, add test
2016-04-05 12:48:29 +03:00
Vytautas Šaltenis
7e9a57463f
Implement SkipStyle, add test
...
Fix a bug in findHtmlTagPos introduced with e02c392d
.
2016-04-05 12:48:28 +03:00
Vytautas Šaltenis
fecfec2059
Implement SkipImages and add test
2016-04-05 12:48:28 +03:00
Vytautas Šaltenis
9da90c5929
Allow NodeVisitor to have some control over traversal
...
Make NodeVisitor return status and decide upon it which node to go to
next. So far, this allows to skip subtrees and quit early.
2016-04-05 12:48:28 +03:00
Vytautas Šaltenis
607478a8ce
Implement SkipLinks, add test
2016-04-04 14:08:35 +03:00
Vytautas Šaltenis
d7f18785f1
Implement TOC and OmitContents
...
Move these two flags from HTML renderer's flags to extensions. Implement
both since they were not yet implemented in the AST rewrite. Add tests.
Note: the expected test strings differ very slightly from v1. The HTML
produced by v2 has a few extra newlines compared to the old one, but
it's now uniform with other sections of the generated document. If the
newline placement gets cleaned up in the future, this will get fixed
automatically, since the renderer is agnostic about the TOC list.
2016-04-04 12:04:20 +03:00
Vytautas Šaltenis
0b69796248
Go style: more Html -> HTML renames
2016-04-01 15:37:21 +03:00
Vytautas Šaltenis
02a5ce37ff
Go style: Html{Block|Span} -> HTML{Block|Span}
2016-04-01 13:15:47 +03:00
Vytautas Šaltenis
32802dbae5
Go style: rename Toc to TOC
2016-04-01 13:12:38 +03:00
Vytautas Šaltenis
f1361aa0da
Make ForEachNode func a Walk method on Node
2016-04-01 12:36:56 +03:00
Vytautas Šaltenis
4ba991937b
Store cell alignment in own type instead of int
2016-04-01 11:44:59 +03:00
Vytautas Šaltenis
60026cc3c6
Make ListData a nested struct instead of pointer
2016-04-01 11:21:25 +03:00
Vytautas Šaltenis
2a07386455
Rename HtmlFlags to HTMLFlags to adhere to Go style
2016-04-01 10:49:23 +03:00
Vytautas Šaltenis
71fe9a191e
Remove dead code
2016-04-01 10:48:25 +03:00
Vytautas Šaltenis
a55b2615a4
Run Smartypants as a separate pass over the AST
...
Separate Smartypants somewhat from the HTML renderer. Move its flags
from HtmlFlags to Extensions (probably should be moved to its own set of
flags, but not now). With that done, do a separate walk of the tree and
either run Smartypants processor if it's enabled, or simply escape text
nodes.
2016-04-01 10:44:22 +03:00
Vytautas Šaltenis
7869a127bd
Combine two Smartypants structs into one
...
Combine smartypantsRenderer and smartypantsData into one struct. Make
action funcs methods on that struct.
2016-03-31 21:40:37 +03:00
Vytautas Šaltenis
4a7ff562a7
Rename Html to HTML to adhere to Go style
2016-03-31 13:54:09 +03:00
Vytautas Šaltenis
fd2d69de5e
Make renderer write to an explicit io.Writer
2016-03-30 21:13:02 +03:00
Vytautas Šaltenis
dc7d4b68df
Remove some cruft
2016-03-30 15:56:53 +03:00
Vytautas Šaltenis
0382dab0c3
The single node renderer is a separate func now
...
A default HTML renderer for a single node is now easily accessible.
Makes it easy to fall back to the default behavior when writing custom
HTML renderers.
2016-03-30 15:48:43 +03:00
Vytautas Šaltenis
886a1405c0
Extract local funcs/vars into methods/members
2016-03-30 15:37:03 +03:00
Vytautas Šaltenis
94893247d1
Add a new renderer from AST
...
This is the new renderer that walks AST and renders everything to a
buffer. Completely covers all the functionality of the previous renderer
and will likely replace it.
2016-03-30 12:54:12 +03:00