Commit Graph

364 Commits

Author SHA1 Message Date
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
Vytautas Šaltenis
9328516bb9 Merge pull request #109 from tummychow/html5-code-block
Use HTML5 recommended style of language on code blocks
2014-08-29 12:20:42 +03:00
tummychow
67002b01b6 Use HTML5 recommended style of language on code blocks
For code blocks that contain a certain language of code, the recommended
attribute structure is <pre><code class="language-foo">. This also
corresponds to the behavior expected by various JS syntax highlighters.

The GitHub code block implementation was obsolete, and identical to the
normal implementation except for its attribute structure, so it was
removed.

Closes #108.
2014-08-28 18:01:06 -04:00
Vytautas Šaltenis
7dd925f93d Merge pull request #107 from shurcooL/master
Improve parser to detect LineBreak independently of renderer.
2014-08-27 10:28:42 +03: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
52f7a2a7b0 Fix misleading wording in README
Fixes #103.
2014-08-21 14:05:37 +03:00
Vytautas Šaltenis
2e7d690972 Merge pull request #98 from cpuguy83/master
Add titleblock support
2014-08-04 23:02:18 +03:00
Brian Goff
539b27a624 Add titleblock support 2014-08-04 14:08:22 -04:00
Vytautas Šaltenis
8b4c144eda Merge pull request #95 from anonx/master
Whitelisted th and td to fix #79
2014-07-22 17:00:57 +03:00
anonx
86bc6131df Whitelisted th and td to fix #79 2014-07-22 19:34:23 +06:00
Vytautas Šaltenis
c7617b05ad Merge pull request #93 from shurcooL/patch-1
Add a reference to github_flavored_markdown in README.
2014-07-09 16:25:33 +03:00
Dmitri Shuralyov
51cf25db16 Add a reference to github_flavored_markdown in README. 2014-07-04 18:10:34 -07:00
Vytautas Šaltenis
7680f7fdeb Merge pull request #88 from dimfeld/master
Remove unnecessary HTML_ABSOLUTE_LINKS flag
2014-05-30 10:30:05 +03:00
Daniel Imfeld
5bf00efe39 Remove unnecessary HTML_ABSOLUTE_LINKS flag 2014-05-29 09:17:20 -05:00
Vytautas Šaltenis
3c2ae1d185 Merge pull request #86 from dimfeld/master
Add absolute link transformation and footnote enhancements
2014-05-29 16:13:04 +03:00
Daniel Imfeld
10f1dc6358 Fix spelling error 2014-05-28 23:52:45 -05:00
Daniel Imfeld
4ccf982a9e Add tests for absolute prefix 2014-05-25 13:22:33 -05:00
Daniel Imfeld
2ce0592896 Add tests for new footnote functionality 2014-05-25 13:07:05 -05:00
Daniel Imfeld
628c02d37b Move footnote prefix to a better place 2014-05-24 14:28:37 -05:00
Daniel Imfeld
c7f4b178c2 Use parameters object for extra options. Enhance footnote support.
Option to add return links.
Option to make footnote prefixes unique, for rendering multiple
documents per page.
2014-05-24 13:29:39 -05: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
Vytautas Šaltenis
03a690ac55 Merge pull request #82 from dimfeld/master
Sanitize shouldn't filter out URLs without protocol.
2014-05-16 12:10:22 +03:00
Daniel Imfeld
e10ba88263 Sanitize shouldn't filter out URLs without protocol. 2014-05-16 03:28:44 -05:00
Russ Ross
93aad334f4 Update README.md
link to markdownfmt, add note about LaTeX output
2014-05-14 13:27:37 -06:00
Vytautas Šaltenis
bb14a3f92a Merge pull request #78 from JeffPaine/patch-1
Add Usage heading to README
2014-05-09 11:07:21 +03:00
Jeff Paine
d55bbf4b7b Add Usage heading 2014-05-08 18:42:05 -04:00
Vytautas Šaltenis
f3ab1849e6 Merge pull request #39 from athom/tilde-escape
allow \~ to escape as ~
2014-05-03 16:01:58 +03:00