From eebed6bc48c2e1b8c2da2e5b198e0164f76c0ab5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 15 Jan 2013 18:50:36 -0800 Subject: [PATCH] Added `writerHtmlQTags` and `--html-q-tags` option. The previous default was to use `` tags in HTML5. But `` tags are also valid HTML4, and they are not very robust in HTML5. Some user agents don't support them, and some CSS resets prevent pandoc's quotes CSS from working properly (e.g. bootstrap). It seems a better default just to insert quote characters, but the option is provided for those who have gotten used to using `` tags. --- README | 3 +++ data/templates | 2 +- pandoc.hs | 10 ++++++++++ src/Text/Pandoc/Options.hs | 2 ++ src/Text/Pandoc/Writers/HTML.hs | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README b/README index 615b0c7b9..bd252ac13 100644 --- a/README +++ b/README @@ -359,6 +359,9 @@ Options affecting specific writers : Produce HTML5 instead of HTML4. This option has no effect for writers other than `html`. (*Deprecated:* Use the `html5` output format instead.) +`--html-q-tags` +: Use `` tags for quotes in HTML. + `--ascii` : Use only ascii characters in output. Currently supported only for HTML output (which uses numerical entities instead of diff --git a/data/templates b/data/templates index b49608bf9..25386101d 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit b49608bf92ad66f255cd3371da834ddb7bee5211 +Subproject commit 25386101d5428eedca69089ab8e5373f0a079bff diff --git a/pandoc.hs b/pandoc.hs index 20278d2d0..61499ad69 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -105,6 +105,7 @@ data Opt = Opt , optSmart :: Bool -- ^ Use smart typography , optOldDashes :: Bool -- ^ Parse dashes like pandoc <=1.8.2.1 , optHtml5 :: Bool -- ^ Produce HTML5 in HTML + , optHtmlQTags :: Bool -- ^ Use tags in HTML , optHighlight :: Bool -- ^ Highlight source code , optHighlightStyle :: Style -- ^ Style to use for highlighted code , optChapters :: Bool -- ^ Use chapter for top-level sects @@ -159,6 +160,7 @@ defaultOpts = Opt , optSmart = False , optOldDashes = False , optHtml5 = False + , optHtmlQTags = False , optHighlight = True , optHighlightStyle = pygments , optChapters = False @@ -431,6 +433,12 @@ options = return opt { optHtml5 = True })) "" -- "Produce HTML5 in HTML output" + , Option "" ["html-q-tags"] + (NoArg + (\opt -> do + return opt { optHtmlQTags = True })) + "" -- "Use tags for quotes in HTML" + , Option "" ["ascii"] (NoArg (\opt -> return opt { optAscii = True })) @@ -816,6 +824,7 @@ main = do , optSmart = smart , optOldDashes = oldDashes , optHtml5 = html5 + , optHtmlQTags = htmlQTags , optHighlight = highlight , optHighlightStyle = highlightStyle , optChapters = chapters @@ -1009,6 +1018,7 @@ main = do writerSourceDirectory = sourceDir, writerUserDataDir = datadir, writerHtml5 = html5, + writerHtmlQTags = htmlQTags, writerChapters = chapters, writerListings = listings, writerBeamer = False, diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 0471161e0..c659b652d 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -262,6 +262,7 @@ data WriterOptions = WriterOptions , writerCiteMethod :: CiteMethod -- ^ How to print cites , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations , writerHtml5 :: Bool -- ^ Produce HTML5 + , writerHtmlQTags :: Bool -- ^ Use @@ tags for quotes in HTML , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show , writerSlideLevel :: Maybe Int -- ^ Force header level of slides , writerChapters :: Bool -- ^ Use "chapter" for top-level sects @@ -303,6 +304,7 @@ instance Default WriterOptions where , writerCiteMethod = Citeproc , writerBiblioFiles = [] , writerHtml5 = False + , writerHtmlQTags = False , writerBeamer = False , writerSlideLevel = Nothing , writerChapters = False diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 3b9a1eae6..3111cbecb 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -618,7 +618,7 @@ inlineToHtml opts inline = strToHtml "’") DoubleQuote -> (strToHtml "“", strToHtml "”") - in if writerHtml5 opts + in if writerHtmlQTags opts then do modify $ \st -> st{ stQuotes = True } H.q `fmap` inlineListToHtml opts lst