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
2 files changed,
24 insertions(+),
18 deletions(-)
M
inline_test.go
→
inline_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.go
→
markdown.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.