pandoc 2.0 → 2.0.0.1
raw patch · 8 files changed
+120/−45 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- AUTHORS.md +0/−1
- changelog +24/−0
- pandoc.cabal +1/−1
- src/Text/Pandoc/App.hs +1/−1
- src/Text/Pandoc/Readers/LaTeX.hs +19/−9
- src/Text/Pandoc/Writers/EPUB.hs +49/−33
- test/command/4007.md +23/−0
- trypandoc/index.html +3/−0
AUTHORS.md view
@@ -179,7 +179,6 @@ - bumper314 - csforste - d-dorazio-- hftf - iandol - infinity0x - lwolfsonkin
changelog view
@@ -1,3 +1,27 @@+pandoc (2.0.0.1)++ * EPUB writer:++ + Fixed filepaths for nonstandard epub-subdirectory values.+ + Ensure that epub2 is recognized as a non-text format,+ so that a template is used.+ + Don't include "prefix" attribute for ibooks for epub2.+ It doesn't validate.+ + Fix stylesheet paths; previously we had an incorrect+ stylesheet path for the cover page and nav page.++ * LaTeX reader:++ + Insert space when needed in macro expansion (#4007).+ Sometimes we need to insert a space after a control sequence+ to prevent it merging with a following letter.+ + Allow unbraced arguments for macros (#4007).+ + Allow body of macro definition to be unbraced (#4007).++ * Linux package build: ensure that pandoc-citeproc is statically linked.++ * trypandoc: add native, ms.+ pandoc (2.0) [new features]
pandoc.cabal view
@@ -1,5 +1,5 @@ name: pandoc-version: 2.0+version: 2.0.0.1 cabal-version: >= 1.10 build-type: Custom license: GPL
src/Text/Pandoc/App.hs view
@@ -535,7 +535,7 @@ type Transform = Pandoc -> Pandoc isTextFormat :: String -> Bool-isTextFormat s = s `notElem` ["odt","docx","epub","epub3"]+isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub"] externalFilter :: MonadIO m => ReaderOptions -> FilePath -> [String] -> Pandoc -> m Pandoc
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -430,7 +430,7 @@ Nothing -> return () Just (Macro expansionPoint numargs optarg newtoks) -> do setInput ts- let getarg = spaces >> braced+ let getarg = try $ spaces >> bracedOrToken args <- case optarg of Nothing -> count numargs getarg Just o ->@@ -438,7 +438,14 @@ <*> count (numargs - 1) getarg let addTok (Tok _ (Arg i) _) acc | i > 0 , i <= numargs =- map (setpos spos) (args !! (i - 1)) ++ acc+ foldr addTok acc (args !! (i - 1))+ -- add space if needed after control sequence+ -- see #4007+ addTok (Tok _ (CtrlSeq x) txt)+ acc@(Tok _ Word _ : _)+ | not (T.null txt) &&+ (isLetter (T.last txt)) =+ Tok spos (CtrlSeq x) (txt <> " ") : acc addTok t acc = setpos spos t : acc ts' <- getInput setInput $ foldr addTok ts' newtoks@@ -1824,7 +1831,7 @@ Tok _ (CtrlSeq name) _ <- anyControlSeq optional $ symbol '=' spaces- contents <- braced <|> ((:[]) <$> (anyControlSeq <|> singleChar))+ contents <- bracedOrToken return (name, Macro ExpandWhenDefined 0 Nothing contents) defmacro :: PandocMonad m => LP m (Text, Macro)@@ -1832,7 +1839,9 @@ controlSeq "def" Tok _ (CtrlSeq name) _ <- anyControlSeq numargs <- option 0 $ argSeq 1- contents <- withVerbatimMode braced+ -- we use withVerbatimMode, because macros are to be expanded+ -- at point of use, not point of definition+ contents <- withVerbatimMode bracedOrToken return (name, Macro ExpandWhenUsed numargs Nothing contents) -- Note: we don't yet support fancy things like #1.#2@@ -1846,6 +1855,9 @@ isArgTok (Tok _ (Arg _) _) = True isArgTok _ = False +bracedOrToken :: PandocMonad m => LP m [Tok]+bracedOrToken = braced <|> ((:[]) <$> (anyControlSeq <|> singleChar))+ newcommand :: PandocMonad m => LP m (Text, Macro) newcommand = do pos <- getPosition@@ -1861,9 +1873,7 @@ spaces optarg <- option Nothing $ Just <$> try bracketedToks spaces- contents <- withVerbatimMode braced- -- we use withVerbatimMode, because macros are to be expanded- -- at point of use, not point of definition+ contents <- withVerbatimMode bracedOrToken when (mtype == "newcommand") $ do macros <- sMacros <$> getState case M.lookup name macros of@@ -1885,9 +1895,9 @@ spaces optarg <- option Nothing $ Just <$> try bracketedToks spaces- startcontents <- withVerbatimMode braced+ startcontents <- withVerbatimMode bracedOrToken spaces- endcontents <- withVerbatimMode braced+ endcontents <- withVerbatimMode bracedOrToken when (mtype == "newenvironment") $ do macros <- sMacros <$> getState case M.lookup name macros of
src/Text/Pandoc/Writers/EPUB.hs view
@@ -43,7 +43,7 @@ import Data.Char (isAlphaNum, isAscii, isDigit, toLower) import Data.List (intercalate, isInfixOf, isPrefixOf) import qualified Data.Map as M-import Data.Maybe (fromMaybe, isNothing, mapMaybe)+import Data.Maybe (fromMaybe, isNothing, mapMaybe, isJust) import qualified Data.Set as Set import qualified Data.Text as TS import qualified Data.Text.Lazy as TL@@ -382,6 +382,10 @@ -- sanity check on epubSubdir unless (all (\c -> isAscii c && isAlphaNum c) epubSubdir) $ throwError $ PandocEpubSubdirectoryError epubSubdir+ let inSubdir f = if null epubSubdir+ then f+ else epubSubdir ++ "/" ++ f+ let epub3 = version == EPUB3 let writeHtml o = fmap (UTF8.fromTextLazy . TL.fromStrict) . writeHtmlStringForEPUB version o@@ -399,8 +403,15 @@ stylesheets [(1 :: Int)..] let vars = ("epub3", if epub3 then "true" else "false")- : map (\e -> ("css", "../" ++ eRelativePath e)) stylesheetEntries- ++ [(x,y) | (x,y) <- writerVariables opts, x /= "css"]+ : [(x,y) | (x,y) <- writerVariables opts, x /= "css"]++ let cssvars useprefix = map (\e -> ("css",+ (if useprefix && not (null epubSubdir)+ then "../"+ else "")+ ++ eRelativePath e))+ stylesheetEntries+ let opts' = opts{ writerEmailObfuscation = NoObfuscation , writerSectionDivs = True , writerVariables = vars@@ -417,7 +428,9 @@ Just img -> do let coverImage = "media/" ++ takeFileName img cpContent <- lift $ writeHtml- opts'{ writerVariables = ("coverpage","true"):vars }+ opts'{ writerVariables =+ ("coverpage","true"):+ cssvars False ++ vars } (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"]) imgContent <- lift $ P.readFileLazy img return ( [mkEntry "cover.xhtml" cpContent]@@ -425,9 +438,10 @@ -- title page tpContent <- lift $ writeHtml opts'{- writerVariables = ("titlepage","true"):vars }+ writerVariables = ("titlepage","true"):+ cssvars True ++ vars } (Pandoc meta [])- let tpEntry = mkEntry "text/title_page.xhtml" tpContent+ let tpEntry = mkEntry (inSubdir "title_page.xhtml") tpContent -- handle pictures -- mediaRef <- P.newIORef []@@ -526,14 +540,15 @@ chapters' let chapToEntry num (Chapter mbnum bs) =- mkEntry ("text/" ++ showChapter num) <$>- writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum } (case bs of- (Header _ _ xs : _) ->- -- remove notes or we get doubled footnotes- Pandoc (setMeta "title" (walk removeNote $ fromList xs)- nullMeta) bs- _ ->- Pandoc nullMeta bs)+ mkEntry (inSubdir (showChapter num)) <$>+ writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum+ , writerVariables = cssvars True ++ vars }+ (case bs of+ (Header _ _ xs : _) ->+ -- remove notes or we get doubled footnotes+ Pandoc (setMeta "title" (walk removeNote $ fromList xs)+ nullMeta) bs+ _ -> Pandoc nullMeta bs) chapterEntries <- lift $ zipWithM chapToEntry [1..] chapters @@ -579,12 +594,14 @@ [] -> throwError $ PandocShouldNeverHappenError "epubIdentifier is null" -- shouldn't happen currentTime <- lift P.getCurrentTime let contentsData = UTF8.fromStringLazy $ ppTopElement $- unode "package" ! [("version", case version of- EPUB2 -> "2.0"- EPUB3 -> "3.0")- ,("xmlns","http://www.idpf.org/2007/opf")- ,("unique-identifier","epub-id-1")- ,("prefix","ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/")] $+ unode "package" !+ ([("version", case version of+ EPUB2 -> "2.0"+ EPUB3 -> "3.0")+ ,("xmlns","http://www.idpf.org/2007/opf")+ ,("unique-identifier","epub-id-1")+ ] +++ [("prefix","ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/") | version == EPUB3]) $ [ metadataElement version metadata currentTime , unode "manifest" $ [ unode "item" ! [("id","ncx"), ("href","toc.ncx")@@ -625,7 +642,10 @@ ("href","nav.xhtml")] $ () ] ++ [ unode "reference" !- [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | epubCoverImage metadata /= Nothing+ [("type","cover")+ ,("title","Cover")+ ,("href","cover.xhtml")] $ ()+ | isJust (epubCoverImage metadata) ] ] let contentsEntry = mkEntry "content.opf" contentsData@@ -661,12 +681,13 @@ navMapFormatter n tit src subs = unode "navPoint" ! [("id", "navPoint-" ++ show n)] $ [ unode "navLabel" $ unode "text" $ stringify tit- , unode "content" ! [("src", "text/" ++ src)] $ ()+ , unode "content" ! [("src", inSubdir src)] $ () ] ++ subs let tpNode = unode "navPoint" ! [("id", "navPoint-0")] $ [ unode "navLabel" $ unode "text" (stringify $ docTitle' meta)- , unode "content" ! [("src","text/title_page.xhtml")] $ () ]+ , unode "content" ! [("src", inSubdir "title_page.xhtml")]+ $ () ] navMap <- lift $ evalStateT (mapM (navPointNode navMapFormatter) secs) 1 let tocData = UTF8.fromStringLazy $ ppTopElement $@@ -694,8 +715,8 @@ let navXhtmlFormatter :: Int -> [Inline] -> String -> [Element] -> Element navXhtmlFormatter n tit src subs = unode "li" ! [("id", "toc-li-" ++ show n)] $- (unode "a" ! [("href", "text/" ++- src)]+ (unode "a" !+ [("href", inSubdir src)] $ titElements) : case subs of [] -> []@@ -741,10 +762,7 @@ ] else [] navData <- lift $ writeHtml opts'{ writerVariables = ("navpage","true"):- -- remove the leading ../ from stylesheet paths:- map (\(k,v) -> if k == "css"- then (k, drop 3 v)- else (k, v)) vars }+ cssvars False ++ vars } (Pandoc (setMeta "title" (walk removeNote $ fromList $ docTitle' meta) nullMeta) (navBlocks ++ landmarks))@@ -758,8 +776,7 @@ unode "container" ! [("version","1.0") ,("xmlns","urn:oasis:names:tc:opendocument:xmlns:container")] $ unode "rootfiles" $- unode "rootfile" ! [("full-path",- epubSubdir ++ ['/' | not (null epubSubdir)] ++ "content.opf")+ unode "rootfile" ! [("full-path", inSubdir "content.opf") ,("media-type","application/oebps-package+xml")] $ () let containerEntry = mkEntry "META-INF/container.xml" containerData @@ -771,8 +788,7 @@ let appleEntry = mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple let addEpubSubdir :: Entry -> Entry- addEpubSubdir e = e{ eRelativePath =- epubSubdir ++ ['/' | not (null epubSubdir)] ++ eRelativePath e }+ addEpubSubdir e = e{ eRelativePath = inSubdir (eRelativePath e) } -- construct archive let archive = foldr addEntryToArchive emptyArchive $ [mimetypeEntry, containerEntry, appleEntry] ++
+ test/command/4007.md view
@@ -0,0 +1,23 @@+```+pandoc -f latex -t native+\newcommand\arrow\to+$a\arrow b$+^D+[Para [Math InlineMath "a\\to b"]]+```++```+pandoc -f latex -t native+\newcommand\pfeil[1]{\to #1}+$a\pfeil b$+^D+[Para [Math InlineMath "a\\to b"]]+```++```+pandoc -f latex -t native+\newcommand\fleche{\to}+$a\fleche b$+^D+[Para [Math InlineMath "a\\to b"]]+```
trypandoc/index.html view
@@ -91,6 +91,7 @@ <option value="markdown_strict">Markdown (strict)</option> <option value="mediawiki">MediaWiki</option> <option value="muse">Muse</option>+ <option value="native">Native (Pandoc AST)</option> <option value="opml">OPML</option> <option value="org">Org Mode</option> <option value="rst">reStructuredText</option>@@ -126,12 +127,14 @@ <option value="json">JSON</option> <option value="latex">LaTeX</option> <option value="man">Groff man</option>+ <option value="ms">Groff ms</option> <option value="markdown">Markdown (pandoc)</option> <option value="markdown_mmd">MultiMarkdown</option> <option value="markdown_phpextra">Markdown (PHP Markdown Extra)</option> <option value="markdown_strict">Markdown (strict)</option> <option value="mediawiki">MediaWiki</option> <option value="muse">Muse</option>+ <option value="native">Native (Pandoc AST)</option> <option value="opendocument">OpenDocument</option> <option value="opml">OPML</option> <option value="org">Org Mode</option>