Commit Graph

172 Commits

Author SHA1 Message Date
Vytautas Šaltenis
d04a53c644 Merge branch 'v2' into v2-perf-tweaks 2017-02-02 12:00:48 +02:00
Vytautas Šaltenis
9c4ef640b9 Move TOC and OmitContents to HTML flags
The root problem this commit fixes is the duplication of Extensions
field in HTMLRendererParameters. The duplication crept in there only to
support these two flags, so moving the flags solves the problem. They're
only used in renderer anyway.

Fixes #277.
2016-11-24 21:48:48 +02:00
Vytautas Šaltenis
120bb2fae1 Get rid of the preprocess stage
Yay!!
2016-11-10 21:49:58 +02:00
Pierre Neidhardt
627dc87cad Add missing type to TableAlignment* constants 2016-10-09 08:43:40 +05:30
Vytautas Šaltenis
6141d5fde1 Merge pull request #306 from russross/v2-add-links-to-footnotes
V2 add links to footnotes
2016-10-03 08:14:53 +03:00
Vytautas Šaltenis
8a11177489 Add direct link to a footnote from it's referer
Some renderers might not care to have an explicit list of footnotes at
the end of the document, instead they're interested in the content of
the footnote at the location of a referer. Make their lives easier by
providing such a link
2016-09-17 19:35:42 +03:00
Pierre Neidhardt
4688db5f6f Remove the LaTeX renderer stub and point to Ambrevar's implementation 2016-09-10 16:17:05 +05:30
Vytautas Šaltenis
b91b5719eb Merge pull request #302 from russross/v2-move-footnotest-to-html
v2: move footnotes to html
2016-09-10 11:32:03 +03:00
Vytautas Šaltenis
91753e8bc7 v2: Extract package level documentation to doc.go (#303)
* Extract package level documentation to doc.go

Plus elaborate the documentation a bit.

* Fix grammar
2016-09-05 10:25:10 +03:00
Vytautas Šaltenis
d36199c417 Rename firstPass -> preprocess 2016-09-03 15:32:37 +03:00
Vytautas Šaltenis
3c2cb1ff45 Fix typo 2016-09-03 15:29:28 +03:00
Vytautas Šaltenis
43ba539936 Add some documentation to reference struct 2016-09-03 13:16:41 +03:00
Vytautas Šaltenis
6947216efb Move footnote rendering to the renderer
Clean up footnotes part of an AST: don't force HTML-specific pieces
there, just keep a clean list of footnotes. Since some renderers might
want to process footnotes differently, let them know about footnotes by
having a flag on that list.
2016-09-03 12:39:16 +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
Vytautas Šaltenis
efa77da18b Fix omission in list item flags
When parseRefsToAST constructs a list of footnotes, it hardcoded the
item flags to ListTypeOrdered and omitted ListItemBeginningOfList.

However, a quick look around indicates that ListItemBeginningOfList
might have lost its meaning altogether in v2 (it used to control item
spacing in v1, which is now extracted from the AST structure). So add a
TODO to clean that up one day.
2016-08-29 00:16:22 +03:00
Vytautas Šaltenis
771cf410c8 Get rid of secondPass function
Most of its body was redundant, as it was moved to parseRefsToAST. After
removal of that code, only a single line remains, so move it out to the
caller of secondPass.
2016-08-29 00:16:22 +03:00
Pierre Neidhardt
6fd47b3b61 v2: Only split when inline callbacks consume some bytes (#301)
* Only split when inline callbacks consume some bytes

The former hacks around maybeLineBreak and Smartypants are no longer
needed.
The algorithm has been streamlined: shorter, simpler, faster.
The 'currBlock' field of the parser is gone.

* Remove spurious logs
2016-08-19 08:56:33 +03:00
Vytautas Šaltenis
9926922c0b Merge pull request #295 from Ambrevar/v2FactorSmarty
v2: Factor Smartypants to HTML
2016-08-10 23:01:58 +03:00
Pierre Neidhardt
02da1dfe9d Factor Smartypants to HTML
Smartypants is HTML-specific.
There is no need to run Smartypants from `Render()`.
This simplifies extensions built upon the HTML renderer.
2016-08-10 09:58:33 +05:30
Pierre Neidhardt
fdbedcdb78 Export tree manipulation functions 2016-08-10 08:59:15 +05:30
Pierre Neidhardt
4d756003cd Move TOC generation to the HTML Renderer 2016-08-09 12:37:44 +05:30
Vytautas Šaltenis
a9baf845f1 Unpublish and rename LinkType constants (#285)
* Unpublish and rename LinkType constants

The constants are only used in the parsing phase, they are not recorded
in the AST directly, so make them private. Improve their names along the
way. Fix tagLength to return two values instead of taking an output
parameter.

* autoLinkType -> autolinkType

And remove unnecessary comment.
2016-07-29 08:01:31 +03:00
Vytautas Šaltenis
46b7355a78 Fix bullet points in MarkdownCommon docs 2016-07-28 19:23:04 +03:00
Vytautas Šaltenis
6d7f5e1bca More lint: block.go 2016-07-27 21:40:45 +03:00
Vytautas Šaltenis
e054c962e7 More lint: markdown.go and ripples to other files 2016-07-27 21:28:41 +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
2f1f0b6b9f Add RenderNode to Renderer interface 2016-07-05 07:32:16 +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
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
98ddf98997 Get rid of unneeded method in Renderer 2016-04-11 11:12:41 +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
123179b8f3 Make Markdown the most general API call
Get rid of MarkdownOptions.
2016-04-05 13:45:00 +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
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
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
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
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