1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-26 20:14:43 +01:00
Commit Graph

68 Commits

Author SHA1 Message Date
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
Dmitri Shuralyov
54a323aafb Update import path of sanitized_anchor_name.
It has moved into a smaller standalone repo.
Closes #139.
2015-01-10 18:23:29 -08:00
Dmitri Shuralyov
f4bb968b5f Minor cleanup.
Apply gofmt on html.go.
Apply goimports-compatible formatting on block.go (space between standard and third party imports).
Move Travis build status image in a more pleasing, common location.
Remove "Markdown pretty-printer output engine" from TODO steps; this is already done in markdownfmt.
Remove unneeded trailing whitespace in README.
2014-11-29 20:41:11 -08: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
Brian Goff
539b27a624 Add titleblock support 2014-08-04 14:08:22 -04:00
Vytautas Šaltenis
c5ece173ad Merge pull request #59 from johnsto/master
Header ID specifiers
2014-04-11 21:31:27 +03:00
Mathias Leppich
cb288d6b5d Revert "add an infinity-loop detection to block-level parsing"
This reverts commit 0c62e28e90.
2014-04-08 11:51:17 +02: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
cd3fa08cb1 fix issue #45: 'Fenced Code Blocks without a blank line before'
Add missing newline between paragraph and fenced code block within `firstPass()`.
2014-03-30 22:40:43 +02:00
Mathias Leppich
0c62e28e90 add an infinity-loop detection to block-level parsing 2014-03-30 22:40:43 +02:00
David Kitchen
6e6572e913 Added th to table headers so that styling with things like Twitter Bootstrap and typeset.css work as expected. Cells in headers should always be TH unless they are advisory cells within headers in which case TD is acceptable (but being Markdown a user with such needs could just enter HTML for this) 2013-10-16 11:36:33 +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
moshee
8346559a1a Referenced footnotes appear to be functional. Inline still unimplemented. 2013-06-26 16:09:27 +00:00
moshee
7bdb82c53a new tests pass but old tests now fail... 2013-06-26 15:57:51 +00:00
moshee
be082a1ef2 First attempt at supporting Pandoc-style footnotes. The existing tests have not broken but the new functionality does not work yet. 2013-06-25 01:18:47 +00: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
c99557ec28 bug in tables when a row has too few columns 2011-07-25 10:23:31 -06:00
Russ Ross
bb8ee591d1 doc improvements, commenting 2011-07-07 11:56:45 -06:00
Russ Ross
2b87b0e786 simplify naming of parsing functions 2011-07-05 14:22:21 -06:00
Russ Ross
fb435fe2e3 finished removing redundant end-of-buffer checks in block parsing; code cleanup 2011-07-04 18:56:29 -06:00
Russ Ross
bd60e3691b removing more redundant checks, additional cleanup of block parsing 2011-07-01 14:13:26 -06:00
Russ Ross
689f6cb79b more consistent spacing of block-level elements 2011-07-01 11:19:42 -06:00
Russ Ross
d4353d99fa remove redundant tests for tab characters in parsing 2011-07-01 10:03:03 -06:00
Russ Ross
7544368fce removing redundant end-of-buffer checks in block parsing 2011-06-29 20:15:58 -06:00
Russ Ross
ae9562f685 move whitespace stripping to parser, not renderers 2011-06-29 15:38:35 -06:00
Russ Ross
3c6f18afc7 Renderer is now an interface 2011-06-29 11:13:17 -06:00
Russ Ross
f0cd9a420e render -> Parser, made parsing functions methods of *Parser 2011-06-28 18:58:53 -06:00
Russ Ross
55cde00c8a camel case 2011-06-28 16:02:12 -06:00
Russ Ross
fde2c60665 version number, few more options for command-line tool 2011-06-28 11:30:10 -06:00