Commit Graph

411 Commits

Author SHA1 Message Date
Vytautas Šaltenis 0c7120d6dc Fix old omission in doTestsBlockWithRunner
It calls the provided runner in the -short run, but the standard runner
in the complete run. Fix that.
2016-04-04 12:09:36 +03:00
Vytautas Šaltenis a658caacc6 Use TestParams in block tests
The different testing function interfaces get unified a bit closer,
runnerWithRendererParameters completely eliminated.
2016-04-04 12:04:20 +03:00
Vytautas Šaltenis b069de6276 Wrap inline test parameters in a struct
Take advantage of zero value initialization.
2016-04-04 12:04:20 +03:00
Vytautas Šaltenis 15e052e478 Move all testing helper funcs in one place
Moved verbatim except for uncommented panic recovery section in the
doTestsInlineParam function.
2016-04-04 12:04:20 +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 04673c9f28 Improve documentation for Node struct 2016-04-01 12:33:05 +03:00
Vytautas Šaltenis 8a4d4fa0cd Move Header-related fields to a nested struct 2016-04-01 11:48:52 +03:00
Vytautas Šaltenis bcd5b5b780 Move table cell fields to a nested struct 2016-04-01 11:46:09 +03:00
Vytautas Šaltenis 4ba991937b Store cell alignment in own type instead of int 2016-04-01 11:44:59 +03:00
Vytautas Šaltenis 67f85cf540 Move code block fields to a nested struct 2016-04-01 11:29:15 +03:00
Vytautas Šaltenis c8eb73377e Fix typos 2016-04-01 11:22:13 +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 4c11a2a62d Expose Parse func that grabs input and returns AST 2016-03-30 19:40:10 +03:00
Vytautas Šaltenis c1011c8ab2 Remove unneeded reference to Renderer from parser 2016-03-30 19:35:53 +03:00
Vytautas Šaltenis 4d74c6a071 Make common flags and extensions public
Add DefaultOptions convenience variable.
2016-03-30 19:29:00 +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 6fe811b603 Fix TitleBlock test
It seems like the implementation of the extension was rather sloppy and
didn't adhere to the style common to the rest of Blackfriday.
2016-03-30 15:05:24 +03:00
Vytautas Šaltenis a32ecdb83d Fix footnote tests
This commit does some changes to the test suite. The changes are only to
the newlines. Turns out the former implementation of footnotes produced
slightly different spacing when rendering the footnotes list. The new
implementation produces the list that is compatible with the rest of the
package.
2016-03-30 15:03:11 +03:00
Vytautas Šaltenis 70124f1ea3 Enable full AST construction, use the new renderer
Connect the block and inline parsers. Most of the tests now pass, only a
couple fail, they need fixes in the test suite.
2016-03-30 14:47:30 +03:00
Vytautas Šaltenis eb70b23221 Construct AST WIP: add inline-level nodes
Parse the content of the block nodes for inline markdown, decorate the
tree with what's found. Tests still broken, need to connect the dots.
2016-03-30 14:38:19 +03:00
Vytautas Šaltenis 7c95b7a189 Construct AST WIP: add block-level nodes
Build a partial tree by adding block nodes. The block nodes will then be
traversed and inline markdown parsed inside each of them. Tests are
broken at this point until the full tree is constructed.
2016-03-30 12:57:12 +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 2bbed304fb Add AST data structures
The main Node structure that holds every AST node and some supplementary
substructs. A bit of helper code to handle the nodes.
2016-03-30 12:54:12 +03:00
Vytautas Šaltenis f8378658c0 Fix rendering of tables
Add proper capture groups to fix the order of bits and pieces.
2015-11-10 21:36:32 +02: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 114d6b0d68 Eradicate 'out' parameter in top level code 2015-11-10 21:36:32 +02:00
Vytautas Šaltenis 0dfcd3beb5 Remove all uses of 'out' in Latex renderer 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 91771dc3ef Redirect output to a capture buffer where necessary
Use CaptureWrites where output should go to a temp buffer instead of the
final output.
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 7ec50399c3 Remove 'out' parameter from parser funcs
This only removes the parameter from declarations, everything is broken
at the moment.
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 a78344809b Fix smartypants smart dash processing
Change the way maybeLineBreak gets called to avoid breaking up stretches
of unprocessed characters that smartypants expects.

This inline processing is getting a bit out of hand, something needs to
be done about it.
2015-11-10 21:36:31 +02:00
Vytautas Šaltenis dd01088b7a Remove last call to Truncate() from parser
Autolink detection used to be triggered by a colon and preceding
protocol name used to be rewound. Now instead of doing that, trigger
autolink processing on [hmfHMF] and see if it looks like a link.
2015-11-10 21:36:31 +02:00