Commit Graph

574 Commits

Author SHA1 Message Date
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
Vytautas Šaltenis
8e90e8b645 Remove calls to Truncate() from linebreak parser
Replace output truncation with appropriate inline callbacks. lineBreak()
is now only responsible for handling HardLineBreak. BackslashLineBreak
is handled in escape() and trailing whitespace is considered in
maybeLineBreak().
2015-11-10 21:36:31 +02:00
Vytautas Šaltenis
ef087889f4 Remove a couple calls to Truncate() from parser
Link parser used to truncate in two cases: when parsing image links and
inline footnotes. In order to avoid this truncation, introduce a
separate callback for each of these cases and avoid writing extra
characters instead of truncating them after the fact.
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
Vytautas Šaltenis
6d6be3d2b2 Remove callback from Paragraph renderer event
Split Paragraph into two events: BeginParagraph and EndParagraph,
removing the need for callback.
2015-11-10 21:08:32 +02:00
Vytautas Šaltenis
af1b26fa04 Remove callback from List renderer event
Split List into two events: BeginList and EndList, removing the need for
callback.
2015-11-10 21:08:32 +02:00
Vytautas Šaltenis
82be6cab6d Remove callback from Header renderer event
Split Header into two events: BeginHeader and EndHeader, removing the
need for callback.
2015-11-10 21:08:32 +02:00
Vytautas Šaltenis
b16c9b3787 Simplify callbacks in Renderer interface
The callbacks used to return bools, but none of the actual
implementations return false, always true. So in order to make further
refactorings simpler, make the interface reflect the inner workings: no
more return values, no more conditionals.
2015-11-10 21:08:32 +02:00
Vytautas Šaltenis
ee98bc0bf4 Massive replacement of C_STYLE flags to typed ones 2015-11-10 21:08:32 +02:00
Vytautas Šaltenis
06515e9125 Rename public constants to idiomatic Go 2015-11-10 20:27:34 +02:00
Dmitri Shuralyov
0b647d0506 Use more idiomatic form for set of strings.
This is a better style for a set, since each value can only be present
or absent.

With bool as value type, each value may be absent, or true or false. It
also uses slightly more memory.
2015-11-09 21:18:55 -08:00
Vytautas Šaltenis
18432fc942 Add a few missing HTML5 block tags
Closes #197.
2015-11-08 21:34:44 +02:00
Vytautas Šaltenis
f1ce82cb01 Sort block tag list alphabetically 2015-11-08 21:33:20 +02:00
Vytautas Šaltenis
510be64de0 Merge pull request #216 from russross/issue-194
Fix footnote following an exclamation point
2015-11-04 21:40:57 +02:00
Vytautas Šaltenis
f21f067121 Merge pull request #215 from russross/issue-193
Fix nested footnotes
2015-11-04 21:37:52 +02:00
Vytautas Šaltenis
c5943e0685 Reformat a dustball of ifs into a switch statement 2015-11-04 21:32:53 +02:00
Vytautas Šaltenis
a58274acef Minor style fix: declare ref first in a loop 2015-11-04 21:07:39 +02:00
Vytautas Šaltenis
ca8c21a297 Fix footnote following an exclamation point
Link parser interpreted the sequence "![^foo]" as an image, but if
footnote extension is enabled, it's quite clear that it should be
interpreted as a footnote following something with an exclamation point
at the end.

Closes #194.
2015-11-03 20:52:36 +02:00
Vytautas Šaltenis
c29209fcda Add String() method to reference struct 2015-11-02 20:24:34 +02:00
Vytautas Šaltenis
9e68ff937b Fix nested footnotes
This is both nasty and neat at the same time. All the code could handle
nested footnotes just fine, the only place that was not working was the
final loop that printed the list. The loop was in a range form, which
couldn't account for another footnote being inserted while processing
existing ones. Changing the loop to the iterative form solves that.

Closes #193.
2015-11-02 20:17:46 +02:00
Vytautas Šaltenis
660c9fd283 Add <style> tag to a list of recognized block tags
Closes #182.
2015-11-01 12:36:02 +02:00
Vytautas Šaltenis
9c9c590f7e Merge pull request #211 from russross/issue-122
Fix issue 122: fenced code blocks inside blockquotes
2015-11-01 09:44:04 +02:00
Vytautas Šaltenis
4193e8665a Drop misleading comment and turn func into method
* The comment is no longer true.
* Other functions similar to terminateBlockquote() are methods, so make
this one a method too.
2015-11-01 09:32:30 +02:00
Vytautas Šaltenis
6c330778b2 Merge pull request #214 from russross/issue-122-test-readability
Make test values more readable, add additional test cases.
2015-11-01 09:25:47 +02:00
Dmitri Shuralyov
e93d8f1624 Make test values more readable, add additional test cases. 2015-10-31 14:35:21 -07:00
Vytautas Šaltenis
ceb8293c34 Merge pull request #212 from nitoyon/readme
README: Add 'Definition lists' and 'Footnotes'
2015-10-30 20:37:43 +02:00
nitoyon
6a7bd0d6e9 README: Add 'Definition lists' and 'Footnotes' 2015-10-31 00:50:10 +09:00
Vytautas Šaltenis
15eb452ae4 Fix fenced code processing inside blockquotes
Add a call to fenced code block processor inside the loop that's
responsible for collecting the quoted lines. Grok all the fenced code
block as a part of the quoted text.

Closes #122.
2015-10-29 20:28:29 +02:00
Vytautas Šaltenis
607f2ceb8a Move complex conditional to a helper func 2015-10-29 20:28:29 +02:00
Vytautas Šaltenis
133788657b Refix fenced code blocks w/o preceding blank lines
Change approach at fixing #45: don't patch input markdown at preprocess
pass, instead improve special case detection when parsing paragraphs.

Leave the fenced code block detection in the preprocess pass though,
it's been put to another use since then, to suppress tab expansion
inside code blocks.
2015-10-29 20:28:16 +02:00
Vytautas Šaltenis
d4ee3ea08b Simplify return value 2015-10-28 21:21:51 +02:00
Vytautas Šaltenis
4b26653fe0 Fix broken test and add test for HTML_SMARTYPANTS_DASHES 2015-10-27 20:21:08 +02:00
Vytautas Šaltenis
6712f32cfd Merge pull request #190 from anthonyfok/add-flag-for-smart-dashes
Add HTML_SMARTYPANTS_DASHES for toggling smart dashes
2015-10-27 20:08:54 +02:00
Vytautas Šaltenis
a18a46c9b9 Merge pull request #203 from russross/issue-136
Handle comments within a block
2015-10-20 20:45:00 +03:00
Vytautas Šaltenis
c9f5708bd5 Spread out test cases for readability 2015-10-20 20:31:08 +03:00
Vytautas Šaltenis
53982c119c Merge pull request #206 from russross/issue-164
Fix footnote followed by a reference style link
2015-10-19 09:17:51 +03:00
Vytautas Šaltenis
4b668b875b Merge pull request #205 from russross/issue-156
Fix bug parsing emphasis
2015-10-19 09:08:30 +03:00