Commit Graph

79 Commits

Author SHA1 Message Date
Miek Gieben 026a971788
Merge pull request #75 from mmarkdown/blockattr-fixes
Fix special section
2018-08-18 11:42:22 +02:00
Miek Gieben a98b0dbeb9 Table: parse table footers
This takes the syntax from kramdown: https://kramdown.gettalong.org/syntax.html#tables
Rename tableHead to tableHeader, and use tableFooter for consistency.

It's not guarded by any parser extension, except parser.Tables

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 11:33:30 +02:00
Miek Gieben 34e94474d8 Fix special section
You can't make up you're own attributes, give special header the class
"special". Adjust all testcases.

<hr>: support block level attributes.

Add more tests for block level attributes.

Fix figure attributes, by re-adding the attribute to the inner block
(table, quote or code block).

Fixes #7

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-18 11:27:17 +02:00
Miek Gieben 6a71c2fe43 ... and the tests
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-03 08:48:23 +01:00
Miek Gieben 9d3b13b86f fix tests as well
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 22:09:19 +01:00
Miek Gieben 30ca9f6e58 tests
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-30 22:09:19 +01:00
Krzysztof Kowalczyk 9bd36d810e add MathJax support; fixes #4 2018-04-15 23:34:22 -07:00
Krzysztof Kowalczyk 832ef9be61 un-export some stuff from parser package 2018-01-28 18:27:38 -08:00
Krzysztof Kowalczyk 84fa04bf9d less boilerplate 2018-01-27 20:51:43 -08:00
Krzysztof Kowalczyk dfa474f00a move parser into its own package 2018-01-27 18:50:27 -08:00
Krzysztof Kowalczyk 8641ad4e76 rename html.HTMLFlags => html.Flags 2018-01-27 18:39:03 -08:00
Krzysztof Kowalczyk 956d0f875c rename htmlrenderer.HTMLRendererParameters => htmlrenderer.Options 2018-01-27 18:29:51 -08:00
Krzysztof Kowalczyk 7b88bd6d02 move html renderer to htmlrenderer package 2018-01-27 18:22:11 -08:00
Krzysztof Kowalczyk da9aa552d2 tweak comments; reduce comment boilerplate 2018-01-26 14:21:26 -08:00
Krzysztof Kowalczyk fade61e5b7 use skipCharN() more 2018-01-26 02:17:38 -08:00
Krzysztof Kowalczyk 1e4781ae5c fix intentional build break 2018-01-26 01:22:57 -08:00
Krzysztof Kowalczyk 2ec36360d7 test breaking the code on travis.ci 2018-01-26 01:19:13 -08:00
Krzysztof Kowalczyk 6a262aa6c5 add tests for SanitizeAnchorName() 2018-01-26 01:18:19 -08:00
Krzysztof Kowalczyk 3ad26698c5 parallelize tests to go from 16 secs => 10 secs for 'go test' 2018-01-25 13:54:50 -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
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 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 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 925d99bc55 Add TOC generation tests 2016-08-09 15:11:40 +05:30
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 106f1ec1bb Add test for CompletePage flag
The implementation for CompletePage was committed with d7f1878 by
accident, following up with the test.
2016-04-04 14:17:16 +03:00
Vytautas Šaltenis 0774c060d7 Get rid of unnecessary test helpers 2016-04-04 14:00:26 +03:00
Vytautas Šaltenis a658caacc6 Use TestParams in block tests
The different testing function interfaces get unified a bit closer,
runnerWithRendererParameters completely eliminated.
2016-04-04 12:04:20 +03:00
Vytautas Šaltenis 15e052e478 Move all testing helper funcs in one place
Moved verbatim except for uncommented panic recovery section in the
doTestsInlineParam function.
2016-04-04 12:04:20 +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 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 6fe811b603 Fix TitleBlock test
It seems like the implementation of the extension was rather sloppy and
didn't adhere to the style common to the rest of Blackfriday.
2016-03-30 15:05:24 +03:00
Vytautas Šaltenis ee98bc0bf4 Massive replacement of C_STYLE flags to typed ones 2015-11-10 21:08:32 +02:00
Dmitri Shuralyov e93d8f1624 Make test values more readable, add additional test cases. 2015-10-31 14:35:21 -07: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 c9f5708bd5 Spread out test cases for readability 2015-10-20 20:31:08 +03: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 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
Dmitri Shuralyov fa1adcf84b Fix test case.
Fix a minor issue in expected anchor after recent PR. The tests were written before the improvement that squashes non-alphanumeric characters into a single dash, and does not include dashes at the beginning and end. This updates the test case to match that behavior so that tests pass and Travis is green.
2014-11-24 20:01:03 -08:00
Austin Ziegler 9c061de92b Allow configurable header ID prefix/suffixes.
This is specifically driven by the Hugo usecase where multiple documents
are often rendered into the same ultimate HTML page.

When a header ID is written to the output HTML format (either through
`HTML_TOC`, `EXTENSION_HEADER_IDS`, or `EXTENSION_AUTO_HEADER_IDS`), it
is possible that multiple documents will hvae identical header IDs. To
permit validation to pass, it is useful to have a per-document prefix or
suffix (in our case, an MD5 of the content filename, and we will be
using it as a suffix).

That is, two documents (`A` and `B`) that have the same header ID (`#
Reason {#reason}`), will end up having an actual header ID of the form
`#reason-DOCID` (e.g., `#reason-A`, `#reason-B`) with these HTML
parameters.

This is built on top of #126 (more intelligent collision detection for
`EXTENSION_AUTO_HEADER_IDS`).
2014-11-23 20:37:27 -05:00
Austin Ziegler 40f28ee022 Prevent generated header collisions, less naively.
> This is a rework of an earlier version of this code.

The automatic header ID generation code submitted in #125 has a subtle
bug where it will use the same ID for multiple headers with identical
text. In the case below, all the headers are rendered a `<h1
id="header">Header</h1>`.

  ```markdown
  # Header
  # Header
  # Header
  # Header
  ```

This change is a simple but robust approach that uses an incrementing
counter and pre-checking to prevent header collision. (The above would
be rendered as `header`, `header-1`, `header-2`, and `header-3`.) In
more complex cases, it will append a new counter suffix (`-1`), like so:

  ```markdown
  # Header
  # Header 1
  # Header
  # Header
  ```

This will generate `header`, `header-1`, `header-1-1`, and `header-1-2`.

This code has two additional changes over the prior version:

1.  Rather than reimplementing @shurcooL’s anchor sanitization code, I
    have imported it as from
    `github.com/shurcooL/go/github_flavored_markdown/sanitized_anchor_name`.

2.  The markdown block parser is now only interested in *generating* a
    sanitized anchor name, not with ensuring its uniqueness. That code
    has been moved to the HTML renderer. This means that if the HTML
    renderer is modified to identify all unique headers prior to
    rendering, the hackish nature of the collision detection can be
    eliminated.
2014-11-23 20:35:43 -05:00