diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-05 14:58:55 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-05 14:58:55 -0800 |
commit | bec9485d93ebcdb3d33f5c43cad09f86acb06d1d (patch) | |
tree | f3aa891a4661934ba6c924940a1b232bf4e0557d | |
parent | 550b931c3cf3ece7226b98aa0547efb3facdd816 (diff) | |
download | pandoc-bec9485d93ebcdb3d33f5c43cad09f86acb06d1d.tar.gz |
Re-added the --ascii option.
Now it is implemented in pandoc.hs, not in the HTML writer.
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | changelog | 3 | ||||
-rw-r--r-- | src/pandoc.hs | 23 |
3 files changed, 23 insertions, 8 deletions
@@ -333,6 +333,11 @@ 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.) +`--ascii` +: Use only ascii characters in output. Currently supported only + for HTML output (which uses numerical entities instead of + UTF-8 when this option is selected). + `--reference-links` : Use reference-style links, rather than inline links, in writing markdown or reStructuredText. By default inline links are used. @@ -178,9 +178,6 @@ pandoc (1.9) * `'` is no longer escaped in HTML output. It does not need to be escaped outside of attributes. - * The `--ascii` option has been removed, because of differences - in blaze-html's and xhtml's escaping. - * Pandoc will no longer transform leading newlines in code blocks to `<br/>` tags. diff --git a/src/pandoc.hs b/src/pandoc.hs index aa166b7e3..2c9f2ffb8 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -134,6 +134,7 @@ data Opt = Opt , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf , optSlideLevel :: Maybe Int -- ^ Header level that creates slides , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2 + , optAscii :: Bool -- ^ Use ascii characters only in html } -- | Defaults for command-line options. @@ -185,6 +186,7 @@ defaultOpts = Opt , optLaTeXEngine = "pdflatex" , optSlideLevel = Nothing , optSetextHeaders = True + , optAscii = False } -- | A list of functions, each transforming the options data structure @@ -412,6 +414,11 @@ options = return opt { optHtml5 = True })) "" -- "Produce HTML5 in HTML output" + , Option "" ["ascii"] + (NoArg + (\opt -> return opt { optAscii = True })) + "" -- "Use ascii characters only in HTML output" + , Option "" ["reference-links"] (NoArg (\opt -> return opt { optReferenceLinks = True } )) @@ -796,6 +803,7 @@ main = do , optLaTeXEngine = latexEngine , optSlideLevel = slideLevel , optSetextHeaders = setextHeaders + , optAscii = ascii } = opts when dumpArgs $ @@ -1027,10 +1035,15 @@ main = do case res of Right pdf -> writeBinary pdf Left err' -> err 43 $ toString err' - Just r -> writerFn outputFile =<< postProcess result + Just r + | htmlFormat && ascii -> + writerFn outputFile =<< selfcontain (toEntities result) + | otherwise -> + writerFn outputFile =<< selfcontain result where result = r writerOptions doc2 ++ ['\n' | not standalone'] - htmlFormats = ["html","html+lhs","html5","html5+lhs", + htmlFormat = writerName' `elem` + ["html","html+lhs","html5","html5+lhs", "s5","slidy","dzslides"] - postProcess = if selfContained && writerName' `elem` htmlFormats - then makeSelfContained datadir - else return + selfcontain = if selfContained && htmlFormat + then makeSelfContained datadir + else return |