From a55b2615a4a5d23822661f416417d71dcb58bd47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Fri, 1 Apr 2016 10:44:22 +0300 Subject: [PATCH] Run Smartypants as a separate pass over the AST Separate Smartypants somewhat from the HTML renderer. Move its flags from HtmlFlags to Extensions (probably should be moved to its own set of flags, but not now). With that done, do a separate walk of the tree and either run Smartypants processor if it's enabled, or simply escape text nodes. --- block_test.go | 4 +-- html.go | 94 +++++++++++++++++++------------------------------- inline_test.go | 20 +++++------ markdown.go | 52 ++++++++++++++++------------ ref_test.go | 2 +- smartypants.go | 28 ++++++++++++++- 6 files changed, 104 insertions(+), 96 deletions(-) diff --git a/block_test.go b/block_test.go index 06d5b5d..2f1616c 100644 --- a/block_test.go +++ b/block_test.go @@ -23,13 +23,13 @@ func runMarkdownBlockWithRenderer(input string, extensions Extensions, renderer } func runMarkdownBlock(input string, extensions Extensions) string { - renderer := HtmlRenderer(UseXHTML, "", "") + renderer := HtmlRenderer(UseXHTML, extensions, "", "") return runMarkdownBlockWithRenderer(input, extensions, renderer) } func runnerWithRendererParameters(parameters HtmlRendererParameters) func(string, Extensions) string { return func(input string, extensions Extensions) string { - renderer := HtmlRendererWithParameters(UseXHTML, "", "", parameters) + renderer := HtmlRendererWithParameters(UseXHTML, extensions, "", "", parameters) return runMarkdownBlockWithRenderer(input, extensions, renderer) } } diff --git a/html.go b/html.go index d5c8123..9433072 100644 --- a/html.go +++ b/html.go @@ -29,25 +29,20 @@ type HtmlFlags int // HTML renderer configuration options. const ( - HtmlFlagsNone HtmlFlags = 0 - SkipHTML HtmlFlags = 1 << iota // Skip preformatted HTML blocks - SkipStyle // Skip embedded