all repos — grayfriday @ 05b8cefd6a3cd87b81adb83479f5faadc0df2a67

blackfriday fork with a few changes

Merge pull request #118 from rtfb/test-relative-links

Make sure relative URLs are preserved
Vytautas Ĺ altenis vytas@rtfb.lt
Mon, 22 Sep 2014 11:58:14 +0300
commit

05b8cefd6a3cd87b81adb83479f5faadc0df2a67

parent

64fbfbbadf651c943c4dec8e28c9ac20d973fad7

2 files changed, 24 insertions(+), 18 deletions(-)

jump to
M inline_test.goinline_test.go

@@ -42,6 +42,7 @@ prefix := "http://localhost"

params := HtmlRendererParameters{AbsolutePrefix: prefix} transformTests := transformLinks(tests, prefix) doTestsInlineParam(t, transformTests, 0, 0, params) + doTestsInlineParam(t, transformTests, 0, commonHtmlFlags, params) } func doSafeTestsInline(t *testing.T, tests []string) {

@@ -353,6 +354,12 @@ "<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n",

"![foo with a title](/bar/ title with no quotes)\n", "<p><img src=\"/bar/ title with no quotes\" alt=\"foo with a title\" />\n</p>\n", + + "![](img.jpg)\n", + "<p><img src=\"img.jpg\" alt=\"\" />\n</p>\n", + + "[link](url)\n", + "<p><a href=\"url\">link</a></p>\n", "![foo]()\n", "<p>![foo]()</p>\n",
M markdown.gomarkdown.go

@@ -41,6 +41,21 @@ EXTENSION_FOOTNOTES // Pandoc-style footnotes

EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK // No need to insert an empty line to start a (code, quote, order list, unorder list)block EXTENSION_HEADER_IDS // specify header IDs with {#id} EXTENSION_TITLEBLOCK // Titleblock ala pandoc + + commonHtmlFlags = 0 | + HTML_USE_XHTML | + HTML_USE_SMARTYPANTS | + HTML_SMARTYPANTS_FRACTIONS | + HTML_SMARTYPANTS_LATEX_DASHES + + commonExtensions = 0 | + EXTENSION_NO_INTRA_EMPHASIS | + EXTENSION_TABLES | + EXTENSION_FENCED_CODE | + EXTENSION_AUTOLINK | + EXTENSION_STRIKETHROUGH | + EXTENSION_SPACE_HEADERS | + EXTENSION_HEADER_IDS ) // These are the possible flag values for the link renderer.

@@ -233,24 +248,8 @@ //

// * Custom Header IDs func MarkdownCommon(input []byte) []byte { // set up the HTML renderer - htmlFlags := 0 - htmlFlags |= HTML_USE_XHTML - htmlFlags |= HTML_USE_SMARTYPANTS - htmlFlags |= HTML_SMARTYPANTS_FRACTIONS - htmlFlags |= HTML_SMARTYPANTS_LATEX_DASHES - renderer := HtmlRenderer(htmlFlags, "", "") - - // set up the parser - extensions := 0 - extensions |= EXTENSION_NO_INTRA_EMPHASIS - extensions |= EXTENSION_TABLES - extensions |= EXTENSION_FENCED_CODE - extensions |= EXTENSION_AUTOLINK - extensions |= EXTENSION_STRIKETHROUGH - extensions |= EXTENSION_SPACE_HEADERS - extensions |= EXTENSION_HEADER_IDS - - return Markdown(input, renderer, extensions) + renderer := HtmlRenderer(commonHtmlFlags, "", "") + return Markdown(input, renderer, commonExtensions) } // Markdown is the main rendering function.