Commit Graph

169 Commits

Author SHA1 Message Date
James
1025c0e7bd Fixed deprecated (see: https://www.w3.org/TR/html4/present/graphics.html#h-15.1.2) align property on tables. Now uses inline CSS. 2018-10-29 15:59:30 -05:00
Liming Jin
670777b536 add NoopenerLinks (#437) 2018-05-26 10:57:26 +03:00
Emil Melnikov
f04854434e Add heading offset option to HTML renderer (#421)
Setting HTMLRendererParameters.HeadingLevelOffset to L changes
default HTML heading levels from hX to h(X+L).
2018-05-24 21:52:48 +03:00
Iain Haslam
ee09303c1a v2: Fix HTML5 by removing rel="footnote" which is invalid.
See #433 for an equivalent change on v1 branch.
2018-02-24 18:23:00 +00:00
Vytautas Šaltenis
cadec560ec Merge pull request #384 from bep/v2
Add Smartypants support for French Guillemets
2017-08-06 20:10:14 +03:00
Bjørn Erik Pedersen
3a1d515242 Add Smartypants support for French Guillemets
This is a port of the fix for #378 in v1.

Fixes #380
2017-08-02 21:42:14 +02:00
Vytautas Šaltenis
45820516bb Unexport a bunch of constants private to HTML renderer (#381)
Unexport a bunch of constants private to HTML renderer

They were cluttering the documentation and are not useful otherwise.
Rearrange constants in descending dependencies order
2017-08-02 09:20:10 +03:00
Vytautas Šaltenis
427717f991 Use io.WriteString instead of w.Write([]byte(str)) 2017-07-10 19:11:30 +03:00
Vytautas Šaltenis
479920a987 Improve the Renderer interface
Improve Renderer to be less confusing. Fix documentation for it.

OmitContents flag got dropped along the way. First, it would fit poorly
into the new design and second, it's unclear how widely this feature is
used. But most importantly, it's trivial to roll your own with the v2
API: https://gist.github.com/rtfb/2693f6bfcc1760661e8d2fb832763a15

Fixes #368.
2017-07-09 15:44:00 +03: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
d04a53c644 Merge branch 'v2' into v2-perf-tweaks 2017-02-02 12:00:48 +02:00
Vytautas Šaltenis
ea57e93666 Several fixes after code review 2017-02-02 11:54:10 +02:00
Vytautas Šaltenis
a4dd8ad4a6 Merge pull request #324 from russross/move-toc-to-html
Move TOC and OmitContents to HTML flags
2016-12-07 21:07:04 +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
b61f73e4f9 Ditch SkipStyle flag
It's been broken since early 2014, which clearly demonstrates that
nobody uses it.

Fixes #252.
2016-11-24 20:37:33 +02:00
Vytautas Saltenis
22a3e5b744 Avoid calling bytes.Split() in appendLanguageAttr
This avoids some allocs.
2016-10-29 12:09:34 +03:00
Vytautas Šaltenis
c60ee1aab0 Avoid allocating []byte for every written newline
This shaves off another ~25% of allocs.
2016-10-08 18:17:00 +03:00
Vytautas Šaltenis
993325d13f Roll our own implementation of HTML escaper 2016-09-10 14:33:37 +03:00
Vytautas Šaltenis
31f2685bfe Remove lots of string literals
Using strings in helper functions causes a lot of string-to-[]byte
allocations. This fix is centered around converging the tag() helper
func to the []byte lingo. In order to do that, a lot of string literals
have moved to global variables, where string to []byte conversion can
happen once.
2016-09-10 13:17:42 +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
Pierre Neidhardt
225250ddf1 html.go: Lint RenderNode() 2016-08-12 09:16:14 +05:30
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
Vytautas Šaltenis
37141d5b5a Merge pull request #296 from Ambrevar/v2icon
v2: Add Icon parameter to the HTML renderer
2016-08-09 22:22:31 +03:00
Pierre Neidhardt
413328d30b Add Icon parameter to the HTML renderer 2016-08-09 17:54:34 +05:30
Pierre Neidhardt
b5ff8e0286 Break lines properly in TOC generation and omit content if required 2016-08-09 15:11:40 +05:30
Pierre Neidhardt
4d756003cd Move TOC generation to the HTML Renderer 2016-08-09 12:37:44 +05:30
Vytautas Šaltenis
e054c962e7 More lint: markdown.go and ripples to other files 2016-07-27 21:28:41 +03:00
Vytautas Šaltenis
f7ec3b0e34 Fix a few lint errors, a.k.a. improve docs 2016-07-27 10:11:13 +03:00
Vytautas Šaltenis
89653c9927 Merge pull request #274 from Ambrevar/v2misc
v2: Implicit interface and Stringer
2016-07-27 09:39:58 +03:00
Vytautas Šaltenis
6291a00f2f Remove dead fields from HTMLRenderer 2016-07-05 07:33:21 +03:00
Vytautas Šaltenis
cb6bd67271 Remove dead HTMLWriter code 2016-07-04 22:02:22 +03:00
Vytautas Šaltenis
f90a576a05 Untangle some mess with attribute escaping
1. Remove unused preserveEntities parameters
2. Move attrEscape() implementation inside esc()
3. Delegate most of esc() work to escCode()
2016-07-02 10:45:06 +03:00
Pierre Neidhardt
20aa621387 Fix empty path to CSS 2016-07-01 18:18:51 +02:00
Pierre Neidhardt
2e53c20b2f Return a *HTMLRenderer from NewHTMLRenderer
Interfaces should be satisfied implicitly.
2016-07-01 17:23:30 +02:00
Vytautas Šaltenis
3575453f08 Move a couple helpers to parser where they're used 2016-04-11 15:55:50 +03:00
Vytautas Šaltenis
76d8c71d70 Unduplicate attrEscape funcs 2016-04-11 15:55:50 +03:00
Vytautas Šaltenis
e95d23065a Rename HTML to HTMLRenderer 2016-04-11 11:45:40 +03:00
Vytautas Šaltenis
c26fdef40e Move html entity regexp to where it's used
And unify regexp variable names.
2016-04-11 11:45:19 +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
98ddf98997 Get rid of unneeded method in Renderer 2016-04-11 11:12:41 +03:00
Vytautas Šaltenis
24e146a727 Make HTMLRendererParameters a substruct of HTML 2016-04-05 14:44:14 +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
4f8d2881a2 Remove a bit of cruft from HTML renderer 2016-04-05 13:54:57 +03:00
Vytautas Šaltenis
83b4cb6062 Implement SkipHTML, add test 2016-04-05 12:48:29 +03:00
Vytautas Šaltenis
7e9a57463f Implement SkipStyle, add test
Fix a bug in findHtmlTagPos introduced with e02c392d.
2016-04-05 12:48:28 +03:00
Vytautas Šaltenis
fecfec2059 Implement SkipImages and add test 2016-04-05 12:48:28 +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
607478a8ce Implement SkipLinks, add test 2016-04-04 14:08:35 +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