Commit Graph

143 Commits

Author SHA1 Message Date
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
Vytautas Šaltenis
7846a310ea Remove unused code 2016-03-30 12:54:12 +03:00
Vytautas Šaltenis
d1b544e278 HACK: render TOC the old way, backup and truncate output 2015-11-10 21:36:32 +02:00
Vytautas Šaltenis
97235182ac Enable writing plain text straight to output
It's only used in a single place and should probably be refactored away,
but this workaround is OK for now.
2015-11-10 21:36:32 +02:00
Vytautas Šaltenis
7a97ffe689 Remove almost all uses of 'out' in HTML renderer 2015-11-10 21:36:32 +02:00
Vytautas Šaltenis
08233481ed Fix Begin/EndHeader to use the new 'out'-less interface
Remove the 'out' parameter. Also, instead of returning and passing the
position of TOC, use CopyWrites to capture contents of the header and
pass that captured buffer instead.
2015-11-10 21:36:32 +02:00
Vytautas Šaltenis
dce6df90b9 Add infrastructure to collect output in a buffer
Add a structure to collect output in a buffer (replaces what used to be
the 'out' parameter all over the place).

Notable things about this struct are the captureBuff and copyBuff
buffers. They're intended to redirect all the output (captureBuff) or
make a copy of all the output (copyBuff) while they're set to non-nil.
Here's an example of their intended use:

    // what used to be a temp buffer as an 'out' parameter
    //     var cellWork bytes.Buffer
    //     p.inline(&cellWork, data[cellStart:cellEnd])
    // can now be captured like this:
    cellWork := p.r.CaptureWrites(func() {
           p.inline(data[cellStart:cellEnd])
    })
2015-11-10 21:36:32 +02:00
Vytautas Šaltenis
352ffdefa4 Remove a bunch of 'out' parameters from calls, WIP
Still not all of them, still broken.
2015-11-10 21:36:32 +02:00
Vytautas Šaltenis
6e42506fcc Remove 'out' parameter from renderer interface
This only removes the parameter from func declarations, not from their
bodies, so obviously breaks everything. Will be restored in upcoming
commits.
2015-11-10 21:36:31 +02:00
Vytautas Šaltenis
29f02f7d01 Rename Renderer method receivers
From 'options' to 'r'. This change contains only a massive rename, no
other changes.
2015-11-10 21:08:32 +02:00
Vytautas Šaltenis
bc4735b84d Remove callback from Footnotes renderer event
Split Footnotes into two events: BeginFootnotes and EndFootnotes,
removing the need for callback.
2015-11-10 21:08:32 +02:00