summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README5
-rw-r--r--changelog29
-rw-r--r--man/man1/pandoc.17
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Shared.hs4
-rw-r--r--src/Text/Pandoc/UTF8.hs5
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs3
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs46
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs2
-rw-r--r--src/markdown2pdf.hs12
-rw-r--r--src/pandoc.hs19
-rw-r--r--tests/writer.latex2
12 files changed, 100 insertions, 36 deletions
diff --git a/README b/README
index 897d8b000..d14fd8938 100644
--- a/README
+++ b/README
@@ -292,6 +292,11 @@ Options
`--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
diff --git a/changelog b/changelog
index dc2304e91..f8fb81887 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,32 @@
+pandoc (1.8.1.1)
+
+ * `markdown2pdf`: Removed some debugging lines accidentally included
+ in the 1.8.1 release. With those lines, the temp directory is created
+ in the working directory, and it is not deleted. This fix restores
+ the original behavior.
+
+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.
diff --git a/man/man1/pandoc.1 b/man/man1/pandoc.1
index 8ec58dd9a..0faf1cc00 100644
--- a/man/man1/pandoc.1
+++ b/man/man1/pandoc.1
@@ -345,6 +345,13 @@ Specify length of lines in characters (for text wrapping).
.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.
diff --git a/pandoc.cabal b/pandoc.cabal
index f2e403c63..039596391 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,5 +1,5 @@
Name: pandoc
-Version: 1.8.0.3
+Version: 1.8.1.1
Cabal-Version: >= 1.6
Build-Type: Custom
License: GPL
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 8326c89ae..c4bc66830 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -490,6 +490,7 @@ data WriterOptions = WriterOptions
, 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 @@ defaultWriterOptions =
, writerHTMLMathMethod = PlainMath
, writerIgnoreNotes = False
, writerNumberSections = False
- , writerSectionDivs = True
+ , writerSectionDivs = False
, writerStrictMarkdown = False
, writerReferenceLinks = False
, writerWrapText = True
@@ -522,6 +523,7 @@ defaultWriterOptions =
, writerHtml5 = False
, writerChapters = False
, writerListings = False
+ , writerAscii = False
}
--
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
index a77f92cdc..4af155882 100644
--- a/src/Text/Pandoc/UTF8.hs
+++ b/src/Text/Pandoc/UTF8.hs
@@ -44,15 +44,16 @@ where
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
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 33b8aa76a..c0cc815d4 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -276,6 +276,9 @@ pageTemplate = unlines
, "$endfor$"
, "$else$"
, "<h1>$title$</h1>"
+ , "$if(toc)$"
+ , "$toc$"
+ , "$endif$"
, "$body$"
, "$endif$"
, "</body>"
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index aba73a417..b3320fa06 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -43,6 +43,7 @@ import Data.List ( isPrefixOf, intersperse )
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 @@ defaultWriterState = WriterState {stNotes= [], stMath = False, stHighlighting =
-- | 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 _ (Blk _) = return Nothing
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 @@ elementToHtml opts (Sec level num id' title' elements) = do
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 @@ obfuscateLink opts txt s =
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 @@ blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
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 @@ blockToHtml opts (Header level lst) = do
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 @@ inlineListToHtml opts lst =
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 @@ inlineToHtml opts inline =
(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 @@ blockListToNote opts ref blocks =
-- 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 "&#8617;" else "↩") ++ "</a>"]
blocks' = if null blocks
then []
else let lastBlock = last blocks
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 28a1e7174..7dd736da4 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -163,7 +163,7 @@ blockToLaTeX (Plain lst) = inlineListToLaTeX lst
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
diff --git a/src/markdown2pdf.hs b/src/markdown2pdf.hs
index c61aaa8cb..005717bf0 100644
--- a/src/markdown2pdf.hs
+++ b/src/markdown2pdf.hs
@@ -14,11 +14,13 @@ import System.Exit (ExitCode (..), exitWith)
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,14 +124,14 @@ saveStdin :: FilePath -> IO (Either String FilePath)
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 ()
@@ -145,7 +147,7 @@ main = bracket
-- 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",
diff --git a/src/pandoc.hs b/src/pandoc.hs
index c0f457449..27e4579aa 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -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 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
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 Data.ByteString.Lazy.UTF8 (toString )
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 @@ data Opt = Opt
, 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 @@ defaultOpts = Opt
, optBibliography = []
, optCslFile = ""
, optListings = False
+ , optAscii = False
}
-- | A list of functions, each transforming the options data structure
@@ -347,6 +349,11 @@ options =
"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 @@ main = do
, optBibliography = reffiles
, optCslFile = cslfile
, optCiteMethod = citeMethod
- , optListings = listings
+ , optListings = listings
+ , optAscii = ascii
} = opts
when dumpArgs $
@@ -803,7 +811,8 @@ main = do
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" ++
diff --git a/tests/writer.latex b/tests/writer.latex
index e6adff585..ff6e9d58b 100644
--- a/tests/writer.latex
+++ b/tests/writer.latex
@@ -788,7 +788,7 @@ or here: <http://example.com/>
From ``Voyage dans la Lune'' by Georges Melies (1902):
-\begin{figure}[htb]
+\begin{figure}[htbp]
\centering
\includegraphics{lalune.jpg}
\caption{lalune}