pandoc 1.8.0.3 → 1.8.1
raw patch · 12 files changed
+95/−38 lines, 12 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Text.Pandoc: writerAscii :: WriterOptions -> Bool
+ Text.Pandoc.Shared: writerAscii :: WriterOptions -> Bool
- Text.Pandoc: WriterOptions :: Bool -> String -> [(String, String)] -> String -> Int -> Bool -> HTMLSlideVariant -> Bool -> Bool -> HTMLMathMethod -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> ObfuscationMethod -> String -> FilePath -> Maybe FilePath -> CiteMethod -> [FilePath] -> Bool -> Bool -> Bool -> WriterOptions
+ Text.Pandoc: WriterOptions :: Bool -> String -> [(String, String)] -> String -> Int -> Bool -> HTMLSlideVariant -> Bool -> Bool -> HTMLMathMethod -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> ObfuscationMethod -> String -> FilePath -> Maybe FilePath -> CiteMethod -> [FilePath] -> Bool -> Bool -> Bool -> Bool -> WriterOptions
- Text.Pandoc.Shared: WriterOptions :: Bool -> String -> [(String, String)] -> String -> Int -> Bool -> HTMLSlideVariant -> Bool -> Bool -> HTMLMathMethod -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> ObfuscationMethod -> String -> FilePath -> Maybe FilePath -> CiteMethod -> [FilePath] -> Bool -> Bool -> Bool -> WriterOptions
+ Text.Pandoc.Shared: WriterOptions :: Bool -> String -> [(String, String)] -> String -> Int -> Bool -> HTMLSlideVariant -> Bool -> Bool -> HTMLMathMethod -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> ObfuscationMethod -> String -> FilePath -> Maybe FilePath -> CiteMethod -> [FilePath] -> Bool -> Bool -> Bool -> Bool -> WriterOptions
Files
- README +5/−0
- changelog +22/−0
- man/man1/pandoc.1 +7/−0
- pandoc.cabal +1/−1
- src/Text/Pandoc/Shared.hs +3/−1
- src/Text/Pandoc/UTF8.hs +3/−2
- src/Text/Pandoc/Writers/EPUB.hs +3/−0
- src/Text/Pandoc/Writers/HTML.hs +26/−20
- src/Text/Pandoc/Writers/LaTeX.hs +1/−1
- src/markdown2pdf.hs +9/−7
- src/pandoc.hs +14/−5
- tests/writer.latex +1/−1
README view
@@ -292,6 +292,11 @@ `--columns`=*NUMBER* : Specify length of lines in characters (for text wrapping). +`--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).+ `--email-obfuscation=`*none|javascript|references* : Specify a method for obfuscating `mailto:` links in HTML documents. *none* leaves `mailto:` links as they are. *javascript* obfuscates
changelog view
@@ -1,3 +1,25 @@+pandoc (1.8.1)++ * Added `--ascii` option. Currently supported only in HTML writer,+ which it causes to use numerical entities instead of UTF-8.++ * EPUB writer: `--toc` now works to provide a table of contents+ at the beginning of each chapter.++ * LaTeX writer: Change figure defaults to `htbp`.+ This prevents "too many unprocessed floats." Resolves+ Issue #285.++ * `Text.Pandoc.UTF8`: Encode filenames even when using recent+ base.++ * `markdown2pdf`: Fixed filename encoding issues. With help from Paulo+ Tanimoto. Resolves Issue #286.++ * HTML writer: Put line breaks in section divs.++ * `Text.Pandoc.Shared`: Make `writerSectionDivs` default to False.+ pandoc (1.8.0.3) * Fixed Source-repository stanza in cabal file.
man/man1/pandoc.1 view
@@ -345,6 +345,13 @@ .RS .RE .TP+.B \f[C]--ascii\f[]+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).+.RS+.RE+.TP .B \f[C]--email-obfuscation=\f[]\f[I]none|javascript|references\f[] Specify a method for obfuscating \f[C]mailto:\f[] links in HTML documents.
pandoc.cabal view
@@ -1,5 +1,5 @@ Name: pandoc-Version: 1.8.0.3+Version: 1.8.1 Cabal-Version: >= 1.6 Build-Type: Custom License: GPL
@@ -490,6 +490,7 @@ , writerHtml5 :: Bool -- ^ Produce HTML5 , writerChapters :: Bool -- ^ Use "chapter" for top-level sects , writerListings :: Bool -- ^ Use listings package for code+ , writerAscii :: Bool -- ^ Avoid non-ascii characters } deriving Show -- | Default writer options.@@ -507,7 +508,7 @@ , writerHTMLMathMethod = PlainMath , writerIgnoreNotes = False , writerNumberSections = False- , writerSectionDivs = True+ , writerSectionDivs = False , writerStrictMarkdown = False , writerReferenceLinks = False , writerWrapText = True@@ -522,6 +523,7 @@ , writerHtml5 = False , writerChapters = False , writerListings = False+ , writerAscii = False } --
src/Text/Pandoc/UTF8.hs view
@@ -44,15 +44,16 @@ import System.IO hiding (readFile, writeFile, getContents, putStr, putStrLn, hPutStr, hPutStrLn, hGetContents) import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn )+import Codec.Binary.UTF8.String (encodeString) import qualified System.IO as IO readFile :: FilePath -> IO String readFile f = do- h <- openFile f ReadMode+ h <- openFile (encodeString f) ReadMode hGetContents h writeFile :: FilePath -> String -> IO ()-writeFile f s = withFile f WriteMode $ \h -> hPutStr h s+writeFile f s = withFile (encodeString f) WriteMode $ \h -> hPutStr h s getContents :: IO String getContents = hGetContents stdin
src/Text/Pandoc/Writers/EPUB.hs view
@@ -276,6 +276,9 @@ , "$endfor$" , "$else$" , "<h1>$title$</h1>"+ , "$if(toc)$"+ , "$toc$"+ , "$endif$" , "$body$" , "$endif$" , "</body>"
src/Text/Pandoc/Writers/HTML.hs view
@@ -43,6 +43,7 @@ import Data.Maybe ( catMaybes ) import Control.Monad.State import Text.XHtml.Transitional hiding ( stringToHtml, unordList, ordList )+import qualified Text.XHtml.Transitional as XHtml import Text.TeXMath import Text.XML.Light.Output @@ -60,8 +61,10 @@ -- | Modified version of Text.XHtml's stringToHtml. -- Use unicode characters wherever possible.-stringToHtml :: String -> Html-stringToHtml = primHtml . escapeStringForXML+stringToHtml :: WriterOptions -> String -> Html+stringToHtml opts = if writerAscii opts+ then XHtml.stringToHtml+ else primHtml . escapeStringForXML -- | Hard linebreak. nl :: WriterOptions -> Html@@ -219,7 +222,7 @@ elementToListItem opts (Sec _ num id' headerText subsecs) = do let sectnum = if writerNumberSections opts then (thespan ! [theclass "toc-section-number"] << showSecNum num) +++- stringToHtml " "+ stringToHtml opts" " else noHtml txt <- liftM (sectnum +++) $ inlineListToHtml opts headerText subHeads <- mapM (elementToListItem opts) subsecs >>= return . catMaybes@@ -245,9 +248,11 @@ else if writerSectionDivs opts then if writerHtml5 opts then tag "section" ! [prefixedId opts id']- << intersperse (nl opts) stuff+ << (nl opts : (intersperse (nl opts) stuff+ ++ [nl opts])) else thediv ! [prefixedId opts id'] <<- intersperse (nl opts) stuff+ (nl opts : (intersperse (nl opts) stuff+ ++ [nl opts])) else toHtmlFromList $ intersperse (nl opts) stuff -- | Convert list of Note blocks to a footnote <div>.@@ -299,7 +304,7 @@ linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) +++ noscript (primHtml $ obfuscateString altText) _ -> error $ "Unknown obfuscation method: " ++ show meth- _ -> anchor ! [href s] $ stringToHtml txt -- malformed email+ _ -> anchor ! [href s] $ stringToHtml opts txt -- malformed email -- | Obfuscate character as entity. obfuscateChar :: Char -> String@@ -351,7 +356,7 @@ else unlines . lines in return $ pre ! attrs $ thecode << (replicate (length leadingBreaks) br +++- [stringToHtml $ addBird rawCode'])+ [stringToHtml opts $ addBird rawCode']) Right h -> modify (\st -> st{ stHighlighting = True }) >> return h blockToHtml opts (BlockQuote blocks) =@@ -377,7 +382,7 @@ secnum <- liftM stSecNum get let contents' = if writerNumberSections opts then (thespan ! [theclass "header-section-number"] << showSecNum secnum) +++- stringToHtml " " +++ contents+ stringToHtml opts " " +++ contents else contents let contents'' = if writerTableOfContents opts then anchor ! [href $ "#" ++ writerIdentifierPrefix opts ++ "TOC"] $ contents'@@ -510,19 +515,19 @@ inlineToHtml :: WriterOptions -> Inline -> State WriterState Html inlineToHtml opts inline = case inline of - (Str str) -> return $ stringToHtml str- (Space) -> return $ stringToHtml " "+ (Str str) -> return $ stringToHtml opts str+ (Space) -> return $ stringToHtml opts " " (LineBreak) -> return br- (EmDash) -> return $ stringToHtml "—"- (EnDash) -> return $ stringToHtml "–"- (Ellipses) -> return $ stringToHtml "…"- (Apostrophe) -> return $ stringToHtml "’"+ (EmDash) -> return $ stringToHtml opts "—"+ (EnDash) -> return $ stringToHtml opts "–"+ (Ellipses) -> return $ stringToHtml opts "…"+ (Apostrophe) -> return $ stringToHtml opts "’" (Emph lst) -> inlineListToHtml opts lst >>= return . emphasize (Strong lst) -> inlineListToHtml opts lst >>= return . strong (Code attr str) -> case highlightHtml True attr str of Left _ -> return $ thecode ! (attrsToHtml opts attr)- $ stringToHtml str+ $ stringToHtml opts str Right h -> return h (Strikeout lst) -> inlineListToHtml opts lst >>= return . (thespan ! [thestyle "text-decoration: line-through;"])@@ -532,10 +537,10 @@ (Subscript lst) -> inlineListToHtml opts lst >>= return . sub (Quoted quoteType lst) -> let (leftQuote, rightQuote) = case quoteType of- SingleQuote -> (stringToHtml "‘",- stringToHtml "’")- DoubleQuote -> (stringToHtml "“",- stringToHtml "”")+ SingleQuote -> (stringToHtml opts "‘",+ stringToHtml opts "’")+ DoubleQuote -> (stringToHtml opts "“",+ stringToHtml opts "”") in do contents <- inlineListToHtml opts lst return $ leftQuote +++ contents +++ rightQuote (Math t str) -> modify (\st -> st {stMath = True}) >> @@ -632,7 +637,8 @@ -- that block. Otherwise, insert a new Plain block with the backlink. let backlink = [RawInline "html" $ " <a href=\"#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref ++ "\" class=\"footnoteBackLink\"" ++- " title=\"Jump back to footnote " ++ ref ++ "\">↩</a>"]+ " title=\"Jump back to footnote " ++ ref ++ "\">" +++ (if writerAscii opts then "↩" else "↩") ++ "</a>"] blocks' = if null blocks then [] else let lastBlock = last blocks
src/Text/Pandoc/Writers/LaTeX.hs view
@@ -163,7 +163,7 @@ blockToLaTeX (Para [Image txt (src,tit)]) = do capt <- inlineListToLaTeX txt img <- inlineToLaTeX (Image txt (src,tit))- return $ "\\begin{figure}[htb]" $$ "\\centering" $$ img $$+ return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$ ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline blockToLaTeX (Para lst) = do result <- inlineListToLaTeX lst
src/markdown2pdf.hs view
@@ -14,11 +14,13 @@ import System.FilePath import System.Directory import System.Process (readProcessWithExitCode)-+import Codec.Binary.UTF8.String (decodeString, encodeString)+import Control.Monad (liftM) run :: FilePath -> [String] -> IO (Either String String) run file opts = do- (code, out, err) <- readProcessWithExitCode file opts ""+ (code, out, err) <- readProcessWithExitCode (encodeString file)+ (map encodeString opts) "" let msg = out ++ err case code of ExitFailure _ -> return $ Left $! msg@@ -122,30 +124,30 @@ saveStdin file = do text <- UTF8.getContents UTF8.writeFile file text- fileExist <- doesFileExist file+ fileExist <- doesFileExist (encodeString file) case fileExist of False -> return $ Left $! "Could not create " ++ file True -> return $ Right file saveOutput :: FilePath -> FilePath -> IO () saveOutput input output = do- copyFile input output+ copyFile (encodeString input) (encodeString output) UTF8.hPutStrLn stderr $! "Created " ++ output main :: IO () main = bracket -- acquire resource- (do dir <- getTemporaryDirectory+ (do dir <- return "testtmp" -- TODO -- getTemporaryDirectory let tmp = dir </> "pandoc" createDirectoryIfMissing True tmp return tmp) -- release resource- ( \tmp -> removeDirectoryRecursive tmp)+ ( \tmp -> return () )-- TODO -- removeDirectoryRecursive tmp) -- run computation $ \tmp -> do- args <- getArgs+ args <- liftM (map decodeString) getArgs -- check for invalid arguments and print help message if needed let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o","-V"] let goodoptslong = ["--from","--read","--strict",
src/pandoc.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2011 John MacFarlane <jgm@berkeley.edu> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@ {- | Module : Main- Copyright : Copyright (C) 2006-2010 John MacFarlane+ Copyright : Copyright (C) 2006-2011 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -55,7 +55,7 @@ import Codec.Binary.UTF8.String (decodeString, encodeString) copyrightMessage :: String-copyrightMessage = "\nCopyright (C) 2006-2010 John MacFarlane\n" +++copyrightMessage = "\nCopyright (C) 2006-2011 John MacFarlane\n" ++ "Web: http://johnmacfarlane.net/pandoc\n" ++ "This is free software; see the source for copying conditions. There is no\n" ++ "warranty, not even for merchantability or fitness for a particular purpose."@@ -123,6 +123,7 @@ , optBibliography :: [String] , optCslFile :: FilePath , optListings :: Bool -- ^ Use listings package for code blocks+ , optAscii :: Bool -- ^ Avoid using nonascii characters } -- | Defaults for command-line options.@@ -166,6 +167,7 @@ , optBibliography = [] , optCslFile = "" , optListings = False+ , optAscii = False } -- | A list of functions, each transforming the options data structure@@ -347,6 +349,11 @@ "NUMBER") "" -- "Length of line in characters" + , Option "" ["ascii"]+ (NoArg+ (\opt -> return opt { optAscii = True }))+ "" -- "Avoid using non-ascii characters in output"+ , Option "" ["email-obfuscation"] (ReqArg (\arg opt -> do@@ -681,7 +688,8 @@ , optBibliography = reffiles , optCslFile = cslfile , optCiteMethod = citeMethod- , optListings = listings + , optListings = listings+ , optAscii = ascii } = opts when dumpArgs $@@ -803,7 +811,8 @@ writerHtml5 = html5 && "html" `isPrefixOf` writerName', writerChapters = chapters, - writerListings = listings }+ writerListings = listings,+ writerAscii = ascii } when (isNonTextOutput writerName' && outputFile == "-") $ do UTF8.hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++
tests/writer.latex view
@@ -788,7 +788,7 @@ From ``Voyage dans la Lune'' by Georges Melies (1902): -\begin{figure}[htb]+\begin{figure}[htbp] \centering \includegraphics{lalune.jpg} \caption{lalune}