Commit Graph

47 Commits

Author SHA1 Message Date
Dmitri Shuralyov
93622da34e Make newline mandatory for opening fence line. (#281)
This was an unintended typo/mistake in #280.

This is stricter, and it's fine. The opening fence line will always need to have a newline.

Add another test for isFenceLine.
2016-07-16 11:34:03 -04:00
Dmitri Shuralyov
a5812bb8f2 Improve fenced code block detection for first pass.
In first pass, there may not be a trailing newline after a fenced code
block yet. Make newline optional in isFenceLine when calling
fencedCodeBlock to detect the fenced code block it anyway. This is more
complex, but it avoids creating temporary buffers or modifying input in
order to maintain performance (see #148).

Document and rename fencedCode to fencedCodeBlock.

Add regression tests.

Fixes #279.
2016-07-15 15:07:43 -04:00
Dmitri Shuralyov
0049676599 Improve fence line detection.
Rename isFenceCode to isFenceLine, document it, add tests.

Add support for making newline optional, this will be needed in future
commits.
2016-07-15 14:59:57 -04:00
Cameron Moore
acc07e6144 Fix definition lists that contain other lists
Fixes #263
2016-05-06 13:27:55 -05:00
Cameron Moore
0529888f55 Fix adjacent list merging
Prevent adjacent lists of differing types from being merged into a
single list.  No options are provided to enable the previous behavior.

Fixes #235
2016-05-02 09:02:35 -05: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
f5ac2ddf7a Add a few more CDATA tests 2015-12-16 20:53:40 +02:00
Vytautas Šaltenis
05a79218ed Implement support for CDATA section
Fixes #165.
2015-12-14 20:57:40 +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
Austin Ziegler
a5e88a3350 Add a flag to turn on header ID generation.
- Fixes #51, #101, and #102.
- Uses the [code][gfm] mentioned by @shurcooL from his Github
  Flavored Markdown parser extension in a [comment on #102][comment].
  Since this was mentioned, I assumed that @shurcooL would be OK with
  this being included under the licence provided by blackfriday (there
  is no licence comment on his code).
- I’ve added it behind another flag, EXTENSION_AUTO_HEADER_IDS, that
  would need to be turned on for it to work. It works with both prefix
  and underline headers.

[gfm]: 3bec0366a8/github_flavored_markdown/main.go (L90-L102)
[comment]: https://github.com/russross/blackfriday/issues/102#issuecomment-51272260
2014-10-27 16:54:23 -04:00
Vytautas Šaltenis
74dee4bbbc Fixup tests after 67002b0 2014-08-29 15:26:37 +03:00
Brian Goff
539b27a624 Add titleblock support 2014-08-04 14:08:22 -04:00
Dmitri Shuralyov
ad246ef7a5 Don't expand tabs inside fenced code blocks.
Still do normalize newlines inside fenced code blocks.
2014-04-12 14:45:25 -07:00
Dmitri Shuralyov
ef2a2b02dc Add failing test for an issue introduced by PR #56.
The issue is that when there are more than 1 fenced code blocks with a
blank line before and after, the parser introduces a single extra new
line to all the fenced code blocks except the last one.
2014-04-11 19:54:55 -07:00
Vytautas Šaltenis
c5ece173ad Merge pull request #59 from johnsto/master
Header ID specifiers
2014-04-11 21:31:27 +03:00
Dave Johnston
924064f3f7 Also support header IDs in ## headers ## 2014-04-06 10:30:40 +01:00
Dave Johnston
7ad5f9c119 Correctly emit trailing header ID brace 2014-04-05 20:59:03 +01:00
Dave Johnston
2dff0864f0 Add header ID support and tests: # Header {#myid} 2014-04-05 20:42:58 +01:00
Mathias Leppich
a4274bba51 add error message when panic has been raised within doTestsBlock() 2014-03-30 22:40:43 +02:00
Mathias Leppich
d4c367a949 add test cases for issue #45 2014-03-30 22:40:43 +02:00
David Kitchen
5b954f1f77 Updated tests to check for th tags instead of td tags within thead blocks 2013-10-17 10:35:44 +01:00
athom
8751c35d1a add EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK flag to make it closer to GFM(Github flavor Markdown) 2013-07-30 10:32:11 +08:00
Russ Ross
b97990f1bb permit backslash-escaped vertical bars in tables 2011-09-13 16:23:24 -06:00
Russ Ross
583b3c5e1d fixed bug with blank line handling within list items 2011-09-09 12:30:45 -06:00
Russ Ross
b8bc812a67 table unit tests and fix for a crash uncovered by them 2011-07-25 11:39:02 -06:00
Russ Ross
e35b4b66cc bounds checking stress tests 2011-07-03 10:51:07 -06:00
Russ Ross
689f6cb79b more consistent spacing of block-level elements 2011-07-01 11:19:42 -06:00
Russ Ross
873a60ad49 complete page rendering is now an option in the library 2011-06-29 10:08:56 -06:00
Russ Ross
c969dff782 added simplified interface for common usage 2011-06-28 15:55:27 -06:00
Russ Ross
fde2c60665 version number, few more options for command-line tool 2011-06-28 11:30:10 -06:00
Russ Ross
2f839dc39a fenced code: ending marker must match beginning marker, tests for fenced code blocks 2011-06-28 10:30:25 -06:00
Russ Ross
f8f70572a4 simplified BSD license 2011-06-27 20:11:32 -06:00
Russ Ross
8233aad6ad preformatted html block tests 2011-06-27 19:35:40 -06:00
Russ Ross
fffbd3ed1a tests for ordered lists 2011-06-27 18:03:54 -06:00
Russ Ross
00cb90e934 horizontal rule and list testing 2011-06-27 16:06:32 -06:00
Russ Ross
9a0217f7aa fixed minor bugs uncovered by more testing 2011-06-27 14:35:11 -06:00
Russ Ross
47c4852520 unit tests for underlined headers, improved whitespace handling for the same 2011-06-27 11:42:38 -06:00
Russ Ross
3af64a90ad fixed headers nested in lists, added prefix header unit tests 2011-06-27 10:13:13 -06:00