Commit Graph

101 Commits

Author SHA1 Message Date
Krzysztof Kowalczyk 8bb670d63d rename Markdown to Parser 2018-01-25 23:16:34 -08:00
Krzysztof Kowalczyk 26da860b55 switch to using interface{} for node data 2018-01-25 22:44:27 -08:00
Krzysztof Kowalczyk 904c88f346 tweak comments; add todo.md 2018-01-25 15:08:57 -08:00
Krzysztof Kowalczyk 49a9386a12 make it stand-alone by folding https://github.com/shurcooL/sanitized_anchor_name 2018-01-25 13:09:33 -08:00
Krzysztof Kowalczyk 78bcb2da26 update links 2018-01-25 13:06:17 -08:00
Krzysztof Kowalczyk 7557d13318 change package name 2018-01-25 13:01:19 -08:00
Pierre Neidhardt 2501229ba6 Rename Markdown()->Run() and Processor->Markdown 2017-06-05 21:42:05 +01:00
Pierre Neidhardt 3cc9341a19 Merge Parser into Processor 2017-05-29 10:52:11 +02:00
Vytautas Šaltenis 41159b3874 Fix bad merge 2017-02-14 21:58:46 +02:00
Vytautas Šaltenis a8c45a7349 Merge branch 'v2' into v2-functional-opts 2017-02-14 21:51:06 +02:00
Vytautas Šaltenis 747587a52d Fix all headings wrongly referred to as headers
I've left test cases alone since can't lean on the compiler for
crosschecking there.

Fixes #330.
2017-02-12 19:05:30 +02:00
Vytautas Šaltenis e81d1d1138 Change the public interface to use functional options
Convert the most important Blackfriday's function, Markdown(), to accept
functional options (as per this Dave Cheney's post:
https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis)
2017-02-02 16:57:25 +02:00
Vytautas Šaltenis ea57e93666 Several fixes after code review 2017-02-02 11:54:10 +02:00
Vytautas Šaltenis 120bb2fae1 Get rid of the preprocess stage
Yay!!
2016-11-10 21:49:58 +02:00
Vytautas Šaltenis d9ffdb7464 Use bytes.IndexByte to skip til EOL 2016-09-10 15:24:45 +03:00
Vytautas Šaltenis e0fc1a0cb1 Don't bother removing trailing newlines in code blocks
The code that collects the block bytes has already removed the trialing
newlines, so this heavyweight regexp machinery is actually doing
nothing.
2016-09-10 12:21:53 +03:00
Vytautas Šaltenis ea8dfc4880 Move reference extraction to paragraph parser
Move reference and footnote extraction code from firstPass to a
paragraph block parser. This makes firstPass a little bit slimmer, ergo
closer to elimination.
2016-09-03 11:32:41 +03:00
Pierre Neidhardt fdbedcdb78 Export tree manipulation functions 2016-08-10 08:59:15 +05:30
Vytautas Šaltenis 6d7f5e1bca More lint: block.go 2016-07-27 21:40:45 +03:00
Vytautas Šaltenis cd2f079140 More lint: inline.go 2016-07-27 21:31:29 +03:00
Dmitri Shuralyov 2560c5f148 Fix issue in fenced code block pre-processing.
Forwardport changes from #280.

Fixes #279.
2016-07-15 17:03:02 -04:00
Vytautas Šaltenis 3575453f08 Move a couple helpers to parser where they're used 2016-04-11 15:55:50 +03:00
Vytautas Šaltenis c9ea588e6f Convert uint32 fields to ints
The former is a bit too inconvenient despite being more accurate.
2016-04-11 11:15:15 +03:00
Vytautas Šaltenis 02a5ce37ff Go style: Html{Block|Span} -> HTML{Block|Span} 2016-04-01 13:15:47 +03:00
Vytautas Šaltenis 4ba991937b Store cell alignment in own type instead of int 2016-04-01 11:44:59 +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 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 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 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 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 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
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 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 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 5d3d5c198e Handle comments within a block
Added test cases both for inline and block workflows.

Closes #136.
2015-10-11 11:14:34 +03:00
Vincent Batoufflet 081aa9c378 Fix definition lists end-of-list detection 2015-06-07 09:36:53 +02:00
Vincent Batoufflet c4825a719d Add definition lists extension support 2015-06-03 08:03:34 +02:00
Vytautas Šaltenis 0bf420d72a Fix a couple typos 2015-05-23 09:28:21 +03:00
Vytautas Šaltenis f4655604b3 Cleanup a random bunch of repetitive loops
Replace them with helper function calls.
2015-04-07 21:59:42 +03:00
Vytautas Šaltenis 36787eca3a Allow heading to end with \#
The problem was in a loop that skipped the optional closing hashes in a
heading like this:

    ### This is an H3 ###

Now it checks to see if a hash is escaped and if it is, treats it as a
rightmost character of the heading text, like this:

    ### This is an H3 #\##   ==>   ### This is an H3 ##

Fixes issue #146.
2015-04-07 21:58:29 +03:00
Tw d90024b17b Delete unnecessary copy of input when enable fenced code extension
Copy of input waste time and memory.

Signed-off-by: Tw <tw19881113@gmail.com>
2015-02-11 15:44:24 +08:00