git.iko.soy/typeable/pandoc
on master help sign in
Re-added the --ascii option.

Now it is implemented in pandoc.hs, not in the HTML writer.

commitbec9485d93ebcdb3d33f5c43cad09f86acb06d1d authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 5 Feb 2012, 14:58 (15 years ago) parent550b931
3 files changed+23−8
README+5 changelog−3 src/pandoc.hs+18−5
README+5
@@ -333,6 +333,11 @@ Options affecting specific writers
333333: Produce HTML5 instead of HTML4. This option has no effect for writers
334334 other than `html`. (*Deprecated:* Use the `html5` output format instead.)
335335
336+`--ascii`
337+: Use only ascii characters in output. Currently supported only
338+ for HTML output (which uses numerical entities instead of
339+ UTF-8 when this option is selected).
340+
336341`--reference-links`
337342: Use reference-style links, rather than inline links, in writing markdown
338343 or reStructuredText. By default inline links are used.
changelog−3
@@ -178,9 +178,6 @@ pandoc (1.9)
178178 * `'` is no longer escaped in HTML output. It does not need to be
179179 escaped outside of attributes.
180180
181− * The `--ascii` option has been removed, because of differences
182− in blaze-html's and xhtml's escaping.
183−
184181 * Pandoc will no longer transform leading newlines in code
185182 blocks to `<br/>` tags.
186183
src/pandoc.hs+18−5
@@ -134,6 +134,7 @@ data Opt = Opt
134134 , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
135135 , optSlideLevel :: Maybe Int -- ^ Header level that creates slides
136136 , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2
137+ , optAscii :: Bool -- ^ Use ascii characters only in html
137138 }
138139
139140-- | Defaults for command-line options.
@@ -185,6 +186,7 @@ defaultOpts = Opt
185186 , optLaTeXEngine = "pdflatex"
186187 , optSlideLevel = Nothing
187188 , optSetextHeaders = True
189+ , optAscii = False
188190 }
189191
190192-- | A list of functions, each transforming the options data structure
@@ -412,6 +414,11 @@ options =
412414 return opt { optHtml5 = True }))
413415 "" -- "Produce HTML5 in HTML output"
414416
417+ , Option "" ["ascii"]
418+ (NoArg
419+ (\opt -> return opt { optAscii = True }))
420+ "" -- "Use ascii characters only in HTML output"
421+
415422 , Option "" ["reference-links"]
416423 (NoArg
417424 (\opt -> return opt { optReferenceLinks = True } ))
@@ -796,6 +803,7 @@ main = do
796803 , optLaTeXEngine = latexEngine
797804 , optSlideLevel = slideLevel
798805 , optSetextHeaders = setextHeaders
806+ , optAscii = ascii
799807 } = opts
800808
801809 when dumpArgs $
@@ -1027,10 +1035,15 @@ main = do
10271035 case res of
10281036 Right pdf -> writeBinary pdf
10291037 Left err' -> err 43 $ toString err'
1030− Just r -> writerFn outputFile =<< postProcess result
1038+ Just r
1039+ | htmlFormat && ascii ->
1040+ writerFn outputFile =<< selfcontain (toEntities result)
1041+ | otherwise ->
1042+ writerFn outputFile =<< selfcontain result
10311043 where result = r writerOptions doc2 ++ ['\n' | not standalone']
1032− htmlFormats = ["html","html+lhs","html5","html5+lhs",
1044+ htmlFormat = writerName' `elem`
1045+ ["html","html+lhs","html5","html5+lhs",
10331046 "s5","slidy","dzslides"]
1034− postProcess = if selfContained && writerName' `elem` htmlFormats
1035− then makeSelfContained datadir
1036− else return
1047+ selfcontain = if selfContained && htmlFormat
1048+ then makeSelfContained datadir
1049+ else return