Commit Graph

391 Commits

Author SHA1 Message Date
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
Vytautas Šaltenis
3a90da10e3 Merge pull request #159 from rtfb/sequential-footnotes
Fix recognition of consecutive footnotes
2015-04-05 09:28:21 +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
Vytautas Šaltenis
2c0c546774 Merge pull request #157 from dchest/reflib
Renaming of upskirt
2015-03-24 18:21:34 +02:00
Dmitry Chestnykh
ef9974b1b7 README: rename libupskirt to Sundown.
The original upskirt library by Natacha Porté has been renamed to
libsoldout, while the fork of it that was located at tanoku/upskirt has
been renamed to Sundown and moved to vmg/sundown. Since Blackfriday has
been started as a translation of tanoku/upskirt, rename its mention in
README to Sundown.
2015-03-24 06:35:19 +01:00
Dmitry Chestnykh
29c5b49e95 Rename upskirtref to testdata; upskirtref_test.go to ref_test.go. 2015-03-24 06:28:49 +01:00
Vytautas Šaltenis
6928e11ecd Merge pull request #155 from beyang/master
add rel="noreferrer" option
2015-03-15 19:31:50 +02:00
Beyang Liu
60b0b4024f add rel="noreferrer" option 2015-03-14 16:46:32 -07: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
Vytautas Šaltenis
77efab57b2 Merge pull request #149 from tw4452852/fenced_code
Delete unnecessary copy of input when enable fenced code extension
2015-02-11 10:22:51 +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
Vytautas Šaltenis
4f4aec0109 Merge pull request #145 from eparis/license
Move the license info from README to LICENSE file
2015-02-10 13:09:14 +02:00
Eric Paris
ec46062546 Move the license info from README to LICENSE file
It's pretty standard to have a license file, and some projects require
them before your code can be used in their code.  Move the license to
its own file.
2015-02-09 16:26:22 -05:00
Vytautas Šaltenis
fe5c2f48a9 Merge pull request #142 from anthonyfok/avoid-converting-dates-into-fractions
Avoid converting dates into fractions
2015-01-27 10:58:53 +02:00
Anthony Fok
2c9fe2cd03 Avoid converting dates into fractions
So that dates like 1/2/2005 and 2005/3/4 stay the way it is
without turning into ½/2005 and 2005/¾.

See http://discuss.gohugo.io/t/any-way-to-disable-smart-fractions/328
for discussions.
2015-01-24 15:23:48 -07:00
Vytautas Šaltenis
7001890e79 Merge pull request #140 from russross/update-import-path/sanitized_anchor_name
Update import path of sanitized_anchor_name.
2015-01-12 21:54:11 +02: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
Vytautas Šaltenis
8ad7215b24 Merge pull request #138 from KenjiTakahashi/emphasis_link
Fix for #19 + some tests for emphasis with links.
2014-12-29 02:32:11 +02:00
KenjiTakahashi
f147218833 fix #19: return immediately from link skipping if end of emphasis is found 2014-12-29 00:34:06 +01:00
KenjiTakahashi
fdda8b88b0 add tests for emphasis with links 2014-12-28 06:28:15 +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
Vytautas Šaltenis
48aaef5fbf Merge pull request #131 from russross/minor-cleanup
Minor cleanup.
2014-11-30 09:02:35 +02: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
Vytautas Šaltenis
315f87d8c0 Merge pull request #128 from bjornerik/angled-quotes
Add support for angled, double quotes
2014-11-28 19:33:07 +02:00
Vytautas Šaltenis
f10a439fa0 Merge pull request #130 from shurcooL/master
Fix test case.
2014-11-25 09:37:08 +02: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
Vytautas Šaltenis
77aeb0ca37 Merge pull request #129 from halostatue/header-prefixes-and-suffixes
Allow configurable header ID prefix/suffixes.
2014-11-24 22:32:19 +02:00
Vytautas Šaltenis
1f004e1c39 Merge pull request #126 from halostatue/generate-unique-header-ids
Prevent header collisions on generation.
2014-11-24 22:30:42 +02: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
bep
857a1a0260 Add support for angled, double quotes
The flag `HTML_SMARTYPANTS_ANGLED_QUOTES` combined with `HTML_USE_SMARTYPANTS` configures rendering of double quotes as angled left and right quotes (&laquo; &raquo;).

The SmartyPants documentation mentions a special syntax for these, `<<>>`, a syntax neither pretty nor user friendly.

Typical use cases would be either or, or combined, but never in the same document. As an example would be a person from Norway; he has a blog in both English and Norwegian (his native tounge); he would then configure Blackfriday to use angled quotes for the Norwegian section, but keep them as reqular double quotes for the English.

If the flag `HTML_SMARTYPANTS_ANGLED_QUOTES` is not provided, everything works as before this commit.
2014-11-05 23:29:41 +01:00
Vytautas Šaltenis
7c8f3c1dcc Merge pull request #125 from halostatue/auto-header-id
Add a flag to turn on header ID generation.
2014-10-28 16:34:49 +02:00
Vytautas Šaltenis
411a019e2d Merge pull request #124 from halostatue/fix-header-id-toc-rendering
Use supplied header ID for TOC rendering.
2014-10-28 16:34:44 +02: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
Austin Ziegler
8cc40f8e07 Use supplied header ID for TOC rendering.
- Fixes #112 so that `#header {#header-id}` renders the TOC with
  `#header-id` instead of `#toc_1`.
2014-10-27 16:49:28 -04:00
Vytautas Šaltenis
05b8cefd6a Merge pull request #118 from rtfb/test-relative-links
Make sure relative URLs are preserved
2014-09-22 11:58:14 +03: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 Šaltenis
64fbfbbadf Merge pull request #117 from rtfb/remove-sanitization
Remove sanitization
2014-09-20 14:54:26 +03:00
Vytautas Šaltenis
8e739c7f0d Change Sanitize() to SanitizeBytes() in example 2014-09-20 14:48:01 +03:00
Vytautas Saltenis
819f70a832 Document usage of blackfriday along w/ bluemonday 2014-09-19 21:26:22 +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
Vytautas Šaltenis
44a39c16c6 Merge pull request #111 from rtfb/master
Add Travis configuration and a badge
2014-08-30 10:12:56 +03:00
Vytautas Šaltenis
16035869a6 Remove go tip from Travis build matrix 2014-08-30 10:09:18 +03:00
Vytautas Šaltenis
c50c511603 More Travis stuff: better go get, plus build badge 2014-08-30 00:10:33 +03:00
Vytautas Šaltenis
ff693ab487 Add a simple Travis config 2014-08-29 15:39:26 +03:00
Vytautas Šaltenis
74dee4bbbc Fixup tests after 67002b0 2014-08-29 15:26:37 +03:00