Commit Graph

94 Commits

Author SHA1 Message Date
Vytautas Šaltenis
1d673b3cd9 Bump const VERSION to 1.4
This is probably not used by too many people, but there it goes anyway.

Closes #119.
2015-10-18 20:51:29 +03:00
Tw
d28de22ef0 fix index out of range panic in reference link
Add checking before accessing the input data.

Fix #172 and #173 issues.

Signed-off-by: Tw <tw19881113@gmail.com>
2015-06-08 15:31:55 +08: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
eeb2c39339 Merge branch 'master' of https://github.com/jtolds/blackfriday into jtolds-master
Conflicts:
	inline_test.go
2015-05-06 15:41:12 +03:00
neclepsio
68a3c498f6 Add EXTENSION_BACKSLASH_LINE_BREAK 2015-04-22 14:10:44 +02: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
JT Olds
8e10236be5 support replacing [refid][] syntax link content with alternate content 2014-12-18 17:36:46 -07:00
JT Olds
5e8b222b69 Add programmable reference overrides
If a user provides a ReferenceOverride function, then reference ids
will be passed to the given ReferenceOverride function first, before
consulting the generated reference table.

The goal here is to enable programmable support for
"WikiWords"-style identifiers or other application-specific
user-generated keywords.

Example, writing documentation:

 The [Frobnosticator][] is a very important class in our codebase.
 While it is used to frobnosticate widgets in general, it can also
 be passed to the [WeeDoodler][] to interesting effect.

This might be solveable with the HTML Renderer relative prefix, but
I didn't see a good way of making a short link to 'Frobnosticator'
relatively without having to write it twice. Maybe
'<Frobnosticator>' should work? Should Autolinks work for relative
links?

In addition, I wanted a little more richness. I plan to support
Godoc links by prefixing references with a '!', like so:

  Check out the [Frobnosticator][] helper function
  [!util.Frobnosticate()][]

The first link links to the Frobnosticator architectural overview
documentation, whereas the second links to Godoc.

Better advice on how to implement this sort of think with
Blackfriday is highly desired.
2014-12-16 16:17:52 -07: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 Saltenis
427a14caf2 Convert silly funcs to consts 2014-09-22 11:44:58 +03:00
Vytautas Šaltenis
3a99461662 Make sure relative URLs are preserved
Add tests to make sure we don't break relative URLs again.
Extracted common html flags and common extensions for easy access from
tests.

Closes issue #104, which was fixed as a side effect of cf6bfc9.
2014-09-21 16:29:24 +03:00
Vytautas Saltenis
cf6bfc9d6d Rip off all blackfriday's html sanitization effort
As per discussion in issue #90.
2014-09-19 21:25:23 +03:00
Brian Goff
539b27a624 Add titleblock support 2014-08-04 14:08:22 -04:00
Daniel Imfeld
ec41294bc4 Add footnote prefix option. Needs testing 2014-05-24 02:55:13 -05:00
Daniel Imfeld
5c12499aa1 Add ability to convert relative links to absolute 2014-05-18 01:28:15 -05:00
Dave Johnston
baebdee6de Avoid double alloc 2014-05-03 08:52:18 +01:00
Dave Johnston
852c1967b9 Fix fenced code extn modifying data beyond slice 2014-05-02 23:05:06 +01:00
Martin Probst
41251715ad Use go.net/html's parser to sanitize HTML.
Use an HTML5 compliant parser that interprets HTML as a browser would to parse
the Markdown result and then sanitize based on the result.
Escape unrecognized and disallowed HTML in the result.
Currently works with a hard coded whitelist of safe HTML tags and attributes.
2014-04-27 23:40:44 +02: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
8df342acd5 Fix bug where newlines were inserted inside fenced code blocks.
Change firstPass() code that checks for fenced code blocks to check all
of them and properly keep track of lastFencedCodeBlockEnd.
This way, it won't misinterpret the end of a fenced code block as a
beginning of a new one.
2014-04-11 21:27:28 -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
cf01a94556 Add Header IDs to default extensions 2014-04-05 20:45:57 +01:00
Dave Johnston
2dff0864f0 Add header ID support and tests: # Header {#myid} 2014-04-05 20:42:58 +01:00
Mathias Leppich
17ca261449 optimisation: only fix fenced code blocks if the extensions parser flag is set... ;-) 2014-04-01 23:20:18 +02: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
Vytautas Šaltenis
2f50a53f8e Rename HTML_SKIP_SCRIPT to HTML_SANITIZE_OUTPUT 2014-01-22 01:23:43 +02:00
Vytautas Šaltenis
55cd82008e Rewrite protection against JavaScript injection
This drops the naive approach at <script> tag stripping and resorts to
full sanitization of html. The general idea (and the regexps) is grabbed
from Stack Exchange's PageDown JavaScript Markdown processor[1]. Like in
PageDown, it's implemented as a separate pass over resulting html.

Includes a metric ton (but not all) of test cases from here[2]. Several
are commented out since they don't pass yet.

Stronger (but still incomplete) fix for #11.

[1] http://code.google.com/p/pagedown/wiki/PageDown
[2] https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
2014-01-22 01:14:35 +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
31798e0eab add testcase for GFM autolink 2013-08-09 17:24:26 +08: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
3ea84a5811 parser no longer returns prematurely from empty footnote ref 2013-07-08 22:34:12 +00:00
moshee
4513607d62 leftover debug stuff 2013-07-08 09:42:29 +00:00
moshee
1a73bae554 added slice bounds check 2013-07-08 06:54:25 +00:00
moshee
c23099e5ee Implementation and some tests for inline footnotes. Also I noticed the list items had the wrong ids, that was silly of me. 2013-07-01 01:37:52 +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
Vytautas Šaltenis
079a55851d Fix typo 2013-04-14 01:44:18 +03:00
Vytautas Šaltenis
375cae5dbe Add HTML_SKIP_SCRIPT to MarkdownCommon 2013-04-14 01:43:21 +03:00
moshee
e69cdde766 Add some HTML5 2012-10-21 21:28:31 -07:00
Russ Ross
a5441fd99f updates for go 1 2012-03-07 21:36:31 -07:00
Russ Ross
6bc8c7a22b version bump to v1.1 2011-09-26 15:45:49 -06:00
Russ Ross
fbbd3248e9 tag as version 1.0 2011-07-19 11:42:24 -06:00
Russ Ross
530123dd9f additional doc comments 2011-07-07 12:05:29 -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
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
a99c922b84 remove NO_EXPAND_TABS options 2011-07-01 09:57:11 -06:00
Russ Ross
2aca667078 simplify inline callback interface 2011-06-29 13:00:54 -06:00