Commit Graph

75 Commits

Author SHA1 Message Date
choueric
5b2fb1b893 use map[string]struct{} as a set.
Use map[string]struct{} instead of map[string]bool to implement a set
and reduce memory space.
2017-06-10 22:24:27 +08:00
choueric
8c89af6200 add 'notesRecord' to check footnote existence fast
It is necessary to use vector for 'notes' instead of map to keep
footnotes ordered. But checking for presence in a vector is not
efficient. So add a map variable 'notesRecord' to tackle this problem.
2017-06-09 10:20:58 +08:00
choueric
a20399916c fix duplicate and recursive footnotes. (#241)
Fix the infinite loop when there is a self-refer footnote by checking if
the reference is already added into parser.notes.

It also fixes of creating duplicate footnotes through this modification.

Add coresponding testcase.
2017-06-08 14:43:56 +08:00
choueric
3ffe8c7f6b add extension to join lines 2017-02-22 09:15:46 +08:00
Dmitri Shuralyov
b88a9bd458 Avoid unneeded break statement.
This is purely a style change with no behavior difference.

In Go (unlike most other languages), case statements in a switch
don't need an explicit break statement, it happens by default. Adding
it explicitly is possible, but has no effect.

In this case, having the break statement hurts readability because
it's hard to tell if it's a mistake, and the break was intended to
break out of the outer for loop, rather than do nothing for the switch
statement. So, remove it, to make it more clear that there is no
bug here.
2016-05-24 22:04:36 -07:00
Vytautas Šaltenis
ee63ffd3e2 Fix initialisms in function names 2015-12-25 13:04:56 +02:00
Vytautas Šaltenis
fc740701cf Cosmetics: fix comment placement and import order 2015-12-10 21:03:21 +02:00
Nat Welch
1bb1fa9e95 remove check that brace is > 0 2015-12-05 02:00:36 +00:00
Nat Welch
c1d4a77100 Fix comment formatting and spelling 2015-12-05 02:00:23 +00:00
Nat Welch
45f5800b75 Get tests to pass 2015-11-29 00:08:48 +00:00
Nat Welch
1622f8f312 Apply @miekg's patch
From 99ce7134f6.patch
2015-11-26 22:11:25 +00:00
Vytautas Šaltenis
c5943e0685 Reformat a dustball of ifs into a switch statement 2015-11-04 21:32:53 +02:00
Vytautas Šaltenis
ca8c21a297 Fix footnote following an exclamation point
Link parser interpreted the sequence "![^foo]" as an image, but if
footnote extension is enabled, it's quite clear that it should be
interpreted as a footnote following something with an exclamation point
at the end.

Closes #194.
2015-11-03 20:52:36 +02:00
Vytautas Šaltenis
d4ee3ea08b Simplify return value 2015-10-28 21:21:51 +02:00
Vytautas Šaltenis
a18a46c9b9 Merge pull request #203 from russross/issue-136
Handle comments within a block
2015-10-20 20:45:00 +03:00
Vytautas Šaltenis
53982c119c Merge pull request #206 from russross/issue-164
Fix footnote followed by a reference style link
2015-10-19 09:17:51 +03:00
Vytautas Šaltenis
4b668b875b Merge pull request #205 from russross/issue-156
Fix bug parsing emphasis
2015-10-19 09:08:30 +03:00
Vytautas Šaltenis
f7510976a3 Fix escaping asterisks within emphasis
First check for escaped character, *then* look if i-th character is an
emphasis character.

Closes #18.
2015-10-13 19:57:15 +03:00
Vytautas Šaltenis
08eac30cb9 Fix footnote followed by a reference style link
When parsing a deferred footnote, we already know it's a footnote from
the '[^' part, so we can use that to hit a proper switch branch
(default) a bit later on.

Closes #164.
2015-10-12 21:18:33 +03:00
Vytautas Šaltenis
cc3cc10ef2 Fix bug parsing emphasis
Start searching for emphasis character at 0th index instead of 1st.
Fixes a corner case with doubly emphasised code span followed by
another code span on the same line.

Changes interpretation of improperly nested emphasis, hence the change
in TestEmphasisMix().

Closes #156.
2015-10-12 21:06:27 +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
Vytautas Šaltenis
62f0018e2f Replace snake_case with mixedCase 2015-05-06 15:55:04 +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
c1917970db Use EXTENSION_BACKSLASH_LINE_BREAK 2015-04-22 14:09:39 +02:00
neclepsio
d4c83fb4da Fix previous commit
Backslash was not removed from output.
2015-04-22 14:04:08 +02:00
neclepsio
2824a549c3 Implement backslash hard line break
See http://spec.commonmark.org/0.18/#example-527
2015-04-22 12:23:19 +02:00
Vytautas Šaltenis
b3137e7c8f Merge pull request #152 from elian0211/about_links
update about links
2015-04-09 20:41:45 +03:00
Vytautas Šaltenis
195dac9f5b Fix recognition of consecutive footnotes
The second footnote was treated as if the pair of them were a reference
style link, without checking if the second bit is another footnote.

Fixes issue 158.
2015-04-03 21:08:46 +03:00
elian0211
bd11a52f1e update func isSafeLink 2015-02-25 21:27:13 +08:00
elian0211
27ba4cebef update about links
when link to current directory or parent directory
2015-02-20 17:06:55 +08:00
KenjiTakahashi
f147218833 fix #19: return immediately from link skipping if end of emphasis is found 2014-12-29 00:34:06 +01: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
Dmitri Shuralyov
78172e5f73 Improve parser to detect LineBreak independently of renderer.
When checking if it's a newline preceeded by two spaces, look at the input data rather than the output, since the output depends on the renderer implementation.
2014-08-26 21:00:07 -07:00
Vytautas Šaltenis
f3ab1849e6 Merge pull request #39 from athom/tilde-escape
allow \~ to escape as ~
2014-05-03 16:01:58 +03: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
Vytautas Šaltenis
e5937643a9 Fix bug in autolink with trailing semicolon
In case the link ends with escaped html entity, the semicolon is a part
of the link and should not be interpreted as punctuation.
2014-02-17 21:09:04 +02:00
Vytautas Šaltenis
f2d43f69a4 Fix bug in autolink termination
Detect the end of link when it is immediately followed by an element.
2014-02-17 21:09:03 +02:00
Vytautas Šaltenis
9fc8c9d866 Fix bug with overzealous autolink processing
When the source Markdown contains an anchor tag with URL as link text
(i.e. <a href=...>http://foo.bar</a>), autolink converts that link text
into another anchor tag, which is nonsense. Detect this situation with
regexp and early exit autolink processing.
2014-02-17 21:09:03 +02:00
Darren Coxall
59358adea8 Relative URIs are considered safe 2013-12-09 14:41:37 +00:00
athom
4c11f72496 allow \~ to escape as ~ 2013-10-01 16:14:04 +08:00
Russ Ross
ca82b8db3a panic fix (issue #33) with test case 2013-09-11 12:47:43 -06:00
Alex Xandra Albert Sim
e250348279 Image inside a link now works. 2013-09-09 12:51:46 +07:00
athom
31798e0eab add testcase for GFM autolink 2013-08-09 17:24:26 +08:00
athom
16c09b01bd make autolink peforms like GFM 2013-08-09 16:28:35 +08:00
moshee
3ea84a5811 parser no longer returns prematurely from empty footnote ref 2013-07-08 22:34:12 +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
Russ Ross
bb8ee591d1 doc improvements, commenting 2011-07-07 11:56:45 -06:00