605 Commits

Author SHA1 Message Date
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
b43df972fb Merge pull request #247 from shawnps/patch-1
fix typo
2016-03-16 09:29:03 +02:00
Shawn Smith
1d94959fea fix typo 2016-03-16 15:21:50 +09:00
Vytautas Šaltenis
006144af03 Merge pull request #234 from shawnps/gofmt
gofmt -s
2016-01-24 13:12:56 +02:00
shawnps
2ee51ae2a0 gofmt -s 2016-01-22 16:04:49 -08:00
Vytautas Šaltenis
c8875c0ed4 Merge pull request #229 from russross/issue-228
Fix bug with gathering list item lines
2015-12-30 17:42:28 +02:00
Vytautas Šaltenis
fc6236fc55 Fix bug with gathering list item lines
Instead of swallowing an empty line and then reintroducing it back again
in certain cases, collect the list item body in an unaltered form and
let the recursive parsing call sort things out.

Fixes issue #228.
2015-12-26 20:18:22 +02:00
Vytautas Šaltenis
b8031576aa Merge pull request #225 from russross/issue-165
Implement support for CDATA section
2015-12-25 13:14:44 +02:00
Vytautas Šaltenis
ee63ffd3e2 Fix initialisms in function names 2015-12-25 13:04:56 +02:00
Vytautas Šaltenis
f5ac2ddf7a Add a few more CDATA tests 2015-12-16 20:53:40 +02:00
Vytautas Šaltenis
594d923645 Convert constant variables into consts 2015-12-16 20:51:44 +02:00
Vytautas Šaltenis
05a79218ed Implement support for CDATA section
Fixes #165.
2015-12-14 20:57:40 +02:00
Vytautas Šaltenis
d18b67ae0a Add more tests for emphasised text
Including EXTENSION_NO_INTRA_EMPHASIS. These nail down a fix for #178
that was a side effect of cc3cc10.
2015-12-12 19:18:59 +02:00
Vytautas Šaltenis
3c4a488ada Merge pull request #224 from russross/issue-180
Fix for #180
2015-12-11 20:25:12 +02:00
Vytautas Šaltenis
fc740701cf Cosmetics: fix comment placement and import order 2015-12-10 21:03:21 +02:00
Vytautas Šaltenis
bcd6dd8711 Don't require the input to end with a newline
Technically, not ending a line with a newline is wrong, but this blunder
is so pervasive that we have no other choice but to live with it.

Fixes #180.
2015-12-10 20:52:47 +02:00
Vytautas Šaltenis
e3cbadc5c9 Bump version 2015-12-06 19:26:14 +02:00
Vytautas Šaltenis
ce3ffa70a0 Merge pull request #222 from icco/parens
Allow parentheses inside of links
2015-12-06 18:44:17 +02:00
Nat Welch
1bb1fa9e95 remove check that brace is > 0 2015-12-05 02:00:36 +00:00
Nat Welch
c1d4a77100 Fix comment formatting and spelling 2015-12-05 02:00:23 +00:00
Nat Welch
45f5800b75 Get tests to pass 2015-11-29 00:08:48 +00:00
Nat Welch
1622f8f312 Apply @miekg's patch
From 99ce7134f6.patch
2015-11-26 22:11:25 +00:00
Vytautas Šaltenis
300106c228 Merge pull request #219 from FooSoft/master
Adding a link to Md2Vim.
2015-11-17 09:23:12 +02:00
Alex Yatskov
7d22880556 Adding a link to Md2Vim. 2015-11-17 12:58:23 +09: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
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