From 6a235ba60693596af3f13b093b83defa37501e09 Mon Sep 17 00:00:00 2001 From: Alexander Kondratskiy Date: Sat, 13 Jul 2013 02:23:27 -0400 Subject: Checking options before applying syntax highlighting for HTML output --- src/Text/Pandoc/Writers/HTML.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 57bf2a349..cfc187e02 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -422,7 +422,10 @@ blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do adjCode = if tolhs then unlines . map ("> " ++) . lines $ rawCode else rawCode - case highlight formatHtmlBlock (id',classes',keyvals) adjCode of + hlCode = if writerHighlight opts -- check highlighting options + then highlight formatHtmlBlock (id',classes',keyvals) adjCode + else Nothing + case hlCode of Nothing -> return $ addAttrs opts (id',classes,keyvals) $ H.pre $ H.code $ toHtml adjCode Just h -> modify (\st -> st{ stHighlighting = True }) >> @@ -589,14 +592,17 @@ inlineToHtml opts inline = (LineBreak) -> return $ if writerHtml5 opts then H5.br else H.br (Emph lst) -> inlineListToHtml opts lst >>= return . H.em (Strong lst) -> inlineListToHtml opts lst >>= return . H.strong - (Code attr str) -> case highlight formatHtmlInline attr str of + (Code attr str) -> case hlCode of Nothing -> return $ addAttrs opts attr $ H.code $ strToHtml str Just h -> do modify $ \st -> st{ stHighlighting = True } return $ addAttrs opts (id',[],keyvals) h - where (id',_,keyvals) = attr + where (id',_,keyvals) = attr + hlCode = if writerHighlight opts + then highlight formatHtmlInline attr str + else Nothing (Strikeout lst) -> inlineListToHtml opts lst >>= return . H.del (SmallCaps lst) -> inlineListToHtml opts lst >>= -- cgit v1.2.3 From f42095b7b72fc3419a661c65d17f46ba3cbc8d62 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 13 Jul 2013 13:48:50 -0700 Subject: Docx writer: Make `--no-highlight` work properly. --- src/Text/Pandoc/Writers/Docx.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index e899200f6..d579d4fa6 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -214,7 +214,8 @@ writeDocx opts doc@(Pandoc meta _) = do let newstyles = styleToOpenXml $ writerHighlightStyle opts let stylepath = "word/styles.xml" styledoc <- parseXml refArchive stylepath - let styledoc' = styledoc{ elContent = elContent styledoc ++ map Elem newstyles } + let styledoc' = styledoc{ elContent = elContent styledoc ++ + [Elem x | x <- newstyles, writerHighlight opts] } let styleEntry = toEntry stylepath epochtime $ renderXml styledoc' -- construct word/numbering.xml @@ -665,13 +666,16 @@ inlineToOpenXML opts (Math mathType str) = do Right r -> return [r] Left _ -> inlinesToOpenXML opts (readTeXMath str) inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst -inlineToOpenXML _ (Code attrs str) = +inlineToOpenXML opts (Code attrs str) = withTextProp (rStyle "VerbatimChar") - $ case highlight formatOpenXML attrs str of - Nothing -> intercalate [br] - `fmap` (mapM formattedString $ lines str) - Just h -> return h - where formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok) + $ if writerHighlight opts + then case highlight formatOpenXML attrs str of + Nothing -> unhighlighted + Just h -> return h + else unhighlighted + where unhighlighted = intercalate [br] `fmap` + (mapM formattedString $ lines str) + formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok) toHlTok (toktype,tok) = mknode "w:r" [] [ mknode "w:rPr" [] [ rStyle $ show toktype ] -- cgit v1.2.3 From 0b49f810f401b9154b50727d2179d1ec39cd8d3e Mon Sep 17 00:00:00 2001 From: Alexander Kondratskiy Date: Sun, 14 Jul 2013 14:33:58 -0400 Subject: Fixing wrong numbered-list indentation in open document format --- src/Text/Pandoc/Writers/OpenDocument.hs | 12 ++++++----- tests/writer.opendocument | 38 ++++++++++++++++----------------- 2 files changed, 26 insertions(+), 24 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 30f99c3e4..0efbf7580 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -489,14 +489,16 @@ paraStyle parent attrs = do tight = if t then [ ("fo:margin-top" , "0in" ) , ("fo:margin-bottom" , "0in" )] else [] - indent = when (i /= 0 || b || t) $ - selfClosingTag "style:paragraph-properties" $ - [ ("fo:margin-left" , indentVal) + indent = if (i /= 0 || b) + then [ ("fo:margin-left" , indentVal) , ("fo:margin-right" , "0in" ) , ("fo:text-indent" , "0in" ) , ("style:auto-text-indent" , "false" )] - ++ tight - addParaStyle $ inTags True "style:style" (styleAttr ++ attrs) indent + else [] + attributes = indent ++ tight + paraProps = when (not $ null attributes) $ + selfClosingTag "style:paragraph-properties" attributes + addParaStyle $ inTags True "style:style" (styleAttr ++ attrs) paraProps return pn paraListStyle :: Int -> State WriterState Int diff --git a/tests/writer.opendocument b/tests/writer.opendocument index 8727373a0..9e1661475 100644 --- a/tests/writer.opendocument +++ b/tests/writer.opendocument @@ -741,25 +741,25 @@ - + - + - + - + - + @@ -768,37 +768,37 @@ - + - + - + - + - + - + - + - + - + @@ -822,18 +822,18 @@ - + - + - + - + @@ -846,7 +846,7 @@ - + -- cgit v1.2.3 From b2385d0e9bf13f2fc152a3983893c47f2ab5d4c0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 16 Jul 2013 22:04:59 -0700 Subject: Text.Pandoc.ImageSize: Handle EPS. Closes #903. This change will make EPS images properly sized on conversion to Word. --- src/Text/Pandoc/ImageSize.hs | 24 +++++++++++++++++++++++- src/Text/Pandoc/Writers/Docx.hs | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs index 273a1a428..9b0850efb 100644 --- a/src/Text/Pandoc/ImageSize.hs +++ b/src/Text/Pandoc/ImageSize.hs @@ -34,11 +34,12 @@ import Data.ByteString (ByteString, unpack) import qualified Data.ByteString.Char8 as B import Control.Monad import Data.Bits +import Text.Pandoc.Shared (safeRead) -- quick and dirty functions to get image sizes -- algorithms borrowed from wwwis.pl -data ImageType = Png | Gif | Jpeg | Pdf deriving Show +data ImageType = Png | Gif | Jpeg | Pdf | Eps deriving Show data ImageSize = ImageSize{ pxX :: Integer @@ -54,6 +55,9 @@ imageType img = case B.take 4 img of "\x47\x49\x46\x38" -> return Gif "\xff\xd8\xff\xe0" -> return Jpeg "%PDF" -> return Pdf + "%!PS" + | (B.take 4 $ B.drop 1 $ B.dropWhile (/=' ') img) == "EPSF" + -> return Eps _ -> fail "Unknown image type" imageSize :: ByteString -> Maybe ImageSize @@ -63,6 +67,7 @@ imageSize img = do Png -> pngSize img Gif -> gifSize img Jpeg -> jpegSize img + Eps -> epsSize img Pdf -> Nothing -- TODO sizeInPixels :: ImageSize -> (Integer, Integer) @@ -71,6 +76,23 @@ sizeInPixels s = (pxX s, pxY s) sizeInPoints :: ImageSize -> (Integer, Integer) sizeInPoints s = (pxX s * 72 `div` dpiX s, pxY s * 72 `div` dpiY s) +epsSize :: ByteString -> Maybe ImageSize +epsSize img = do + let ls = takeWhile ("%" `B.isPrefixOf`) $ B.lines img + let ls' = dropWhile (not . ("%%BoundingBox:" `B.isPrefixOf`)) ls + case ls' of + [] -> mzero + (x:_) -> case B.words x of + (_:_:_:ux:uy:[]) -> do + ux' <- safeRead $ B.unpack ux + uy' <- safeRead $ B.unpack uy + return ImageSize{ + pxX = ux' + , pxY = uy' + , dpiX = 72 + , dpiY = 72 } + _ -> mzero + pngSize :: ByteString -> Maybe ImageSize pngSize img = do let (h, rest) = B.splitAt 8 img diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index d579d4fa6..1ed8c2fa5 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -776,6 +776,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do Just Jpeg -> ".jpeg" Just Gif -> ".gif" Just Pdf -> ".pdf" + Just Eps -> ".eps" Nothing -> takeExtension src if null imgext then -- without an extension there is no rule for content type -- cgit v1.2.3 From 7c980f39bf1cff941d3e78056fd69e0b371833e3 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Jul 2013 20:58:14 -0700 Subject: Improved fetching of external resources. * In Shared, openURL and fetchItem now return an Either, for better error handling. (API change.) * Better error message when fetching a URL fails with `--self-contained`. * EPUB writer: If resource not found, skip it, as in Docx writer. * Closes #916. --- src/Text/Pandoc/SelfContained.hs | 5 +++-- src/Text/Pandoc/Shared.hs | 16 +++++++++------- src/Text/Pandoc/Writers/Docx.hs | 2 +- src/Text/Pandoc/Writers/EPUB.hs | 13 +++++++++---- src/Text/Pandoc/Writers/ODT.hs | 5 ++--- 5 files changed, 24 insertions(+), 17 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index c4613992a..0547bc065 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -40,7 +40,7 @@ import System.FilePath (takeExtension, dropExtension, takeDirectory, ()) import Data.Char (toLower, isAscii, isAlphaNum) import Codec.Compression.GZip as Gzip import qualified Data.ByteString.Lazy as L -import Text.Pandoc.Shared (renderTags', openURL, readDataFile) +import Text.Pandoc.Shared (renderTags', openURL, readDataFile, err) import Text.Pandoc.UTF8 (toString, fromString) import Text.Pandoc.MIME (getMimeType) import System.Directory (doesFileExist) @@ -98,7 +98,7 @@ cssURLs userdata d orig = getItem :: Maybe FilePath -> String -> IO (ByteString, Maybe String) getItem userdata f = if isAbsoluteURI f - then openURL f + then openURL f >>= either handleErr return else do -- strip off trailing query or fragment part, if relative URL. -- this is needed for things like cmunrm.eot?#iefix, @@ -110,6 +110,7 @@ getItem userdata f = exists <- doesFileExist f' cont <- if exists then B.readFile f' else readDataFile userdata f' return (cont, mime) + where handleErr e = err 61 $ "Failed to retrieve " ++ f ++ "\n" ++ show e getRaw :: Maybe FilePath -> String -> String -> IO (ByteString, String) getRaw userdata mimetype src = do diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 09086da1f..0f2e16d2e 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -95,6 +95,7 @@ import Text.Pandoc.MIME (getMimeType) import System.FilePath ( (), takeExtension, dropExtension ) import Data.Generics (Typeable, Data) import qualified Control.Monad.State as S +import qualified Control.Exception as E import Control.Monad (msum, unless) import Text.Pandoc.Pretty (charWidth) import System.Locale (defaultTimeLocale) @@ -586,12 +587,13 @@ readDataFileUTF8 userDir fname = -- | Fetch an image or other item from the local filesystem or the net. -- Returns raw content and maybe mime type. -fetchItem :: String -> String -> IO (BS.ByteString, Maybe String) +fetchItem :: String -> String + -> IO (Either E.SomeException (BS.ByteString, Maybe String)) fetchItem sourceDir s = case s of _ | isAbsoluteURI s -> openURL s | isAbsoluteURI sourceDir -> openURL $ sourceDir ++ "/" ++ s - | otherwise -> do + | otherwise -> E.try $ do let mime = case takeExtension s of ".gz" -> getMimeType $ dropExtension s x -> getMimeType x @@ -600,21 +602,21 @@ fetchItem sourceDir s = return (cont, mime) -- | Read from a URL and return raw data and maybe mime type. -openURL :: String -> IO (BS.ByteString, Maybe String) +openURL :: String -> IO (Either E.SomeException (BS.ByteString, Maybe String)) openURL u | "data:" `isPrefixOf` u = let mime = takeWhile (/=',') $ drop 5 u contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u - in return (contents, Just mime) + in return $ Right (contents, Just mime) #ifdef HTTP_CONDUIT - | otherwise = do + | otherwise = E.try $ do req <- parseUrl u resp <- withManager $ httpLbs req return (BS.concat $ toChunks $ responseBody resp, UTF8.toString `fmap` lookup hContentType (responseHeaders resp)) #else - | otherwise = getBodyAndMimeType `fmap` browse - (do S.liftIO $ UTF8.hPutStrLn stderr $ "Fetching " ++ u ++ "..." + | otherwise = E.try $ getBodyAndMimeType `fmap` browse + (do UTF8.hPutStrLn stderr $ "Fetching " ++ u ++ "..." setOutHandler $ const (return ()) setAllowRedirects True request (getRequest' u')) diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 1ed8c2fa5..611cddc65 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -726,7 +726,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do Just (_,_,_,elt,_) -> return [elt] Nothing -> do let sourceDir = writerSourceDirectory opts - res <- liftIO $ E.try $ fetchItem sourceDir src + res <- liftIO $ fetchItem sourceDir src case res of Left (_ :: E.SomeException) -> do liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..." diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index f171a2560..42863ef86 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -123,10 +123,15 @@ writeEPUB opts doc@(Pandoc meta _) = do Pandoc _ blocks <- bottomUpM (transformInline opts' sourceDir picsRef) doc pics <- readIORef picsRef - let readPicEntry (oldsrc, newsrc) = do - (img,_) <- fetchItem sourceDir oldsrc - return $ toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img - picEntries <- mapM readPicEntry pics + let readPicEntry entries (oldsrc, newsrc) = do + res <- fetchItem sourceDir oldsrc + case res of + Left e -> do + warn $ "Could not find image `" ++ oldsrc ++ "', skipping..." + return entries + Right (img,_) -> return $ + (toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img) : entries + picEntries <- foldM readPicEntry [] pics -- handle fonts let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index db27286e8..589010bb9 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -42,7 +42,6 @@ import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) import Control.Monad (liftM) -import Control.Monad.Trans (liftIO) import Text.Pandoc.XML import Text.Pandoc.Pretty import qualified Control.Exception as E @@ -114,10 +113,10 @@ writeODT opts doc@(Pandoc meta _) = do transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline transformPic sourceDir entriesRef (Image lab (src,_)) = do - res <- liftIO $ E.try $ fetchItem sourceDir src + res <- fetchItem sourceDir src case res of Left (_ :: E.SomeException) -> do - liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..." + warn $ "Could not find image `" ++ src ++ "', skipping..." return $ Emph lab Right (img, _) -> do let size = imageSize img -- cgit v1.2.3 From 93e096fe1d23bf60a7ca7fa39fa6e730336338eb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Jul 2013 21:51:11 -0700 Subject: Fixed warning. --- src/Text/Pandoc/Writers/EPUB.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 42863ef86..e625931fc 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -126,7 +126,7 @@ writeEPUB opts doc@(Pandoc meta _) = do let readPicEntry entries (oldsrc, newsrc) = do res <- fetchItem sourceDir oldsrc case res of - Left e -> do + Left _ -> do warn $ "Could not find image `" ++ oldsrc ++ "', skipping..." return entries Right (img,_) -> return $ -- cgit v1.2.3 From d5fad2306a27b3fcf2c85782dd13bc8e516a5df9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 25 Jul 2013 20:29:42 -0700 Subject: LaTeX writer: Change `\` to `/` in paths. `/` works even on Windows in LaTeX. `\` will cause major problems if unescaped. --- src/Text/Pandoc/Writers/LaTeX.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 2b4a608a7..06a04ade2 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -202,7 +202,8 @@ stringToLaTeX ctx (x:xs) = do _ -> '-' : rest '~' | not isUrl -> "\\textasciitilde{}" ++ rest '^' -> "\\^{}" ++ rest - '\\' -> "\\textbackslash{}" ++ rest + '\\'| isUrl -> '/' : rest -- NB. / works as path sep even on Windows + | otherwise -> "\\textbackslash{}" ++ rest '|' -> "\\textbar{}" ++ rest '<' -> "\\textless{}" ++ rest '>' -> "\\textgreater{}" ++ rest @@ -648,7 +649,8 @@ inlineToLaTeX (Image _ (source, _)) = do let source' = if isAbsoluteURI source then source else unEscapeString source - return $ "\\includegraphics" <> braces (text source') + source'' <- stringToLaTeX URLString source' + return $ "\\includegraphics" <> braces (text source'') inlineToLaTeX (Note contents) = do modify (\s -> s{stInNote = True}) contents' <- blockListToLaTeX contents -- cgit v1.2.3 From a97f39c12e7b47a272575b69ad4cdd38966c043e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 26 Jul 2013 12:40:56 -0700 Subject: Beamer: add allowframebreaks to slide if set in header classes. It's recommended that your bibliography slide have this attribute: # References {.allowframebreaks} This causes multiple slides to be created if necessary, depending on the length of the bibliography. --- README | 10 ++++++++++ src/Text/Pandoc/Writers/LaTeX.hs | 19 +++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index d9b003344..4895f0f52 100644 --- a/README +++ b/README @@ -2674,6 +2674,16 @@ using the `-V` option: pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf +Note that header attributes will turn into slide attributes +(on a `
` or `
`) in HTML slide formats, allowing you +to style individual slides. In Beamer, the only header attribute +that affects slides is the `allowframebreaks` class, which sets the +`allowframebreaks` option, causing multiple slides to be created +if the content overfills the frame. This is recommended especially for +bibliographies: + + # References {.allowframebreaks} + Literate Haskell support ======================== diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 06a04ade2..aa5bfa623 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -232,7 +232,7 @@ toSlides bs = do elementToBeamer :: Int -> Element -> State WriterState [Block] elementToBeamer _slideLevel (Blk b) = return [b] -elementToBeamer slideLevel (Sec lvl _num (ident,classes,_) tit elts) +elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts) | lvl > slideLevel = do bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts return $ Para ( RawInline "latex" "\\begin{block}{" @@ -240,7 +240,7 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,_) tit elts) : bs ++ [RawBlock "latex" "\\end{block}"] | lvl < slideLevel = do bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts - return $ (Header lvl (ident,classes,[]) tit) : bs + return $ (Header lvl (ident,classes,kvs) tit) : bs | otherwise = do -- lvl == slideLevel -- note: [fragile] is required or verbatim breaks let hasCodeBlock (CodeBlock _ _) = [True] @@ -248,17 +248,20 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,_) tit elts) let hasCode (Code _ _) = [True] hasCode _ = [] opts <- gets stOptions - let fragile = if not $ null $ queryWith hasCodeBlock elts ++ + let fragile = not $ null $ queryWith hasCodeBlock elts ++ if writerListings opts then queryWith hasCode elts else [] - then "[fragile]" - else "" - let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ fragile) : + let allowframebreaks = "allowframebreaks" `elem` classes + let optionslist = ["fragile" | fragile] ++ + ["allowframebreaks" | allowframebreaks] + let options = if null optionslist + then "" + else "[" ++ intercalate "," optionslist ++ "]" + let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ options) : if tit == [Str "\0"] -- marker for hrule then [] - else (RawInline "latex" "\\frametitle{") : tit ++ - [RawInline "latex" "}"] + else (RawInline "latex" "{") : tit ++ [RawInline "latex" "}"] let slideEnd = RawBlock "latex" "\\end{frame}" -- now carve up slide into blocks if there are sections inside bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts -- cgit v1.2.3 From 4a84b78100f2cfa0f7f7d13a24693a37af60003d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 3 Aug 2013 23:05:14 -0700 Subject: MediaWiki writer: Use native mediawiki tables instead of HTML. Closes #720. --- src/Text/Pandoc/Writers/MediaWiki.hs | 83 +++++---- tests/tables.mediawiki | 316 ++++++++++++++--------------------- 2 files changed, 164 insertions(+), 235 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index b3b319c2a..e1bfd18b2 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -36,7 +36,7 @@ import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.XML ( escapeStringForXML ) -import Data.List ( intersect, intercalate ) +import Data.List ( intersect, intercalate, intersperse ) import Network.URI ( isURI ) import Control.Monad.State @@ -135,25 +135,17 @@ blockToMediaWiki opts (BlockQuote blocks) = do return $ "
" ++ contents ++ "
" blockToMediaWiki opts (Table capt aligns widths headers rows') = do - let alignStrings = map alignmentToString aligns - captionDoc <- if null capt - then return "" - else do - c <- inlineListToMediaWiki opts capt - return $ "" ++ c ++ "\n" - let percent w = show (truncate (100*w) :: Integer) ++ "%" - let coltags = if all (== 0.0) widths - then "" - else unlines $ map - (\w -> "") widths - head' <- if all null headers - then return "" - else do - hs <- tableRowToMediaWiki opts alignStrings 0 headers - return $ "\n" ++ hs ++ "\n\n" - body' <- zipWithM (tableRowToMediaWiki opts alignStrings) [1..] rows' - return $ "\n" ++ captionDoc ++ coltags ++ head' ++ - "\n" ++ unlines body' ++ "\n
\n" + caption <- if null capt + then return "" + else do + c <- inlineListToMediaWiki opts capt + return $ "|+ " ++ trimr c ++ "\n" + let headless = all null headers + let allrows = if headless then rows' else headers:rows' + tableBody <- (concat . intersperse "|-\n") `fmap` + mapM (tableRowToMediaWiki opts headless aligns widths) + (zip [1..] allrows) + return $ "{|\n" ++ caption ++ tableBody ++ "|}\n" blockToMediaWiki opts x@(BulletList items) = do oldUseTags <- get >>= return . stUseTags @@ -285,20 +277,34 @@ vcat = intercalate "\n" -- Auxiliary functions for tables: tableRowToMediaWiki :: WriterOptions - -> [String] - -> Int - -> [[Block]] + -> Bool + -> [Alignment] + -> [Double] + -> (Int, [[Block]]) -> State WriterState String -tableRowToMediaWiki opts alignStrings rownum cols' = do - let celltype = if rownum == 0 then "th" else "td" - let rowclass = case rownum of - 0 -> "header" - x | x `rem` 2 == 1 -> "odd" - _ -> "even" - cols'' <- sequence $ zipWith - (\alignment item -> tableItemToMediaWiki opts celltype alignment item) - alignStrings cols' - return $ "\n" ++ unlines cols'' ++ "" +tableRowToMediaWiki opts headless alignments widths (rownum, cells) = do + cells' <- mapM (\cellData -> + tableCellToMediaWiki opts headless rownum cellData) + $ zip3 alignments widths cells + return $ unlines cells' + +tableCellToMediaWiki :: WriterOptions + -> Bool + -> Int + -> (Alignment, Double, [Block]) + -> State WriterState String +tableCellToMediaWiki opts headless rownum (alignment, width, bs) = do + contents <- blockListToMediaWiki opts bs + let marker = if rownum == 1 && not headless then "!" else "|" + let percent w = show (truncate (100*w) :: Integer) ++ "%" + let attrs = ["align=" ++ show (alignmentToString alignment) | + alignment /= AlignDefault && alignment /= AlignLeft] ++ + ["width=\"" ++ percent width ++ "\"" | + width /= 0.0 && rownum == 1] + let attr = if null attrs + then "" + else unwords attrs ++ "|" + return $ marker ++ attr ++ trimr contents alignmentToString :: Alignment -> [Char] alignmentToString alignment = case alignment of @@ -307,17 +313,6 @@ alignmentToString alignment = case alignment of AlignCenter -> "center" AlignDefault -> "left" -tableItemToMediaWiki :: WriterOptions - -> String - -> String - -> [Block] - -> State WriterState String -tableItemToMediaWiki opts celltype align' item = do - let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++ - x ++ "" - contents <- blockListToMediaWiki opts item - return $ mkcell contents - -- | Convert list of Pandoc block elements to MediaWiki. blockListToMediaWiki :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements diff --git a/tests/tables.mediawiki b/tests/tables.mediawiki index 4836ecd79..efde76559 100644 --- a/tests/tables.mediawiki +++ b/tests/tables.mediawiki @@ -1,212 +1,146 @@ Simple table with caption: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
+{| +|+ Demonstration of simple table syntax. +!align="right"|Right +!Left +!align="center"|Center +!Default +|- +|align="right"|12 +|12 +|align="center"|12 +|12 +|- +|align="right"|123 +|123 +|align="center"|123 +|123 +|- +|align="right"|1 +|1 +|align="center"|1 +|1 +|} Simple table without caption: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RightLeftCenterDefault
12121212
123123123123
1111
+{| +!align="right"|Right +!Left +!align="center"|Center +!Default +|- +|align="right"|12 +|12 +|align="center"|12 +|12 +|- +|align="right"|123 +|123 +|align="center"|123 +|123 +|- +|align="right"|1 +|1 +|align="center"|1 +|1 +|} Simple table indented two spaces: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Demonstration of simple table syntax.
RightLeftCenterDefault
12121212
123123123123
1111
+{| +|+ Demonstration of simple table syntax. +!align="right"|Right +!Left +!align="center"|Center +!Default +|- +|align="right"|12 +|12 +|align="center"|12 +|12 +|- +|align="right"|123 +|123 +|align="center"|123 +|123 +|- +|align="right"|1 +|1 +|align="center"|1 +|1 +|} Multiline table with caption: - - ----- - - - - - - - - - - - - - - - - - - - - - -
Here's the caption. It may span multiple lines.
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+{| +|+ Here's the caption. It may span multiple lines. +!align="center" width="15%"|Centered Header +!width="13%"|Left Aligned +!align="right" width="16%"|Right Aligned +!width="33%"|Default aligned +|- +|align="center"|First +|row +|align="right"|12.0 +|Example of a row that spans multiple lines. +|- +|align="center"|Second +|row +|align="right"|5.0 +|Here's another one. Note the blank line between rows. +|} Multiline table without caption: - ----- - - - - - - - - - - - - - - - - - - - - - -
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+{| +!align="center" width="15%"|Centered Header +!width="13%"|Left Aligned +!align="right" width="16%"|Right Aligned +!width="33%"|Default aligned +|- +|align="center"|First +|row +|align="right"|12.0 +|Example of a row that spans multiple lines. +|- +|align="center"|Second +|row +|align="right"|5.0 +|Here's another one. Note the blank line between rows. +|} Table without column headers: - - - - - - - - - - - - - - - - - - - - - -
12121212
123123123123
1111
+{| +|align="right"|12 +|12 +|align="center"|12 +|align="right"|12 +|- +|align="right"|123 +|123 +|align="center"|123 +|align="right"|123 +|- +|align="right"|1 +|1 +|align="center"|1 +|align="right"|1 +|} Multiline table without column headers: - ----- - - - - - - - - - - - - - -
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here's another one. Note the blank line between rows.
+{| +|align="center" width="15%"|First +|width="13%"|row +|align="right" width="16%"|12.0 +|width="33%"|Example of a row that spans multiple lines. +|- +|align="center"|Second +|row +|align="right"|5.0 +|Here's another one. Note the blank line between rows. +|} -- cgit v1.2.3 From 2d6e0b1530e61fa2d6a22d8b61042734b20f0af5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 4 Aug 2013 14:12:13 -0700 Subject: Remove CPP from default-extensions; add pragmas to modules as needed. --- man/make-pandoc-man-pages.hs | 1 + pandoc.cabal | 4 ---- src/Text/Pandoc/Pretty.hs | 2 +- src/Text/Pandoc/UTF8.hs | 1 + src/Text/Pandoc/Writers/EPUB.hs | 6 +----- 5 files changed, 4 insertions(+), 10 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/man/make-pandoc-man-pages.hs b/man/make-pandoc-man-pages.hs index eca1276eb..008294433 100644 --- a/man/make-pandoc-man-pages.hs +++ b/man/make-pandoc-man-pages.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} -- Create pandoc.1 man and pandoc_markdown.5 man pages from README import Text.Pandoc import qualified Text.Pandoc.UTF8 as UTF8 diff --git a/pandoc.cabal b/pandoc.cabal index 7d4bccc41..7f12a44ae 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -277,7 +277,6 @@ Library Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind Ghc-Prof-Options: -auto-all -caf-all -rtsopts Default-Language: Haskell98 - Default-Extensions: CPP Other-Extensions: PatternGuards, OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving, RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances, @@ -357,7 +356,6 @@ Executable pandoc if os(windows) Cpp-options: -D_WINDOWS Default-Language: Haskell98 - Default-Extensions: CPP Other-Extensions: PatternGuards, OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving, RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances, @@ -377,7 +375,6 @@ Executable make-pandoc-man-pages old-time >= 1.0 && < 1.2, time >= 1.2 && < 1.5 Default-Language: Haskell98 - Default-Extensions: CPP Test-Suite test-pandoc Type: exitcode-stdio-1.0 @@ -415,7 +412,6 @@ Test-Suite test-pandoc Tests.Writers.LaTeX Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind Default-Language: Haskell98 - Default-Extensions: CPP benchmark benchmark-pandoc Type: exitcode-stdio-1.0 diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index 21121a506..faf2a6797 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE GeneralizedNewtypeDeriving, CPP #-} {- Copyright (C) 2010 John MacFarlane diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs index 9fa743cd9..229442543 100644 --- a/src/Text/Pandoc/UTF8.hs +++ b/src/Text/Pandoc/UTF8.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {- Copyright (C) 2010 John MacFarlane diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index e625931fc..fb756f196 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE PatternGuards #-} +{-# LANGUAGE PatternGuards, CPP #-} {- Copyright (C) 2010 John MacFarlane @@ -62,11 +62,7 @@ import Text.Pandoc.MIME (getMimeType) import Prelude hiding (catch) #endif import Control.Exception (catch, SomeException) -#if MIN_VERSION_blaze_html(0,5,0) import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -#else -import Text.Blaze.Renderer.Utf8 (renderHtml) -#endif -- A Chapter includes a list of blocks and maybe a section -- number offset. Note, some chapters are unnumbered. The section -- cgit v1.2.3 From 7d18770b008c12e13c324223304c6703e06f3a4a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 6 Aug 2013 23:31:01 -0700 Subject: Added support for MetaBool. --- src/Text/Pandoc/Readers/Markdown.hs | 2 +- src/Text/Pandoc/Writers/Custom.hs | 2 ++ src/Text/Pandoc/Writers/Shared.hs | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 076706b4e..a880c09de 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -278,7 +278,7 @@ toMetaValue opts x = yamlToMeta :: ReaderOptions -> Yaml.Value -> MetaValue yamlToMeta opts (Yaml.String t) = toMetaValue opts t yamlToMeta _ (Yaml.Number n) = MetaString $ show n -yamlToMeta _ (Yaml.Bool b) = MetaString $ map toLower $ show b +yamlToMeta _ (Yaml.Bool b) = MetaBool b yamlToMeta opts (Yaml.Array xs) = B.toMetaValue $ map (yamlToMeta opts) $ V.toList xs yamlToMeta opts (Yaml.Object o) = MetaMap $ H.foldrWithKey (\k v m -> diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 732497616..5c82fe0e1 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -110,12 +110,14 @@ instance StackValue [Block] where instance StackValue MetaValue where push l (MetaMap m) = Lua.push l m push l (MetaList xs) = Lua.push l xs + push l (MetaBool x) = Lua.push l x push l (MetaString s) = Lua.push l s push l (MetaInlines ils) = Lua.push l ils push l (MetaBlocks bs) = Lua.push l bs peek _ _ = undefined valuetype (MetaMap _) = Lua.TTABLE valuetype (MetaList _) = Lua.TTABLE + valuetype (MetaBool _) = Lua.TBOOLEAN valuetype (MetaString _) = Lua.TSTRING valuetype (MetaInlines _) = Lua.TSTRING valuetype (MetaBlocks _) = Lua.TSTRING diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index c6c30d070..e6ec853f8 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -74,6 +74,7 @@ metaValueToJSON blockWriter inlineWriter (MetaMap metamap) = liftM toJSON $ Traversable.mapM (metaValueToJSON blockWriter inlineWriter) metamap metaValueToJSON blockWriter inlineWriter (MetaList xs) = liftM toJSON $ Traversable.mapM (metaValueToJSON blockWriter inlineWriter) xs +metaValueToJSON _ _ (MetaBool b) = return $ toJSON b metaValueToJSON _ _ (MetaString s) = return $ toJSON s metaValueToJSON blockWriter _ (MetaBlocks bs) = liftM toJSON $ blockWriter bs metaValueToJSON _ inlineWriter (MetaInlines bs) = liftM toJSON $ inlineWriter bs -- cgit v1.2.3 From 802dc9a8b9f206eb3be592ab19067f637eb2a3ee Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 8 Aug 2013 10:41:39 -0700 Subject: Added Text.Pandoc.Compat.Monoid. This allows pandoc to compile with base < 4.5, where Data.Monoid doesn't export `<>`. Thanks to Dirk Ullirch for the patch. --- pandoc.cabal | 1 + src/Text/Pandoc/Compat/Monoid.hs | 16 ++++++++++++++++ src/Text/Pandoc/Templates.hs | 2 +- src/Text/Pandoc/Writers/Docx.hs | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/Text/Pandoc/Compat/Monoid.hs (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.cabal b/pandoc.cabal index 3dc400d40..192b6c5fd 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -335,6 +335,7 @@ Library Text.Pandoc.ImageSize, Text.Pandoc.Slides, Text.Pandoc.Highlighting, + Text.Pandoc.Compat.Monoid, Paths_pandoc Buildable: True diff --git a/src/Text/Pandoc/Compat/Monoid.hs b/src/Text/Pandoc/Compat/Monoid.hs new file mode 100644 index 000000000..80ffcbbd6 --- /dev/null +++ b/src/Text/Pandoc/Compat/Monoid.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE CPP #-} +module Text.Pandoc.Compat.Monoid ( Monoid(..) + , (<>) + ) where + +#if MIN_VERSION_base(4,5,0) +import Data.Monoid ((<>), Monoid(..)) +#else +import Data.Monoid (mappend, Monoid(..)) +#endif + +#if MIN_VERSION_base(4,5,0) +#else +(<>) :: Monoid m => m -> m -> m +(<>) = mappend +#endif diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index c95c84ca8..22a44e735 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -102,7 +102,7 @@ import Control.Applicative import qualified Data.Text as T import Data.Text (Text) import Data.Text.Encoding (encodeUtf8) -import Data.Monoid ((<>), Monoid(..)) +import Text.Pandoc.Compat.Monoid ((<>), Monoid(..)) import Data.List (intersperse, nub) import System.FilePath ((), (<.>)) import qualified Data.Map as M diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 611cddc65..6bb4d5569 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -35,7 +35,7 @@ import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 import qualified Data.Map as M import qualified Text.Pandoc.UTF8 as UTF8 -import Data.Monoid ((<>)) +import Text.Pandoc.Compat.Monoid ((<>)) import Codec.Archive.Zip import Data.Time.Clock.POSIX import Text.Pandoc.Definition -- cgit v1.2.3 From e9de0f0e22b9b64b5684efe81d03539c3f57a71c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 8 Aug 2013 23:14:12 -0700 Subject: Preliminary support for new Div and Span elements in writers. Currently these are "transparent" containers, except in HTML, where they produce div and span elements with attributes. --- data/sample.lua | 8 ++++++++ src/Text/Pandoc/Writers/AsciiDoc.hs | 2 ++ src/Text/Pandoc/Writers/ConTeXt.hs | 2 ++ src/Text/Pandoc/Writers/Custom.hs | 5 +++++ src/Text/Pandoc/Writers/Docbook.hs | 3 +++ src/Text/Pandoc/Writers/Docx.hs | 2 ++ src/Text/Pandoc/Writers/FB2.hs | 3 +++ src/Text/Pandoc/Writers/HTML.hs | 5 +++++ src/Text/Pandoc/Writers/LaTeX.hs | 2 ++ src/Text/Pandoc/Writers/Man.hs | 2 ++ src/Text/Pandoc/Writers/Markdown.hs | 3 +++ src/Text/Pandoc/Writers/MediaWiki.hs | 6 ++++++ src/Text/Pandoc/Writers/OpenDocument.hs | 2 ++ src/Text/Pandoc/Writers/Org.hs | 3 +++ src/Text/Pandoc/Writers/RST.hs | 2 ++ src/Text/Pandoc/Writers/RTF.hs | 3 +++ src/Text/Pandoc/Writers/Texinfo.hs | 5 +++++ src/Text/Pandoc/Writers/Textile.hs | 6 ++++++ 18 files changed, 64 insertions(+) (limited to 'src/Text/Pandoc/Writers') diff --git a/data/sample.lua b/data/sample.lua index 1c82ebe2e..a7e9d6337 100644 --- a/data/sample.lua +++ b/data/sample.lua @@ -177,6 +177,10 @@ function Note(s) '">' .. num .. '' end +function Span(s, attr) + return "" .. s .. "" +end + function Plain(s) return s end @@ -299,6 +303,10 @@ function Table(caption, aligns, widths, headers, rows) return table.concat(buffer,'\n') end +function Div(s, attr) + return "\n" .. s .. "
" +end + -- The following code will produce runtime warnings when you haven't defined -- all of the functions you need for the custom writer, so it's useful -- to include when you're working on a writer. diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 6c3c6955e..00cea27e5 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -246,6 +246,7 @@ blockToAsciiDoc opts (OrderedList (_start, sty, _delim) items) = do blockToAsciiDoc opts (DefinitionList items) = do contents <- mapM (definitionListItemToAsciiDoc opts) items return $ cat contents <> blankline +blockToAsciiDoc opts (Div _ bs) = blockListToAsciiDoc opts bs -- | Convert bullet list item (list of blocks) to asciidoc. bulletListItemToAsciiDoc :: WriterOptions -> [Block] -> State WriterState Doc @@ -383,3 +384,4 @@ inlineToAsciiDoc opts (Note [Plain inlines]) = do return $ text "footnote:[" <> contents <> "]" -- asciidoc can't handle blank lines in notes inlineToAsciiDoc _ (Note _) = return "[multiblock footnote omitted]" +inlineToAsciiDoc opts (Span _ ils) = inlineListToAsciiDoc opts ils diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 32588dc8f..40dc1deb5 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -143,6 +143,7 @@ blockToConTeXt (CodeBlock _ str) = -- blankline because \stoptyping can't have anything after it, inc. '}' blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline blockToConTeXt (RawBlock _ _ ) = return empty +blockToConTeXt (Div _ bs) = blockListToConTeXt bs blockToConTeXt (BulletList lst) = do contents <- mapM listItemToConTeXt lst return $ ("\\startitemize" <> if isTightList lst @@ -330,6 +331,7 @@ inlineToConTeXt (Note contents) = do then text "\\footnote{" <> nest 2 contents' <> char '}' else text "\\startbuffer " <> nest 2 contents' <> text "\\stopbuffer\\footnote{\\getbuffer}" +inlineToConTeXt (Span _ ils) = inlineListToConTeXt ils -- | Craft the section header, inserting the secton reference, if supplied. sectionHeader :: Attr diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 5c82fe0e1..c250a240e 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -178,6 +178,9 @@ blockToCustom lua (OrderedList (num,sty,delim) items) = blockToCustom lua (DefinitionList items) = callfunc lua "DefinitionList" items +blockToCustom lua (Div attr items) = + callfunc lua "Div" items (attrToMap attr) + -- | Convert list of Pandoc block elements to Custom. blockListToCustom :: LuaState -- ^ Options -> [Block] -- ^ List of block elements @@ -240,3 +243,5 @@ inlineToCustom lua (Image alt (src,tit)) = inlineToCustom lua (Note contents) = callfunc lua "Note" contents +inlineToCustom lua (Span attr items) = + callfunc lua "Span" items (attrToMap attr) diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 6f4b61a79..2f415f3ee 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -148,6 +148,7 @@ listItemToDocbook opts item = -- | Convert a Pandoc block element to Docbook. blockToDocbook :: WriterOptions -> Block -> Doc blockToDocbook _ Null = empty +blockToDocbook opts (Div _ bs) = blocksToDocbook opts bs blockToDocbook _ (Header _ _ _) = empty -- should not occur after hierarchicalize blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst -- title beginning with fig: indicates that the image is a figure @@ -267,6 +268,8 @@ inlineToDocbook opts (Quoted _ lst) = inTagsSimple "quote" $ inlinesToDocbook opts lst inlineToDocbook opts (Cite _ lst) = inlinesToDocbook opts lst +inlineToDocbook opts (Span _ ils) = + inlinesToDocbook opts ils inlineToDocbook _ (Code _ str) = inTagsSimple "literal" $ text (escapeStringForXML str) inlineToDocbook opts (Math t str) diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 6bb4d5569..d93254971 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -428,6 +428,7 @@ getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique -- | Convert a Pandoc block element to OpenXML. blockToOpenXML :: WriterOptions -> Block -> WS [Element] blockToOpenXML _ Null = return [] +blockToOpenXML opts (Div _ bs) = blocksToOpenXML opts bs blockToOpenXML opts (Header lev (ident,_,_) lst) = do contents <- withParaProp (pStyle $ "Heading" ++ show lev) $ blockToOpenXML opts (Para lst) @@ -633,6 +634,7 @@ formattedString str = do inlineToOpenXML :: WriterOptions -> Inline -> WS [Element] inlineToOpenXML _ (Str str) = formattedString str inlineToOpenXML opts Space = inlineToOpenXML opts (Str " ") +inlineToOpenXML opts (Span _ ils) = inlinesToOpenXML opts ils inlineToOpenXML opts (Strong lst) = withTextProp (mknode "w:b" [] ()) $ inlinesToOpenXML opts lst inlineToOpenXML opts (Emph lst) = diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs index 27f0c8305..2576b2dc2 100644 --- a/src/Text/Pandoc/Writers/FB2.hs +++ b/src/Text/Pandoc/Writers/FB2.hs @@ -324,6 +324,7 @@ blockToXml (CodeBlock _ s) = return . spaceBeforeAfter . map (el "p" . el "code") . lines $ s blockToXml (RawBlock _ s) = return . spaceBeforeAfter . map (el "p" . el "code") . lines $ s +blockToXml (Div _ bs) = cMapM blockToXml bs blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs blockToXml (OrderedList a bss) = do state <- get @@ -425,6 +426,7 @@ indent = indentBlock -- | Convert a Pandoc's Inline element to FictionBook XML representation. toXml :: Inline -> FBM [Content] toXml (Str s) = return [txt s] +toXml (Span _ ils) = cMapM toXml ils toXml (Emph ss) = list `liftM` wrap "emphasis" ss toXml (Strong ss) = list `liftM` wrap "strong" ss toXml (Strikeout ss) = list `liftM` wrap "strikethrough" ss @@ -560,6 +562,7 @@ list = (:[]) plain :: Inline -> String plain (Str s) = s plain (Emph ss) = concat (map plain ss) +plain (Span _ ss) = concat (map plain ss) plain (Strong ss) = concat (map plain ss) plain (Strikeout ss) = concat (map plain ss) plain (Superscript ss) = concat (map plain ss) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index cfc187e02..560c26c76 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -407,6 +407,9 @@ blockToHtml opts (Para [Str ".",Space,Str ".",Space,Str "."]) blockToHtml opts (Para lst) = do contents <- inlineListToHtml opts lst return $ H.p contents +blockToHtml opts (Div attr bs) = do + contents <- blockListToHtml opts bs + return $ addAttrs opts attr $ H.div $ nl opts >> contents >> nl opts blockToHtml _ (RawBlock "html" str) = return $ preEscapedString str blockToHtml _ (RawBlock _ _) = return mempty blockToHtml opts (HorizontalRule) = return $ if writerHtml5 opts then H5.hr else H.hr @@ -590,6 +593,8 @@ inlineToHtml opts inline = (Str str) -> return $ strToHtml str (Space) -> return $ strToHtml " " (LineBreak) -> return $ if writerHtml5 opts then H5.br else H.br + (Span attr ils) -> inlineListToHtml opts ils >>= + return . addAttrs opts attr . H.span (Emph lst) -> inlineListToHtml opts lst >>= return . H.em (Strong lst) -> inlineListToHtml opts lst >>= return . H.strong (Code attr str) -> case hlCode of diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index aa5bfa623..37de03e0f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -282,6 +282,7 @@ isLineBreakOrSpace _ = False blockToLaTeX :: Block -- ^ Block to convert -> State WriterState Doc blockToLaTeX Null = return empty +blockToLaTeX (Div _ bs) = blockListToLaTeX bs blockToLaTeX (Plain lst) = inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst -- title beginning with fig: indicates that the image is a figure @@ -560,6 +561,7 @@ isQuoted _ = False -- | Convert inline element to LaTeX inlineToLaTeX :: Inline -- ^ Inline to convert -> State WriterState Doc +inlineToLaTeX (Span _ ils) = inlineListToLaTeX ils >>= return . braces inlineToLaTeX (Emph lst) = inlineListToLaTeX lst >>= return . inCmd "emph" inlineToLaTeX (Strong lst) = diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index 0508b6c27..ed66c7c2b 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -160,6 +160,7 @@ blockToMan :: WriterOptions -- ^ Options -> Block -- ^ Block element -> State WriterState Doc blockToMan _ Null = return empty +blockToMan opts (Div _ bs) = blockListToMan opts bs blockToMan opts (Plain inlines) = liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines blockToMan opts (Para inlines) = do @@ -300,6 +301,7 @@ inlineListToMan opts lst = mapM (inlineToMan opts) lst >>= (return . hcat) -- | Convert Pandoc inline element to man. inlineToMan :: WriterOptions -> Inline -> State WriterState Doc +inlineToMan opts (Span _ ils) = inlineListToMan opts ils inlineToMan opts (Emph lst) = do contents <- inlineListToMan opts lst return $ text "\\f[I]" <> contents <> text "\\f[]" diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 80402a757..d195d8445 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -301,6 +301,7 @@ blockToMarkdown :: WriterOptions -- ^ Options -> Block -- ^ Block element -> State WriterState Doc blockToMarkdown _ Null = return empty +blockToMarkdown opts (Div _ bs) = blockListToMarkdown opts bs blockToMarkdown opts (Plain inlines) = do contents <- inlineListToMarkdown opts inlines return $ contents <> cr @@ -628,6 +629,8 @@ escapeSpaces x = x -- | Convert Pandoc inline element to markdown. inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc +inlineToMarkdown opts (Span _ ils) = + inlineListToMarkdown opts ils inlineToMarkdown opts (Emph lst) = do contents <- inlineListToMarkdown opts lst return $ "*" <> contents <> "*" diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index e1bfd18b2..fccf25753 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -83,6 +83,9 @@ blockToMediaWiki :: WriterOptions -- ^ Options blockToMediaWiki _ Null = return "" +blockToMediaWiki opts (Div _ bs) = + blockListToMediaWiki opts bs + blockToMediaWiki opts (Plain inlines) = inlineListToMediaWiki opts inlines @@ -328,6 +331,9 @@ inlineListToMediaWiki opts lst = -- | Convert Pandoc inline element to MediaWiki. inlineToMediaWiki :: WriterOptions -> Inline -> State WriterState String +inlineToMediaWiki opts (Span _ ils) = + inlineListToMediaWiki opts ils + inlineToMediaWiki opts (Emph lst) = do contents <- inlineListToMediaWiki opts lst return $ "''" ++ contents ++ "''" diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 0efbf7580..d76d0f6ad 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -285,6 +285,7 @@ blockToOpenDocument :: WriterOptions -> Block -> State WriterState Doc blockToOpenDocument o bs | Plain b <- bs = inParagraphTags =<< inlinesToOpenDocument o b | Para b <- bs = inParagraphTags =<< inlinesToOpenDocument o b + | Div _ xs <- bs = blocksToOpenDocument o xs | Header i _ b <- bs = setFirstPara >> (inHeaderTags i =<< inlinesToOpenDocument o b) | BlockQuote b <- bs = setFirstPara >> mkBlockQuote b @@ -360,6 +361,7 @@ inlinesToOpenDocument o l = hcat <$> mapM (inlineToOpenDocument o) l inlineToOpenDocument :: WriterOptions -> Inline -> State WriterState Doc inlineToOpenDocument o ils | Space <- ils = inTextStyle space + | Span _ xs <- ils = inlinesToOpenDocument o xs | LineBreak <- ils = return $ selfClosingTag "text:line-break" [] | Str s <- ils = inTextStyle $ handleSpaces $ escapeStringForXML s | Emph l <- ils = withTextStyle Italic $ inlinesToOpenDocument o l diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index 40e8abf7e..34ae532b0 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -106,6 +106,7 @@ escapeString = escapeStringUsing $ blockToOrg :: Block -- ^ Block element -> State WriterState Doc blockToOrg Null = return empty +blockToOrg (Div _ bs) = blockListToOrg bs blockToOrg (Plain inlines) = inlineListToOrg inlines -- title beginning with fig: indicates that the image is a figure blockToOrg (Para [Image txt (src,'f':'i':'g':':':tit)]) = do @@ -229,6 +230,8 @@ inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat -- | Convert Pandoc inline element to Org. inlineToOrg :: Inline -> State WriterState Doc +inlineToOrg (Span _ lst) = + inlineListToOrg lst inlineToOrg (Emph lst) = do contents <- inlineListToOrg lst return $ "/" <> contents <> "/" diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 606793842..4d8daa15b 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -161,6 +161,7 @@ bordered contents c = blockToRST :: Block -- ^ Block element -> State WriterState Doc blockToRST Null = return empty +blockToRST (Div _ bs) = blockListToRST bs blockToRST (Plain inlines) = inlineListToRST inlines -- title beginning with fig: indicates that the image is a figure blockToRST (Para [Image txt (src,'f':'i':'g':':':tit)]) = do @@ -338,6 +339,7 @@ inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat -- | Convert Pandoc inline element to RST. inlineToRST :: Inline -> State WriterState Doc +inlineToRST (Span _ ils) = inlineListToRST ils inlineToRST (Emph lst) = do contents <- inlineListToRST lst return $ "*" <> contents <> "*" diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 0db1c52c4..7e5d33c50 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -208,6 +208,8 @@ blockToRTF :: Int -- ^ indent level -> Block -- ^ block to convert -> String blockToRTF _ _ Null = "" +blockToRTF indent alignment (Div _ bs) = + concatMap (blockToRTF indent alignment) bs blockToRTF indent alignment (Plain lst) = rtfCompact indent 0 alignment $ inlineListToRTF lst blockToRTF indent alignment (Para lst) = @@ -308,6 +310,7 @@ inlineListToRTF lst = concatMap inlineToRTF lst -- | Convert inline item to RTF. inlineToRTF :: Inline -- ^ inline to convert -> String +inlineToRTF (Span _ lst) = inlineListToRTF lst inlineToRTF (Emph lst) = "{\\i " ++ (inlineListToRTF lst) ++ "}" inlineToRTF (Strong lst) = "{\\b " ++ (inlineListToRTF lst) ++ "}" inlineToRTF (Strikeout lst) = "{\\strike " ++ (inlineListToRTF lst) ++ "}" diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs index 0f57d14b2..f8b460001 100644 --- a/src/Text/Pandoc/Writers/Texinfo.hs +++ b/src/Text/Pandoc/Writers/Texinfo.hs @@ -123,6 +123,8 @@ blockToTexinfo :: Block -- ^ Block to convert blockToTexinfo Null = return empty +blockToTexinfo (Div _ bs) = blockListToTexinfo bs + blockToTexinfo (Plain lst) = inlineListToTexinfo lst @@ -374,6 +376,9 @@ disallowedInNode c = c `elem` ".,:()" inlineToTexinfo :: Inline -- ^ Inline to convert -> State WriterState Doc +inlineToTexinfo (Span _ lst) = + inlineListToTexinfo lst + inlineToTexinfo (Emph lst) = inlineListToTexinfo lst >>= return . inCmd "emph" diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index 3288ce222..3fb554dca 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -101,6 +101,9 @@ blockToTextile :: WriterOptions -- ^ Options blockToTextile _ Null = return "" +blockToTextile opts (Div _ bs) = + blockListToTextile opts bs + blockToTextile opts (Plain inlines) = inlineListToTextile opts inlines @@ -343,6 +346,9 @@ inlineListToTextile opts lst = -- | Convert Pandoc inline element to Textile. inlineToTextile :: WriterOptions -> Inline -> State WriterState String +inlineToTextile opts (Span _ lst) = + inlineListToTextile opts lst + inlineToTextile opts (Emph lst) = do contents <- inlineListToTextile opts lst return $ if '_' `elem` contents -- cgit v1.2.3 From cbfa9321066212b912583481015224f3c944ae21 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 10 Aug 2013 17:23:51 -0700 Subject: Adjustments for new Format newtype. --- src/Text/Pandoc/Readers/HTML.hs | 4 ++-- src/Text/Pandoc/Readers/LaTeX.hs | 2 +- src/Text/Pandoc/Readers/RST.hs | 1 + src/Text/Pandoc/Readers/Textile.hs | 6 +++--- src/Text/Pandoc/Writers/AsciiDoc.hs | 8 ++++++-- src/Text/Pandoc/Writers/Custom.hs | 6 ++++++ src/Text/Pandoc/Writers/Docbook.hs | 9 +++++---- src/Text/Pandoc/Writers/Docx.hs | 10 +++++----- src/Text/Pandoc/Writers/EPUB.hs | 6 +++--- src/Text/Pandoc/Writers/HTML.hs | 13 ++++++++----- src/Text/Pandoc/Writers/LaTeX.hs | 13 ++++++++----- src/Text/Pandoc/Writers/Man.hs | 10 ++++++---- src/Text/Pandoc/Writers/MediaWiki.hs | 14 ++++++++------ src/Text/Pandoc/Writers/OpenDocument.hs | 12 +++++++----- src/Text/Pandoc/Writers/RST.hs | 15 +++++++++------ src/Text/Pandoc/Writers/RTF.hs | 12 +++++++----- src/Text/Pandoc/Writers/Texinfo.hs | 19 +++++++++++-------- src/Text/Pandoc/Writers/Textile.hs | 14 ++++++-------- tests/Tests/Arbitrary.hs | 8 ++++---- 19 files changed, 106 insertions(+), 76 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 0068ab5c1..7ca554fa3 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -182,7 +182,7 @@ pRawHtmlBlock = do raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag parseRaw <- getOption readerParseRaw if parseRaw && not (null raw) - then return [RawBlock "html" raw] + then return [RawBlock (Format "html") raw] else return [] pHtmlBlock :: String -> TagParser String @@ -408,7 +408,7 @@ pRawHtmlInline = do result <- pSatisfy (tagComment (const True)) <|> pSatisfy isInlineTag parseRaw <- getOption readerParseRaw if parseRaw - then return [RawInline "html" $ renderTags' [result]] + then return [RawInline (Format "html") $ renderTags' [result]] else return [] pInlinesInTags :: String -> ([Inline] -> Inline) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 6b5035d93..eb0baedda 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-} {- Copyright (C) 2006-2012 John MacFarlane diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 34962b553..df0a8294d 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2006-2010 John MacFarlane diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 9191f6908..8ccd1e227 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -290,13 +290,13 @@ rawHtmlBlock :: Parser [Char] ParserState Block rawHtmlBlock = try $ do (_,b) <- htmlTag isBlockTag optional blanklines - return $ RawBlock "html" b + return $ RawBlock (Format "html") b -- | Raw block of LaTeX content rawLaTeXBlock' :: Parser [Char] ParserState Block rawLaTeXBlock' = do guardEnabled Ext_raw_tex - RawBlock "latex" <$> (rawLaTeXBlock <* spaces) + RawBlock (Format "latex") <$> (rawLaTeXBlock <* spaces) -- | In textile, paragraphs are separated by blank lines. @@ -487,7 +487,7 @@ endline = try $ do return LineBreak rawHtmlInline :: Parser [Char] ParserState Inline -rawHtmlInline = RawInline "html" . snd <$> htmlTag isInlineTag +rawHtmlInline = RawInline (Format "html") . snd <$> htmlTag isInlineTag -- | Raw LaTeX Inline rawLaTeXInline' :: Parser [Char] ParserState Inline diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 00cea27e5..68b525742 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -132,7 +132,9 @@ blockToAsciiDoc opts (Para inlines) = do then text "\\" else empty return $ esc <> contents <> blankline -blockToAsciiDoc _ (RawBlock _ _) = return empty +blockToAsciiDoc _ (RawBlock f s) + | f == "asciidoc" = return $ text s + | otherwise = return empty blockToAsciiDoc _ HorizontalRule = return $ blankline <> text "'''''" <> blankline blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do @@ -347,7 +349,9 @@ inlineToAsciiDoc _ (Math InlineMath str) = return $ "latexmath:[$" <> text str <> "$]" inlineToAsciiDoc _ (Math DisplayMath str) = return $ "latexmath:[\\[" <> text str <> "\\]]" -inlineToAsciiDoc _ (RawInline _ _) = return empty +inlineToAsciiDoc _ (RawInline f s) + | f == "asciidoc" = return $ text s + | otherwise = return empty inlineToAsciiDoc _ (LineBreak) = return $ " +" <> cr inlineToAsciiDoc _ Space = return space inlineToAsciiDoc opts (Cite _ lst) = inlineListToAsciiDoc opts lst diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index c250a240e..0234e1e35 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -33,6 +33,7 @@ module Text.Pandoc.Writers.Custom ( writeCustom ) where import Text.Pandoc.Definition import Text.Pandoc.Options import Data.List ( intersperse ) +import Data.Char ( toLower ) import Scripting.Lua (LuaState, StackValue, callfunc) import qualified Scripting.Lua as Lua import Text.Pandoc.UTF8 (fromString, toString) @@ -78,6 +79,11 @@ instance StackValue a => StackValue [a] where return (Just lst) valuetype _ = Lua.TTABLE +instance StackValue Format where + push lua (Format f) = Lua.push lua (map toLower f) + peek l n = fmap Format `fmap` Lua.peek l n + valuetype _ = Lua.TSTRING + instance (StackValue a, StackValue b) => StackValue (M.Map a b) where push lua m = do let xs = M.toList m diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 2f415f3ee..3d150d19b 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2006-2010 John MacFarlane @@ -199,10 +200,10 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = in inTags True "orderedlist" attribs items blockToDocbook opts (DefinitionList lst) = inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst -blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block --- we allow html for compatibility with earlier versions of pandoc -blockToDocbook _ (RawBlock "html" str) = text str -- raw XML block -blockToDocbook _ (RawBlock _ _) = empty +blockToDocbook _ (RawBlock f str) + | f == "docbook" = text str -- raw XML block + | f == "html" = text str -- allow html for backwards compatibility + | otherwise = empty blockToDocbook _ HorizontalRule = empty -- not semantic blockToDocbook opts (Table caption aligns widths headers rows) = let captionDoc = if null caption diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index d93254971..2483e243f 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -460,8 +460,8 @@ blockToOpenXML opts (Para lst) = do contents <- inlinesToOpenXML opts lst return [mknode "w:p" [] (paraProps ++ contents)] blockToOpenXML _ (RawBlock format str) - | format == "openxml" = return [ x | Elem x <- parseXML str ] - | otherwise = return [] + | format == Format "openxml" = return [ x | Elem x <- parseXML str ] + | otherwise = return [] blockToOpenXML opts (BlockQuote blocks) = withParaProp (pStyle "BlockQuote") $ blocksToOpenXML opts blocks blockToOpenXML opts (CodeBlock attrs str) = @@ -653,8 +653,8 @@ inlineToOpenXML opts (Strikeout lst) = $ inlinesToOpenXML opts lst inlineToOpenXML _ LineBreak = return [br] inlineToOpenXML _ (RawInline f str) - | f == "openxml" = return [ x | Elem x <- parseXML str ] - | otherwise = return [] + | f == Format "openxml" = return [ x | Elem x <- parseXML str ] + | otherwise = return [] inlineToOpenXML opts (Quoted quoteType lst) = inlinesToOpenXML opts $ [Str open] ++ lst ++ [Str close] where (open, close) = case quoteType of @@ -688,7 +688,7 @@ inlineToOpenXML opts (Note bs) = do let notemarker = mknode "w:r" [] [ mknode "w:rPr" [] (rStyle "FootnoteRef") , mknode "w:footnoteRef" [] () ] - let notemarkerXml = RawInline "openxml" $ ppElement notemarker + let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs insertNoteRef (Para ils : xs) = Para (notemarkerXml : ils) : xs insertNoteRef xs = Para [notemarkerXml] : xs diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index fb756f196..ab14ff8a0 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -103,7 +103,7 @@ writeEPUB opts doc@(Pandoc meta _) = do Just img -> do let coverImage = "cover-image" ++ takeExtension img let cpContent = renderHtml $ writeHtml opts' - (Pandoc meta [RawBlock "html" $ "
\n\"cover\n
"]) + (Pandoc meta [RawBlock (Format "html") $ "
\n\"cover\n
"]) imgContent <- B.readFile img return ( [mkEntry "cover.xhtml" cpContent] , [mkEntry coverImage imgContent] ) @@ -422,7 +422,7 @@ transformInline opts sourceDir picsRef (Image lab (src,tit)) | isAbsoluteURI src = do raw <- makeSelfContained Nothing $ writeHtmlInline opts (Image lab (src,tit)) - return $ RawInline "html" raw + return $ RawInline (Format "html") raw | otherwise = do let src' = unEscapeString src pics <- readIORef picsRef @@ -438,7 +438,7 @@ transformInline opts sourceDir picsRef (Image lab (src,tit)) transformInline opts _ _ (x@(Math _ _)) | WebTeX _ <- writerHTMLMathMethod opts = do raw <- makeSelfContained Nothing $ writeHtmlInline opts x - return $ RawInline "html" raw + return $ RawInline (Format "html") raw transformInline _ _ _ x = return x writeHtmlInline :: WriterOptions -> Inline -> String diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 560c26c76..25079574e 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -410,8 +410,9 @@ blockToHtml opts (Para lst) = do blockToHtml opts (Div attr bs) = do contents <- blockListToHtml opts bs return $ addAttrs opts attr $ H.div $ nl opts >> contents >> nl opts -blockToHtml _ (RawBlock "html" str) = return $ preEscapedString str -blockToHtml _ (RawBlock _ _) = return mempty +blockToHtml _ (RawBlock f str) + | f == Format "html" = return $ preEscapedString str + | otherwise = return mempty blockToHtml opts (HorizontalRule) = return $ if writerHtml5 opts then H5.hr else H.hr blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do let tolhs = isEnabled Ext_literate_haskell opts && @@ -678,12 +679,14 @@ inlineToHtml opts inline = return $ case t of InlineMath -> m DisplayMath -> brtag >> m >> brtag ) - (RawInline "latex" str) -> case writerHTMLMathMethod opts of + (RawInline f str) + | f == Format "latex" -> + case writerHTMLMathMethod opts of LaTeXMathML _ -> do modify (\st -> st {stMath = True}) return $ toHtml str _ -> return mempty - (RawInline "html" str) -> return $ preEscapedString str - (RawInline _ _) -> return mempty + | f == Format "html" -> return $ preEscapedString str + | otherwise -> return mempty (Link [Str str] (s,_)) | "mailto:" `isPrefixOf` s && s == escapeURI ("mailto" ++ str) -> -- autolink diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 37de03e0f..d09ccc3b8 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -356,8 +356,10 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do Nothing -> rawCodeBlock Just h -> modify (\st -> st{ stHighlighting = True }) >> return (flush $ text h) -blockToLaTeX (RawBlock "latex" x) = return $ text x -blockToLaTeX (RawBlock _ _) = return empty +blockToLaTeX (RawBlock f x) + | f == Format "latex" || f == Format "tex" + = return $ text x + | otherwise = return empty blockToLaTeX (BulletList []) = return empty -- otherwise latex error blockToLaTeX (BulletList lst) = do incremental <- gets stIncremental @@ -630,9 +632,10 @@ inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$' inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]" -inlineToLaTeX (RawInline "latex" str) = return $ text str -inlineToLaTeX (RawInline "tex" str) = return $ text str -inlineToLaTeX (RawInline _ _) = return empty +inlineToLaTeX (RawInline f str) + | f == Format "latex" || f == Format "tex" + = return $ text str + | otherwise = return empty inlineToLaTeX (LineBreak) = return "\\\\" inlineToLaTeX Space = return space inlineToLaTeX (Link txt ('#':ident, _)) = do diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index ed66c7c2b..642a002d6 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -167,8 +167,9 @@ blockToMan opts (Para inlines) = do contents <- liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines return $ text ".PP" $$ contents -blockToMan _ (RawBlock "man" str) = return $ text str -blockToMan _ (RawBlock _ _) = return empty +blockToMan _ (RawBlock f str) + | f == Format "man" = return $ text str + | otherwise = return empty blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *" blockToMan opts (Header level _ inlines) = do contents <- inlineListToMan opts inlines @@ -333,8 +334,9 @@ inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str inlineToMan opts (Math DisplayMath str) = do contents <- inlineListToMan opts $ readTeXMath str return $ cr <> text ".RS" $$ contents $$ text ".RE" -inlineToMan _ (RawInline "man" str) = return $ text str -inlineToMan _ (RawInline _ _) = return empty +inlineToMan _ (RawInline f str) + | f == Format "man" = return $ text str + | otherwise = return empty inlineToMan _ (LineBreak) = return $ cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr inlineToMan _ Space = return space diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index fccf25753..4ffba1100 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -107,9 +107,10 @@ blockToMediaWiki opts (Para inlines) = do then "

" ++ contents ++ "

" else contents ++ if null listLevel then "\n" else "" -blockToMediaWiki _ (RawBlock "mediawiki" str) = return str -blockToMediaWiki _ (RawBlock "html" str) = return str -blockToMediaWiki _ (RawBlock _ _) = return "" +blockToMediaWiki _ (RawBlock f str) + | f == Format "mediawiki" = return str + | f == Format "html" = return str + | otherwise = return "" blockToMediaWiki _ HorizontalRule = return "\n-----\n" @@ -374,9 +375,10 @@ inlineToMediaWiki _ (Str str) = return $ escapeString str inlineToMediaWiki _ (Math _ str) = return $ "" ++ str ++ "" -- note: str should NOT be escaped -inlineToMediaWiki _ (RawInline "mediawiki" str) = return str -inlineToMediaWiki _ (RawInline "html" str) = return str -inlineToMediaWiki _ (RawInline _ _) = return "" +inlineToMediaWiki _ (RawInline f str) + | f == Format "mediawiki" = return str + | f == Format "html" = return str + | otherwise = return "" inlineToMediaWiki _ (LineBreak) = return "
" diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index d76d0f6ad..05c576c20 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE PatternGuards #-} +{-# LANGUAGE PatternGuards, OverloadedStrings #-} {- Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane. @@ -296,7 +296,9 @@ blockToOpenDocument o bs | Table c a w h r <- bs = setFirstPara >> table c a w h r | HorizontalRule <- bs = setFirstPara >> return (selfClosingTag "text:p" [ ("text:style-name", "Horizontal_20_Line") ]) - | RawBlock _ _ <- bs = return empty + | RawBlock f s <- bs = if f == "opendocument" + then preformatted s + else return empty | Null <- bs = return empty | otherwise = return empty where @@ -374,9 +376,9 @@ inlineToOpenDocument o ils | Code _ s <- ils = preformatted s | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s) | Cite _ l <- ils = inlinesToOpenDocument o l - | RawInline "opendocument" s <- ils = preformatted s - | RawInline "html" s <- ils = preformatted s -- for backwards compat. - | RawInline _ _ <- ils = return empty + | RawInline f s <- ils = if f == "opendocument" || f == "html" + then preformatted s + else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l | Image _ (s,t) <- ils = return $ mkImg s t | Note l <- ils = mkNote l diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 4d8daa15b..5fbbb6afc 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -42,7 +42,7 @@ import Network.URI (isAbsoluteURI) import Text.Pandoc.Pretty import Control.Monad.State import Control.Applicative ( (<$>) ) -import Data.Char (isSpace) +import Data.Char (isSpace, toLower) type Refs = [([Inline], Target)] @@ -176,9 +176,11 @@ blockToRST (Para inlines) | otherwise = do contents <- inlineListToRST inlines return $ contents <> blankline -blockToRST (RawBlock f str) = - return $ blankline <> ".. raw:: " <> text f $+$ - (nest 3 $ text str) $$ blankline +blockToRST (RawBlock f str) + | f == "rst" = return $ text str + | otherwise = return $ blankline <> ".. raw:: " <> + text (map toLower $ unFormat f) $+$ + (nest 3 $ text str) $$ blankline blockToRST HorizontalRule = return $ blankline $$ "--------------" $$ blankline blockToRST (Header level _ inlines) = do @@ -374,8 +376,9 @@ inlineToRST (Math t str) = do then blankline $$ ".. math::" $$ blankline $$ nest 3 (text str) $$ blankline else blankline $$ (".. math:: " <> text str) $$ blankline -inlineToRST (RawInline "rst" x) = return $ text x -inlineToRST (RawInline _ _) = return empty +inlineToRST (RawInline f x) + | f == "rst" = return $ text x + | otherwise = return empty inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para) inlineToRST Space = return space -- autolink diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 7e5d33c50..6d2b1229d 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -62,7 +62,7 @@ rtfEmbedImage x@(Image _ (src,_)) = do let raw = "{\\pict" ++ filetype ++ " " ++ concat bytes ++ "}" return $ if B.null imgdata then x - else RawInline "rtf" raw + else RawInline (Format "rtf") raw else return x rtfEmbedImage x = return x @@ -218,8 +218,9 @@ blockToRTF indent alignment (BlockQuote lst) = concatMap (blockToRTF (indent + indentIncrement) alignment) lst blockToRTF indent _ (CodeBlock _ str) = rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str)) -blockToRTF _ _ (RawBlock "rtf" str) = str -blockToRTF _ _ (RawBlock _ _) = "" +blockToRTF _ _ (RawBlock f str) + | f == Format "rtf" = str + | otherwise = "" blockToRTF indent alignment (BulletList lst) = spaceAtEnd $ concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $ @@ -325,8 +326,9 @@ inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}" inlineToRTF (Str str) = stringToRTF str inlineToRTF (Math _ str) = inlineListToRTF $ readTeXMath str inlineToRTF (Cite _ lst) = inlineListToRTF lst -inlineToRTF (RawInline "rtf" str) = str -inlineToRTF (RawInline _ _) = "" +inlineToRTF (RawInline f str) + | f == Format "rtf" = str + | otherwise = "" inlineToRTF (LineBreak) = "\\line " inlineToRTF Space = " " inlineToRTF (Link text (src, _)) = diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs index f8b460001..b1fd3d6af 100644 --- a/src/Text/Pandoc/Writers/Texinfo.hs +++ b/src/Text/Pandoc/Writers/Texinfo.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2008-2010 John MacFarlane and Peter Wang @@ -152,10 +153,11 @@ blockToTexinfo (CodeBlock _ str) = do flush (text str) $$ text "@end verbatim" <> blankline -blockToTexinfo (RawBlock "texinfo" str) = return $ text str -blockToTexinfo (RawBlock "latex" str) = - return $ text "@tex" $$ text str $$ text "@end tex" -blockToTexinfo (RawBlock _ _) = return empty +blockToTexinfo (RawBlock f str) + | f == "texinfo" = return $ text str + | f == "latex" || f == "tex" = + return $ text "@tex" $$ text str $$ text "@end tex" + | otherwise = return empty blockToTexinfo (BulletList lst) = do items <- mapM listItemToTexinfo lst @@ -418,10 +420,11 @@ inlineToTexinfo (Cite _ lst) = inlineListToTexinfo lst inlineToTexinfo (Str str) = return $ text (stringToTexinfo str) inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str -inlineToTexinfo (RawInline f str) | f == "latex" || f == "tex" = - return $ text "@tex" $$ text str $$ text "@end tex" -inlineToTexinfo (RawInline "texinfo" str) = return $ text str -inlineToTexinfo (RawInline _ _) = return empty +inlineToTexinfo (RawInline f str) + | f == "latex" || f == "tex" = + return $ text "@tex" $$ text str $$ text "@end tex" + | f == "texinfo" = return $ text str + | otherwise = return empty inlineToTexinfo (LineBreak) = return $ text "@*" inlineToTexinfo Space = return $ char ' ' diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index 3fb554dca..27e8b60ec 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -121,10 +121,9 @@ blockToTextile opts (Para inlines) = do then "

" ++ contents ++ "

" else contents ++ if null listLevel then "\n" else "" -blockToTextile _ (RawBlock f str) = - if f == "html" || f == "textile" - then return str - else return "" +blockToTextile _ (RawBlock f str) + | f == Format "html" || f == Format "textile" = return str + | otherwise = return "" blockToTextile _ HorizontalRule = return "
\n" @@ -401,10 +400,9 @@ inlineToTextile _ (Str str) = return $ escapeStringForTextile str inlineToTextile _ (Math _ str) = return $ "" ++ escapeStringForXML str ++ "" -inlineToTextile _ (RawInline f str) = - if f == "html" || f == "textile" - then return str - else return "" +inlineToTextile _ (RawInline f str) + | f == Format "html" || f == Format "textile" = return str + | otherwise = return "" inlineToTextile _ (LineBreak) = return "\n" diff --git a/tests/Tests/Arbitrary.hs b/tests/Tests/Arbitrary.hs index 5939d088d..31c0cb46a 100644 --- a/tests/Tests/Arbitrary.hs +++ b/tests/Tests/Arbitrary.hs @@ -41,8 +41,8 @@ arbInline :: Int -> Gen Inline arbInline n = frequency $ [ (60, liftM Str realString) , (60, return Space) , (10, liftM2 Code arbAttr realString) - , (5, elements [ RawInline "html" "" - , RawInline "latex" "\\my{command}" ]) + , (5, elements [ RawInline (Format "html") "" + , RawInline (Format "latex") "\\my{command}" ]) ] ++ [ x | x <- nesters, n > 1] where nesters = [ (10, liftM Emph $ arbInlines (n-1)) , (10, liftM Strong $ arbInlines (n-1)) @@ -74,9 +74,9 @@ arbBlock :: Int -> Gen Block arbBlock n = frequency $ [ (10, liftM Plain $ arbInlines (n-1)) , (15, liftM Para $ arbInlines (n-1)) , (5, liftM2 CodeBlock arbAttr realString) - , (2, elements [ RawBlock "html" + , (2, elements [ RawBlock (Format "html") "
\n*&*\n
" - , RawBlock "latex" + , RawBlock (Format "latex") "\\begin[opt]{env}\nhi\n{\\end{env}" ]) , (5, do x1 <- choose (1 :: Int, 6) -- cgit v1.2.3 From 9152fa1a95346e26bc290b3f5018b2eeb5d4e077 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 10 Aug 2013 18:13:38 -0700 Subject: Use query instead of queryWith. --- src/Text/Pandoc/Biblio.hs | 5 +++-- src/Text/Pandoc/Shared.hs | 29 +++++++++++++++++++++++++++-- src/Text/Pandoc/Writers/ConTeXt.hs | 4 ++-- src/Text/Pandoc/Writers/LaTeX.hs | 7 ++++--- 4 files changed, 36 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index 755c779ea..206b38530 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -36,6 +36,7 @@ import Text.CSL hiding ( Cite(..), Citation(..), endWithPunct ) import qualified Text.CSL as CSL ( Cite(..) ) import Text.Pandoc.Definition import Text.Pandoc.Generic +import Text.Pandoc.Walk import Text.Pandoc.Shared (stringify) import Text.Parsec hiding (State) import Control.Monad @@ -48,7 +49,7 @@ processBiblio Nothing _ p = p processBiblio _ [] p = p processBiblio (Just style) r p = let p' = evalState (bottomUpM setHash p) 1 - grps = queryWith getCitation p' + grps = query getCitation p' result = citeproc procOpts style r (setNearNote style $ map (map toCslCite) grps) cits_map = M.fromList $ zip grps (citations result) @@ -121,7 +122,7 @@ isTextualCitation (c:_) = citationMode c == AuthorInText isTextualCitation _ = False -- | Retrieve all citations from a 'Pandoc' docuument. To be used with --- 'queryWith'. +-- 'query'. getCitation :: Inline -> [[Citation]] getCitation i | Cite t _ <- i = [t] | otherwise = [] diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 09874299d..2b692dc3c 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DeriveDataTypeable, CPP #-} +{-# LANGUAGE DeriveDataTypeable, CPP, MultiParamTypeClasses #-} {- Copyright (C) 2006-2013 John MacFarlane @@ -79,6 +79,7 @@ module Text.Pandoc.Shared ( ) where import Text.Pandoc.Definition +import Text.Pandoc.Walk import Text.Pandoc.Generic import Text.Pandoc.Builder (Blocks, ToMetaValue(..)) import qualified Text.Pandoc.Builder as B @@ -105,6 +106,7 @@ import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..), renderOptions) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as B8 +import Text.Pandoc.Compat.Monoid #ifdef EMBED_DATA_FILES import Text.Pandoc.Data (dataFiles) @@ -383,7 +385,7 @@ consolidateInlines [] = [] -- | Convert list of inlines to a string with formatting removed. stringify :: [Inline] -> String -stringify = queryWith go +stringify = query go where go :: Inline -> [Char] go Space = " " go (Str x) = x @@ -433,6 +435,29 @@ data Element = Blk Block -- lvl num attributes label contents deriving (Eq, Read, Show, Typeable, Data) +instance Walkable Inline Element where + walk f (Blk x) = Blk (walk f x) + walk f (Sec lev nums attr ils elts) = Sec lev nums attr (walk f ils) (walk f elts) + walkM f (Blk x) = Blk `fmap` walkM f x + walkM f (Sec lev nums attr ils elts) = do + ils' <- walkM f ils + elts' <- walkM f elts + return $ Sec lev nums attr ils' elts' + query f (Blk x) = query f x + query f (Sec _ _ _ ils elts) = query f ils <> query f elts + +instance Walkable Block Element where + walk f (Blk x) = Blk (walk f x) + walk f (Sec lev nums attr ils elts) = Sec lev nums attr (walk f ils) (walk f elts) + walkM f (Blk x) = Blk `fmap` walkM f x + walkM f (Sec lev nums attr ils elts) = do + ils' <- walkM f ils + elts' <- walkM f elts + return $ Sec lev nums attr ils' elts' + query f (Blk x) = query f x + query f (Sec _ _ _ ils elts) = query f ils <> query f elts + + -- | Convert Pandoc inline list to plain text identifier. HTML -- identifiers must start with a letter, and may contain only -- letters, digits, and the characters _-. diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 40dc1deb5..0379f8b0a 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -33,7 +33,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared import Text.Pandoc.Options -import Text.Pandoc.Generic (queryWith) +import Text.Pandoc.Walk (query) import Text.Printf ( printf ) import Data.List ( intercalate, isPrefixOf ) import Control.Monad.State @@ -326,7 +326,7 @@ inlineToConTeXt (Note contents) = do contents' <- blockListToConTeXt contents let codeBlock x@(CodeBlock _ _) = [x] codeBlock _ = [] - let codeBlocks = queryWith codeBlock contents + let codeBlocks = query codeBlock contents return $ if null codeBlocks then text "\\footnote{" <> nest 2 contents' <> char '}' else text "\\startbuffer " <> nest 2 contents' <> diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index d09ccc3b8..860ca8349 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -30,6 +30,7 @@ Conversion of 'Pandoc' format into LaTeX. -} module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where import Text.Pandoc.Definition +import Text.Pandoc.Walk import Text.Pandoc.Generic import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared @@ -86,7 +87,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do -- see if there are internal links let isInternalLink (Link _ ('#':xs,_)) = [xs] isInternalLink _ = [] - modify $ \s -> s{ stInternalLinks = queryWith isInternalLink blocks } + modify $ \s -> s{ stInternalLinks = query isInternalLink blocks } let template = writerTemplate options -- set stBook depending on documentclass let bookClasses = ["memoir","book","report","scrreprt","scrbook"] @@ -248,9 +249,9 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts) let hasCode (Code _ _) = [True] hasCode _ = [] opts <- gets stOptions - let fragile = not $ null $ queryWith hasCodeBlock elts ++ + let fragile = not $ null $ query hasCodeBlock elts ++ if writerListings opts - then queryWith hasCode elts + then query hasCode elts else [] let allowframebreaks = "allowframebreaks" `elem` classes let optionslist = ["fragile" | fragile] ++ -- cgit v1.2.3 From 02a125d0aa8becd258c99b27c5e30116f0cbacb4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 10 Aug 2013 18:45:00 -0700 Subject: Use walk, walkM in place of bottomUp, bottomUpM when possible. They are significantly faster. --- src/Text/Pandoc/PDF.hs | 4 ++-- src/Text/Pandoc/Readers/LaTeX.hs | 4 ++-- src/Text/Pandoc/Readers/MediaWiki.hs | 4 ++-- src/Text/Pandoc/Shared.hs | 2 +- src/Text/Pandoc/Writers/Docx.hs | 11 ++++++----- src/Text/Pandoc/Writers/EPUB.hs | 6 +++--- src/Text/Pandoc/Writers/FB2.hs | 8 ++++++-- src/Text/Pandoc/Writers/LaTeX.hs | 3 +-- src/Text/Pandoc/Writers/Markdown.hs | 8 ++++---- src/Text/Pandoc/Writers/ODT.hs | 4 ++-- src/Text/Pandoc/Writers/RTF.hs | 4 ++-- 11 files changed, 31 insertions(+), 27 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index b030e2ca7..ce20ac1b4 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -44,7 +44,7 @@ import Data.List (isInfixOf) import qualified Data.ByteString.Base64 as B64 import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Definition -import Text.Pandoc.Generic (bottomUpM) +import Text.Pandoc.Walk (walkM) import Text.Pandoc.Shared (fetchItem, warn) import Text.Pandoc.Options (WriterOptions(..)) import Text.Pandoc.MIME (extensionFromMimeType) @@ -73,7 +73,7 @@ handleImages :: String -- ^ source directory/base URL -> FilePath -- ^ temp dir to store images -> Pandoc -- ^ document -> IO Pandoc -handleImages baseURL tmpdir = bottomUpM (handleImage' baseURL tmpdir) +handleImages baseURL tmpdir = walkM (handleImage' baseURL tmpdir) handleImage' :: String -> FilePath diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index eb0baedda..71e1e0ac2 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -35,7 +35,7 @@ module Text.Pandoc.Readers.LaTeX ( readLaTeX, ) where import Text.Pandoc.Definition -import Text.Pandoc.Generic +import Text.Pandoc.Walk import Text.Pandoc.Shared import Text.Pandoc.Options import Text.Pandoc.Biblio (processBiblio) @@ -815,7 +815,7 @@ keyvals :: LP [(String, String)] keyvals = try $ char '[' *> manyTill keyval (char ']') alltt :: String -> LP Blocks -alltt t = bottomUp strToCode <$> parseFromString blocks +alltt t = walk strToCode <$> parseFromString blocks (substitute " " "\\ " $ substitute "%" "\\%" $ concat $ intersperse "\\\\\n" $ lines t) where strToCode (Str s) = Code nullAttr s diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 56049e035..8f1ff2776 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -42,7 +42,7 @@ import Text.Pandoc.Options import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag ) import Text.Pandoc.XML ( fromEntities ) import Text.Pandoc.Parsing hiding ( nested ) -import Text.Pandoc.Generic ( bottomUp ) +import Text.Pandoc.Walk ( walk ) import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead ) import Data.Monoid (mconcat, mempty) import Control.Applicative ((<$>), (<*), (*>), (<$)) @@ -342,7 +342,7 @@ preformatted = try $ do spacesStr _ = False if F.all spacesStr contents then return mempty - else return $ B.para $ bottomUp strToCode contents + else return $ B.para $ walk strToCode contents header :: MWParser Blocks header = try $ do diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 2b692dc3c..6fd78b188 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -518,7 +518,7 @@ isHeaderBlock _ = False -- | Shift header levels up or down. headerShift :: Int -> Pandoc -> Pandoc -headerShift n = bottomUp shift +headerShift n = walk shift where shift :: Block -> Block shift (Header level attr inner) = Header (level + n) attr inner shift x = x diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 2483e243f..aa618b2cc 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -45,6 +45,7 @@ import Text.Pandoc.Shared hiding (Element) import Text.Pandoc.Options import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Highlighting ( highlight ) +import Text.Pandoc.Walk import Text.Highlighting.Kate.Types () import Text.XML.Light import Text.TeXMath @@ -108,7 +109,7 @@ writeDocx :: WriterOptions -- ^ Writer options -> IO BL.ByteString writeDocx opts doc@(Pandoc meta _) = do let datadir = writerUserDataDir opts - let doc' = bottomUp (concatMap fixDisplayMath) doc + let doc' = walk fixDisplayMath doc refArchive <- liftM (toArchive . toLazy) $ case writerReferenceDocx opts of Just f -> B.readFile f @@ -810,17 +811,17 @@ stripLeadingTrailingSpace = go . reverse . go . reverse where go (Space:xs) = xs go xs = xs -fixDisplayMath :: Block -> [Block] +fixDisplayMath :: Block -> Block fixDisplayMath (Plain lst) | any isDisplayMath lst && not (all isDisplayMath lst) = -- chop into several paragraphs so each displaymath is its own - map (Plain . stripLeadingTrailingSpace) $ + Div ("",["math"],[]) $ map (Plain . stripLeadingTrailingSpace) $ groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || not (isDisplayMath x || isDisplayMath y)) lst fixDisplayMath (Para lst) | any isDisplayMath lst && not (all isDisplayMath lst) = -- chop into several paragraphs so each displaymath is its own - map (Para . stripLeadingTrailingSpace) $ + Div ("",["math"],[]) $ map (Para . stripLeadingTrailingSpace) $ groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || not (isDisplayMath x || isDisplayMath y)) lst -fixDisplayMath x = [x] +fixDisplayMath x = x diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index ab14ff8a0..fa2b45036 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -48,7 +48,7 @@ import qualified Text.Pandoc.Shared as Shared import Text.Pandoc.Builder (fromList, setMeta) import Text.Pandoc.Options import Text.Pandoc.Definition -import Text.Pandoc.Generic +import Text.Pandoc.Walk import Control.Monad.State import Text.XML.Light hiding (ppTopElement) import Text.Pandoc.UUID @@ -116,7 +116,7 @@ writeEPUB opts doc@(Pandoc meta _) = do -- handle pictures picsRef <- newIORef [] - Pandoc _ blocks <- bottomUpM + Pandoc _ blocks <- walkM (transformInline opts' sourceDir picsRef) doc pics <- readIORef picsRef let readPicEntry entries (oldsrc, newsrc) = do @@ -520,7 +520,7 @@ correlateRefs chapterHeaderLevel bs = -- Replace internal link references using the table produced -- by correlateRefs. replaceRefs :: [(String,String)] -> [Block] -> [Block] -replaceRefs refTable = bottomUp replaceOneRef +replaceRefs refTable = walk replaceOneRef where replaceOneRef x@(Link lab ('#':xs,tit)) = case lookup xs refTable of Just url -> Link lab (url,tit) diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs index 2576b2dc2..adbe948be 100644 --- a/src/Text/Pandoc/Writers/FB2.hs +++ b/src/Text/Pandoc/Writers/FB2.hs @@ -45,7 +45,7 @@ import qualified Text.XML.Light.Cursor as XC import Text.Pandoc.Definition import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def) import Text.Pandoc.Shared (orderedListMarkers) -import Text.Pandoc.Generic (bottomUp) +import Text.Pandoc.Walk -- | Data to be written at the end of the document: -- (foot)notes, URLs, references, images. @@ -423,6 +423,10 @@ indent = indentBlock indentLines ins = let lns = split isLineBreak ins :: [[Inline]] in intercalate [LineBreak] $ map ((Str spacer):) lns +capitalize :: Inline -> Inline +capitalize (Str xs) = Str $ map toUpper xs +capitalize x = x + -- | Convert a Pandoc's Inline element to FictionBook XML representation. toXml :: Inline -> FBM [Content] toXml (Str s) = return [txt s] @@ -432,7 +436,7 @@ toXml (Strong ss) = list `liftM` wrap "strong" ss toXml (Strikeout ss) = list `liftM` wrap "strikethrough" ss toXml (Superscript ss) = list `liftM` wrap "sup" ss toXml (Subscript ss) = list `liftM` wrap "sub" ss -toXml (SmallCaps ss) = cMapM toXml $ bottomUp (map toUpper) ss +toXml (SmallCaps ss) = cMapM toXml $ walk capitalize ss toXml (Quoted SingleQuote ss) = do -- FIXME: should be language-specific inner <- cMapM toXml ss return $ [txt "‘"] ++ inner ++ [txt "’"] diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 860ca8349..7f9a99801 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -31,7 +31,6 @@ Conversion of 'Pandoc' format into LaTeX. module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where import Text.Pandoc.Definition import Text.Pandoc.Walk -import Text.Pandoc.Generic import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared import Text.Pandoc.Options @@ -498,7 +497,7 @@ sectionHeader unnumbered ref level lst = do txt <- inlineListToLaTeX lst let noNote (Note _) = Str "" noNote x = x - let lstNoNotes = bottomUp noNote lst + let lstNoNotes = walk noNote lst let star = if unnumbered then text "*" else empty -- footnotes in sections don't work unless you specify an optional -- argument: \section[mysec]{mysec\footnote{blah}} diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index d195d8445..3d0ed8702 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -32,7 +32,7 @@ Markdown: -} module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where import Text.Pandoc.Definition -import Text.Pandoc.Generic +import Text.Pandoc.Walk import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared @@ -82,7 +82,7 @@ writePlain opts document = where document' = plainify document plainify :: Pandoc -> Pandoc -plainify = bottomUp go +plainify = walk go where go :: Inline -> Inline go (Emph xs) = SmallCaps xs go (Strong xs) = SmallCaps xs @@ -643,13 +643,13 @@ inlineToMarkdown opts (Strikeout lst) = do then "~~" <> contents <> "~~" else "" <> contents <> "" inlineToMarkdown opts (Superscript lst) = do - let lst' = bottomUp escapeSpaces lst + let lst' = walk escapeSpaces lst contents <- inlineListToMarkdown opts lst' return $ if isEnabled Ext_superscript opts then "^" <> contents <> "^" else "" <> contents <> "" inlineToMarkdown opts (Subscript lst) = do - let lst' = bottomUp escapeSpaces lst + let lst' = walk escapeSpaces lst contents <- inlineListToMarkdown opts lst' return $ if isEnabled Ext_subscript opts then "~" <> contents <> "~" diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 589010bb9..fb94d9ffb 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -39,7 +39,7 @@ import Text.Pandoc.Shared ( stringify, readDataFile, fetchItem, warn ) import Text.Pandoc.ImageSize ( imageSize, sizeInPoints ) import Text.Pandoc.MIME ( getMimeType ) import Text.Pandoc.Definition -import Text.Pandoc.Generic +import Text.Pandoc.Walk import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) import Control.Monad (liftM) import Text.Pandoc.XML @@ -63,7 +63,7 @@ writeODT opts doc@(Pandoc meta _) = do -- handle pictures picEntriesRef <- newIORef ([] :: [Entry]) let sourceDir = writerSourceDirectory opts - doc' <- bottomUpM (transformPic sourceDir picEntriesRef) doc + doc' <- walkM (transformPic sourceDir picEntriesRef) doc let newContents = writeOpenDocument opts{writerWrapText = False} doc' epochtime <- floor `fmap` getPOSIXTime let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 6d2b1229d..0e8ce2ece 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -34,7 +34,7 @@ import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Templates (renderTemplate') -import Text.Pandoc.Generic (bottomUpM) +import Text.Pandoc.Walk import Data.List ( isSuffixOf, intercalate ) import Data.Char ( ord, chr, isDigit, toLower ) import System.FilePath ( takeExtension ) @@ -70,7 +70,7 @@ rtfEmbedImage x = return x -- images embedded as encoded binary data. writeRTFWithEmbeddedImages :: WriterOptions -> Pandoc -> IO String writeRTFWithEmbeddedImages options doc = - writeRTF options `fmap` bottomUpM rtfEmbedImage doc + writeRTF options `fmap` walkM rtfEmbedImage doc -- | Convert Pandoc to a string in rich text format. writeRTF :: WriterOptions -> Pandoc -> String -- cgit v1.2.3 From e279175ea517e2df65fe5d716bc02e383b04fc36 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 11 Aug 2013 15:58:09 -0700 Subject: Options: Changed `writerSourceDir` to `writerSourceURL` (now a Maybe). Previously we used to store the directory of the first input file, even if it was local, and used this as a base directory for finding images in ODT, EPUB, Docx, and PDF. This has been confusing to many users. It seems better to look for images relative to the current working directory, even if the first file argument is in another directory. writerSourceURL is set to 'Just url' when the first command-line argument is an absolute URL. (So, relative links will be resolved in relation to the first page.) Otherwise, 'Nothing'. The ODT, EPUB, Docx, and PDF writers have been modified accordingly. Note that this change may break some existing workflows. If you have been assuming that relative links will be interpreted relative to the directory of the first file argument, you'll need to make that the current directory before running pandoc. Closes #942. --- pandoc.hs | 12 +++++++----- src/Text/Pandoc/Options.hs | 4 ++-- src/Text/Pandoc/PDF.hs | 6 +++--- src/Text/Pandoc/Shared.hs | 20 ++++++++++---------- src/Text/Pandoc/Writers/Docx.hs | 3 +-- src/Text/Pandoc/Writers/EPUB.hs | 21 +++++++-------------- src/Text/Pandoc/Writers/ODT.hs | 9 ++++----- 7 files changed, 34 insertions(+), 41 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.hs b/pandoc.hs index fdf0b35b7..81672e16c 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -1034,13 +1034,15 @@ main = do return $ Just csl { CSL.styleAbbrevs = abbrevs } else return Nothing - let sourceDir = case sources of - [] -> "." + let sourceURL = case sources of + [] -> Nothing (x:_) -> case parseURI x of Just u | uriScheme u `elem` ["http:","https:"] -> - show u{ uriPath = "", uriQuery = "", uriFragment = "" } - _ -> takeDirectory x + Just $ show u{ uriPath = "", + uriQuery = "", + uriFragment = "" } + _ -> Nothing let readerOpts = def{ readerSmart = smart || (texLigatures && (laTeXOutput || "context" `isPrefixOf` writerName')) @@ -1074,7 +1076,7 @@ main = do writerColumns = columns, writerEmailObfuscation = obfuscationMethod, writerIdentifierPrefix = idPrefix, - writerSourceDirectory = sourceDir, + writerSourceURL = sourceURL, writerUserDataDir = datadir, writerHtml5 = html5, writerHtmlQTags = htmlQTags, diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 61a85cf6e..c7c37d6b8 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -286,7 +286,7 @@ data WriterOptions = WriterOptions , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML -- and for footnote marks in markdown - , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file + , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory , writerCiteMethod :: CiteMethod -- ^ How to print cites , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations @@ -329,7 +329,7 @@ instance Default WriterOptions where , writerColumns = 72 , writerEmailObfuscation = JavascriptObfuscation , writerIdentifierPrefix = "" - , writerSourceDirectory = "." + , writerSourceURL = Nothing , writerUserDataDir = Nothing , writerCiteMethod = Citeproc , writerBiblioFiles = [] diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index ce20ac1b4..ae611bc37 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -65,17 +65,17 @@ makePDF :: String -- ^ pdf creator (pdflatex, lualatex, xelatex) -> Pandoc -- ^ document -> IO (Either ByteString ByteString) makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do - doc' <- handleImages (writerSourceDirectory opts) tmpdir doc + doc' <- handleImages (writerSourceURL opts) tmpdir doc let source = writer opts doc' tex2pdf' tmpdir program source -handleImages :: String -- ^ source directory/base URL +handleImages :: Maybe String -- ^ source base URL -> FilePath -- ^ temp dir to store images -> Pandoc -- ^ document -> IO Pandoc handleImages baseURL tmpdir = walkM (handleImage' baseURL tmpdir) -handleImage' :: String +handleImage' :: Maybe String -> FilePath -> Inline -> IO Inline diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 6fd78b188..d670a35bc 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -612,18 +612,18 @@ readDataFileUTF8 userDir fname = -- | Fetch an image or other item from the local filesystem or the net. -- Returns raw content and maybe mime type. -fetchItem :: String -> String +fetchItem :: Maybe String -> String -> IO (Either E.SomeException (BS.ByteString, Maybe String)) -fetchItem sourceDir s = - case s of - _ | isAbsoluteURI s -> openURL s - | isAbsoluteURI sourceDir -> openURL $ sourceDir ++ "/" ++ s - | otherwise -> E.try $ do +fetchItem sourceURL s + | isAbsoluteURI s = openURL s + | otherwise = case sourceURL of + Just u -> openURL (u ++ "/" ++ s) + Nothing -> E.try readLocalFile + where readLocalFile = do let mime = case takeExtension s of - ".gz" -> getMimeType $ dropExtension s - x -> getMimeType x - let f = sourceDir s - cont <- BS.readFile f + ".gz" -> getMimeType $ dropExtension s + x -> getMimeType x + cont <- BS.readFile s return (cont, mime) -- | Read from a URL and return raw data and maybe mime type. diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index aa618b2cc..c8673ae48 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -728,8 +728,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do case M.lookup src imgs of Just (_,_,_,elt,_) -> return [elt] Nothing -> do - let sourceDir = writerSourceDirectory opts - res <- liftIO $ fetchItem sourceDir src + res <- liftIO $ fetchItem (writerSourceURL opts) src case res of Left (_ :: E.SomeException) -> do liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..." diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index fa2b45036..ac0e7610c 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -55,7 +55,7 @@ import Text.Pandoc.UUID import Text.Pandoc.Writers.HTML import Text.Pandoc.Writers.Markdown ( writePlain ) import Data.Char ( toLower ) -import Network.URI ( isAbsoluteURI, unEscapeString ) +import Network.URI ( unEscapeString ) import Text.Pandoc.MIME (getMimeType) #if MIN_VERSION_base(4,6,0) #else @@ -93,7 +93,6 @@ writeEPUB opts doc@(Pandoc meta _) = do then MathML Nothing else writerHTMLMathMethod opts , writerWrapText = False } - let sourceDir = writerSourceDirectory opts' let mbCoverImage = lookup "epub-cover-image" vars -- cover page @@ -117,10 +116,10 @@ writeEPUB opts doc@(Pandoc meta _) = do -- handle pictures picsRef <- newIORef [] Pandoc _ blocks <- walkM - (transformInline opts' sourceDir picsRef) doc + (transformInline opts' picsRef) doc pics <- readIORef picsRef let readPicEntry entries (oldsrc, newsrc) = do - res <- fetchItem sourceDir oldsrc + res <- fetchItem (writerSourceURL opts') oldsrc case res of Left _ -> do warn $ "Could not find image `" ++ oldsrc ++ "', skipping..." @@ -414,19 +413,13 @@ showDateTimeISO8601 :: UTCTime -> String showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ" transformInline :: WriterOptions - -> FilePath -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images -> Inline -> IO Inline -transformInline opts sourceDir picsRef (Image lab (src,tit)) - | isAbsoluteURI src = do - raw <- makeSelfContained Nothing - $ writeHtmlInline opts (Image lab (src,tit)) - return $ RawInline (Format "html") raw - | otherwise = do +transformInline opts picsRef (Image lab (src,tit)) = do let src' = unEscapeString src pics <- readIORef picsRef - let oldsrc = sourceDir src' + let oldsrc = maybe src' ( src) $ writerSourceURL opts let ext = takeExtension src' newsrc <- case lookup oldsrc pics of Just n -> return n @@ -435,11 +428,11 @@ transformInline opts sourceDir picsRef (Image lab (src,tit)) modifyIORef picsRef ( (oldsrc, new): ) return new return $ Image lab (newsrc, tit) -transformInline opts _ _ (x@(Math _ _)) +transformInline opts _ (x@(Math _ _)) | WebTeX _ <- writerHTMLMathMethod opts = do raw <- makeSelfContained Nothing $ writeHtmlInline opts x return $ RawInline (Format "html") raw -transformInline _ _ _ x = return x +transformInline _ _ x = return x writeHtmlInline :: WriterOptions -> Inline -> String writeHtmlInline opts z = trimr $ diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index fb94d9ffb..751a323f5 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -62,8 +62,7 @@ writeODT opts doc@(Pandoc meta _) = do readDataFile datadir "reference.odt" -- handle pictures picEntriesRef <- newIORef ([] :: [Entry]) - let sourceDir = writerSourceDirectory opts - doc' <- walkM (transformPic sourceDir picEntriesRef) doc + doc' <- walkM (transformPic opts picEntriesRef) doc let newContents = writeOpenDocument opts{writerWrapText = False} doc' epochtime <- floor `fmap` getPOSIXTime let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents @@ -111,9 +110,9 @@ writeODT opts doc@(Pandoc meta _) = do let archive'' = addEntryToArchive metaEntry archive' return $ fromArchive archive'' -transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline -transformPic sourceDir entriesRef (Image lab (src,_)) = do - res <- fetchItem sourceDir src +transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline +transformPic opts entriesRef (Image lab (src,_)) = do + res <- fetchItem (writerSourceURL opts) src case res of Left (_ :: E.SomeException) -> do warn $ "Could not find image `" ++ src ++ "', skipping..." -- cgit v1.2.3 From eb0c0b86ed518982eb5d3336e73ff5cb1d59d87c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 11 Aug 2013 17:13:46 -0700 Subject: ODT/OpenDocument writer: Minor changes for ODF 1.2 conformance. See #939. We leave the nonconforming contextual-spacing attribute, which is provided by LibreOffice itself and seems to be supported. --- data/reference.odt | Bin 7058 -> 10702 bytes data/templates | 2 +- src/Text/Pandoc/Writers/ODT.hs | 20 ++++++++++++++------ src/Text/Pandoc/Writers/OpenDocument.hs | 3 ++- tests/writer.opendocument | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/data/reference.odt b/data/reference.odt index 6307119d3..29c1777d7 100644 Binary files a/data/reference.odt and b/data/reference.odt differ diff --git a/data/templates b/data/templates index c27f59c01..0cb55f228 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit c27f59c010b0468f01b710cdf3a3c04a450a03e7 +Subproject commit 0cb55f2289148b106ab78ce8f15efc8d0b8acda0 diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 751a323f5..cc0a06243 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -65,26 +65,30 @@ writeODT opts doc@(Pandoc meta _) = do doc' <- walkM (transformPic opts picEntriesRef) doc let newContents = writeOpenDocument opts{writerWrapText = False} doc' epochtime <- floor `fmap` getPOSIXTime - let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents + let contentEntry = toEntry "content.xml" epochtime + $ fromStringLazy newContents picEntries <- readIORef picEntriesRef - let archive = foldr addEntryToArchive refArchive $ contentEntry : picEntries + let archive = foldr addEntryToArchive refArchive + $ contentEntry : picEntries -- construct META-INF/manifest.xml based on archive let toFileEntry fp = case getMimeType fp of Nothing -> empty Just m -> selfClosingTag "manifest:file-entry" [("manifest:media-type", m) ,("manifest:full-path", fp) + ,("manifest:version", "1.2") ] - let files = [ ent | ent <- filesInArchive archive, not ("META-INF" `isPrefixOf` ent) ] + let files = [ ent | ent <- filesInArchive archive, + not ("META-INF" `isPrefixOf` ent) ] let manifestEntry = toEntry "META-INF/manifest.xml" epochtime $ fromStringLazy $ render Nothing $ text "" $$ ( inTags True "manifest:manifest" - [("xmlns:manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")] + [("xmlns:manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0") + ,("manifest:version","1.2")] $ ( selfClosingTag "manifest:file-entry" [("manifest:media-type","application/vnd.oasis.opendocument.text") - ,("manifest:version","1.2") ,("manifest:full-path","/")] $$ vcat ( map toFileEntry $ files ) ) @@ -107,7 +111,11 @@ writeODT opts doc@(Pandoc meta _) = do ) ) ) - let archive'' = addEntryToArchive metaEntry archive' + -- make sure mimetype is first + let mimetypeEntry = toEntry "mimetype" epochtime + $ fromStringLazy "application/vnd.oasis.opendocument.text" + let archive'' = addEntryToArchive mimetypeEntry + $ addEntryToArchive metaEntry archive' return $ fromArchive archive'' transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 05c576c20..3ec5c2073 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -461,7 +461,8 @@ tableStyle :: Int -> [(Char,Double)] -> Doc tableStyle num wcs = let tableId = "Table" ++ show (num + 1) table = inTags True "style:style" - [("style:name", tableId)] $ + [("style:name", tableId) + ,("style:family", "table")] $ selfClosingTag "style:table-properties" [("table:align" , "center")] colStyle (c,0) = selfClosingTag "style:style" diff --git a/tests/writer.opendocument b/tests/writer.opendocument index 9e1661475..1cee01f76 100644 --- a/tests/writer.opendocument +++ b/tests/writer.opendocument @@ -1,5 +1,5 @@ - + -- cgit v1.2.3 From 3e8bd8aa15a57c3dc87772049aabedeb1e0c7582 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 14 Aug 2013 23:24:45 -0700 Subject: Updated for removed unMeta, unFormat in pandoc-types. --- pandoc.cabal | 9 +++++++++ scripts/comments.py | 3 +-- scripts/myemph.py | 7 +++++-- scripts/tikz.py | 2 +- src/Text/Pandoc/Writers/RST.hs | 4 ++-- tests/docbook-reader.native | 2 +- tests/haddock-reader.native | 2 +- tests/html-reader.native | 2 +- tests/latex-reader.native | 8 ++++---- tests/markdown-reader-more.native | 10 +++++----- tests/mediawiki-reader.native | 22 +++++++++++----------- tests/opml-reader.native | 2 +- tests/rst-reader.native | 8 ++++---- tests/s5.native | 2 +- tests/testsuite.native | 38 +++++++++++++++++++------------------- tests/textile-reader.native | 18 +++++++++--------- tests/writer.native | 38 +++++++++++++++++++------------------- 17 files changed, 94 insertions(+), 83 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.cabal b/pandoc.cabal index e22908918..352da4988 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -112,6 +112,15 @@ Extra-Source-Files: -- generated man pages (produced post-build) man/man1/pandoc.1, man/man5/pandoc_markdown.5, + -- python library and sample python scripts + scripts/abc.py, + scripts/comments.py, + scripts/graphviz.py, + scripts/pandoc.py, + scripts/caps.py, + scripts/deemph.py, + scripts/myemph.py, + scripts/tikz.py, -- tests tests/bodybg.gif, tests/docbook-reader.docbook diff --git a/scripts/comments.py b/scripts/comments.py index 304af1a2d..ded21039c 100755 --- a/scripts/comments.py +++ b/scripts/comments.py @@ -15,8 +15,7 @@ incomment = False def comment(k,v,fmt): global incomment if k == 'RawBlock': - f, s = v - fmt = f['unFormat'] + fmt, s = v if fmt == "html": if re.search("", s): incomment = True diff --git a/scripts/myemph.py b/scripts/myemph.py index e527a0b2e..2a322b385 100755 --- a/scripts/myemph.py +++ b/scripts/myemph.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from pandoc import toJSONFilter, rawInline +from pandoc import toJSONFilter """ Pandoc filter that causes emphasis to be rendered using @@ -7,9 +7,12 @@ the custom macro '\myemph{...}' rather than '\emph{...}' in latex. Other output formats are unaffected. """ +def latex(s): + return {'RawInline': ['latex', s]} + def myemph(k, v, f): if k == 'Emph' and f == 'latex': - return [rawInline("latex", "\\myemph{")] + v + [rawInline("latex","}")] + return [latex('\\myemph{')] + v + [latex('}')] if __name__ == "__main__": toJSONFilter(myemph) diff --git a/scripts/tikz.py b/scripts/tikz.py index 7e1ed7927..4ff8b2383 100755 --- a/scripts/tikz.py +++ b/scripts/tikz.py @@ -44,7 +44,7 @@ def tikz2image(tikz, filetype, outfile): def tikz(key, value, format): if key == 'RawBlock': [fmt, code] = value - if fmt['unFormat'] == "latex" and re.match("\\\\begin{tikzpicture}", code): + if fmt == "latex" and re.match("\\\\begin{tikzpicture}", code): outfile = imagedir + '/' + sha1(code) if format == "html": filetype = "png" diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 5fbbb6afc..557658bc8 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -176,10 +176,10 @@ blockToRST (Para inlines) | otherwise = do contents <- inlineListToRST inlines return $ contents <> blankline -blockToRST (RawBlock f str) +blockToRST (RawBlock f@(Format f') str) | f == "rst" = return $ text str | otherwise = return $ blankline <> ".. raw:: " <> - text (map toLower $ unFormat f) $+$ + text (map toLower f') $+$ (nest 3 $ text str) $$ blankline blockToRST HorizontalRule = return $ blankline $$ "--------------" $$ blankline diff --git a/tests/docbook-reader.native b/tests/docbook-reader.native index 2d29bb154..8c94fea3e 100644 --- a/tests/docbook-reader.native +++ b/tests/docbook-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]}) +Pandoc (Meta (fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])])) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,Header 1 ("",[],[]) [Str "Headers"] ,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")] diff --git a/tests/haddock-reader.native b/tests/haddock-reader.native index 877719b50..c17c2ddf0 100644 --- a/tests/haddock-reader.native +++ b/tests/haddock-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList []}) +Pandoc (Meta (fromList [])) [Para [Str "This",Space,Str "file",Space,Str "tests",Space,Str "the",Space,Str "Pandoc",Space,Str "reader",Space,Str "for",Space,Str "Haddock.",Space,Str "We've",Space,Str "borrowed",Space,Str "examples",Space,Str "from",Space,Str "Haddock's",Space,Str "documentation:",Space,Link [Str "http://www.haskell.org/haddock/doc/html/ch03s08.html"] ("http://www.haskell.org/haddock/doc/html/ch03s08.html","http://www.haskell.org/haddock/doc/html/ch03s08.html"),Str "."] ,Para [Str "The",Space,Str "following",Space,Str "characters",Space,Str "have",Space,Str "special",Space,Str "meanings",Space,Str "in",Space,Str "Haddock,",Space,Str "/,",Space,Str "',",Space,Str "`,",Space,Str "\",",Space,Str "@,",Space,Str "<,",Space,Str "so",Space,Str "they",Space,Str "must",Space,Str "be",Space,Str "escaped."] ,Para [Str "*",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "paragraph,",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str ">",Space,Str "This",Space,Str "sentence",Space,Str "is",Space,Str "not",Space,Str "code.",Space,Str ">>>",Space,Str "This",Space,Str "is",Space,Str "not",Space,Str "an",Space,Str "example."] diff --git a/tests/html-reader.native b/tests/html-reader.native index 15937e594..8f60f040e 100644 --- a/tests/html-reader.native +++ b/tests/html-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]}) +Pandoc (Meta (fromList [("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])])) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Str "'",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."] ,HorizontalRule ,Header 1 ("",[],[]) [Str "Headers"] diff --git a/tests/latex-reader.native b/tests/latex-reader.native index 504e8b701..ddee17f9e 100644 --- a/tests/latex-reader.native +++ b/tests/latex-reader.native @@ -1,5 +1,5 @@ -Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]}) -[RawBlock (Format {unFormat = "latex"}) "\\maketitle" +Pandoc (Meta (fromList [("authors",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])])) +[RawBlock (Format "latex") "\\maketitle" ,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,HorizontalRule ,Header 1 ("",[],[]) [Str "Headers"] @@ -260,8 +260,8 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp ,HorizontalRule ,Header 1 ("",[],[]) [Str "LaTeX"] ,BulletList - [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22-23"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [RawInline (Format {unFormat = "latex"}) "\\cite[22-23]{smith.1899}"]]] - ,[Para [RawInline (Format {unFormat = "latex"}) "\\doublespacing"]] + [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22-23"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [RawInline (Format "latex") "\\cite[22-23]{smith.1899}"]]] + ,[Para [RawInline (Format "latex") "\\doublespacing"]] ,[Para [Math InlineMath "2+2=4"]] ,[Para [Math InlineMath "x \\in y"]] ,[Para [Math InlineMath "\\alpha \\wedge \\omega"]] diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native index c88c0ed67..ca588571f 100644 --- a/tests/markdown-reader-more.native +++ b/tests/markdown-reader-more.native @@ -2,9 +2,9 @@ ,Header 2 ("blank-line-before-url-in-link-reference",[],[]) [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"] ,Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")] ,Header 2 ("raw-context-environments",[],[]) [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"] -,Plain [RawInline (Format {unFormat = "tex"}) "\\placeformula "] -,RawBlock (Format {unFormat = "context"}) "\\startformula\n L_{1} = L_{2}\n \\stopformula" -,RawBlock (Format {unFormat = "context"}) "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]" +,Plain [RawInline (Format "tex") "\\placeformula "] +,RawBlock (Format "context") "\\startformula\n L_{1} = L_{2}\n \\stopformula" +,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]" ,Header 2 ("urls-with-spaces",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces"] ,Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")] ,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")] @@ -12,13 +12,13 @@ ,HorizontalRule ,HorizontalRule ,Header 2 ("raw-html-before-header",[],[]) [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"] -,Para [RawInline (Format {unFormat = "html"}) "
",RawInline (Format {unFormat = "html"}) ""] +,Para [RawInline (Format "html") "",RawInline (Format "html") ""] ,Header 3 ("my-header",[],[]) [Str "my",Space,Str "header"] ,Header 2 ("in-math",[],[]) [Str "$",Space,Str "in",Space,Str "math"] ,Para [Math InlineMath "\\$2 + \\$3"] ,Header 2 ("commented-out-list-item",[],[]) [Str "Commented-out",Space,Str "list",Space,Str "item"] ,BulletList - [[Plain [Str "one",Space,RawInline (Format {unFormat = "html"}) ""]] + [[Plain [Str "one",Space,RawInline (Format "html") ""]] ,[Plain [Str "three"]]] ,Header 2 ("backslash-newline",[],[]) [Str "Backslash",Space,Str "newline"] ,Para [Str "hi",LineBreak,Str "there"] diff --git a/tests/mediawiki-reader.native b/tests/mediawiki-reader.native index f6e09e45a..81596c7d7 100644 --- a/tests/mediawiki-reader.native +++ b/tests/mediawiki-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList []}) +Pandoc (Meta (fromList [])) [Header 1 ("",[],[]) [Str "header"] ,Header 2 ("",[],[]) [Str "header",Space,Str "level",Space,Str "two"] ,Header 3 ("",[],[]) [Str "header",Space,Str "level",Space,Str "3"] @@ -51,11 +51,11 @@ Pandoc (Meta {unMeta = fromList []}) ,Para [Str "bud"] ,Para [Str "another"] ,Header 2 ("",[],[]) [Str "raw",Space,Str "html"] -,Para [Str "hi",Space,RawInline (Format {unFormat = "html"}) "",Emph [Str "there"],RawInline (Format {unFormat = "html"}) "",Str "."] -,Para [RawInline (Format {unFormat = "html"}) "",Str "inserted",RawInline (Format {unFormat = "html"}) ""] -,RawBlock (Format {unFormat = "html"}) "
" +,Para [Str "hi",Space,RawInline (Format "html") "",Emph [Str "there"],RawInline (Format "html") "",Str "."] +,Para [RawInline (Format "html") "",Str "inserted",RawInline (Format "html") ""] +,RawBlock (Format "html") "
" ,Para [Str "hi",Space,Emph [Str "there"]] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Header 2 ("",[],[]) [Str "sup,",Space,Str "sub,",Space,Str "del"] ,Para [Str "H",Subscript [Str "2"],Str "O",Space,Str "base",Superscript [Emph [Str "exponent"]],Space,Strikeout [Str "hello"]] ,Header 2 ("",[],[]) [Str "inline",Space,Str "code"] @@ -140,7 +140,7 @@ Pandoc (Meta {unMeta = fromList []}) ,[Plain [Str "this",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "continuation"]] ,[Plain [Str "and",Space,Str "is",Space,Str "often",Space,Str "used"]] ,[Plain [Str "instead",LineBreak,Str "of",Space,Str "
"]]])]] - ,[Plain [RawInline (Format {unFormat = "mediawiki"}) "{{{template\n|author=John\n|title=My Book\n}}}"] + ,[Plain [RawInline (Format "mediawiki") "{{{template\n|author=John\n|title=My Book\n}}}"] ,OrderedList (1,DefaultStyle,DefaultDelim) [[Plain [Str "five",Space,Str "sub",Space,Str "1"] ,OrderedList (1,DefaultStyle,DefaultDelim) @@ -168,16 +168,16 @@ Pandoc (Meta {unMeta = fromList []}) ,Para [Code ("",[],[]) "\160hell\160\160\160\160\160\160yeah"] ,Para [Code ("",[],[]) "Start\160with\160a\160space\160in\160the\160first\160column,",LineBreak,Code ("",[],[]) "(before\160the\160).",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "Then\160your\160block\160format\160will\160be",LineBreak,Code ("",[],[]) "\160\160\160\160maintained.",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "This\160is\160good\160for\160copying\160in\160code\160blocks:",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "def\160function():",LineBreak,Code ("",[],[]) "\160\160\160\160\"\"\"documentation\160string\"\"\"",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "\160\160\160\160if\160True:",LineBreak,Code ("",[],[]) "\160\160\160\160\160\160\160\160print\160True",LineBreak,Code ("",[],[]) "\160\160\160\160else:",LineBreak,Code ("",[],[]) "\160\160\160\160\160\160\160\160print\160False"] ,Para [Str "Not"] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Para [Str "preformatted"] ,Para [Str "Don't",Space,Str "need"] ,Para [Code ("",[],[]) "a\160blank\160line"] ,Para [Str "around",Space,Str "a",Space,Str "preformatted",Space,Str "block."] ,Header 2 ("",[],[]) [Str "templates"] -,RawBlock (Format {unFormat = "mediawiki"}) "{{Welcome}}" -,RawBlock (Format {unFormat = "mediawiki"}) "{{Foo:Bar}}" -,RawBlock (Format {unFormat = "mediawiki"}) "{{Thankyou|all your effort|Me}}" -,Para [Str "Written",Space,RawInline (Format {unFormat = "mediawiki"}) "{{{date}}}",Space,Str "by",Space,RawInline (Format {unFormat = "mediawiki"}) "{{{name}}}",Str "."] +,RawBlock (Format "mediawiki") "{{Welcome}}" +,RawBlock (Format "mediawiki") "{{Foo:Bar}}" +,RawBlock (Format "mediawiki") "{{Thankyou|all your effort|Me}}" +,Para [Str "Written",Space,RawInline (Format "mediawiki") "{{{date}}}",Space,Str "by",Space,RawInline (Format "mediawiki") "{{{name}}}",Str "."] ,Header 2 ("",[],[]) [Str "tables"] ,Table [] [AlignDefault,AlignDefault] [0.0,0.0] [[] diff --git a/tests/opml-reader.native b/tests/opml-reader.native index e71857680..237a16719 100644 --- a/tests/opml-reader.native +++ b/tests/opml-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Dave",Space,Str "Winer"]]),("date",MetaInlines [Str "Thu,",Space,Str "14",Space,Str "Jul",Space,Str "2005",Space,Str "23:41:05",Space,Str "GMT"]),("title",MetaInlines [Str "States"])]}) +Pandoc (Meta (fromList [("author",MetaList [MetaInlines [Str "Dave",Space,Str "Winer"]]),("date",MetaInlines [Str "Thu,",Space,Str "14",Space,Str "Jul",Space,Str "2005",Space,Str "23:41:05",Space,Str "GMT"]),("title",MetaInlines [Str "States"])])) [Header 1 ("",[],[]) [Str "United",Space,Str "States"] ,Header 2 ("",[],[]) [Str "Far",Space,Str "West"] ,Header 3 ("",[],[]) [Str "Alaska"] diff --git a/tests/rst-reader.native b/tests/rst-reader.native index 69e73ae40..09da2d5ef 100644 --- a/tests/rst-reader.native +++ b/tests/rst-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("revision",MetaBlocks [Para [Str "3"]]),("subtitle",MetaInlines [Str "Subtitle"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]}) +Pandoc (Meta (fromList [("authors",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("revision",MetaBlocks [Para [Str "3"]]),("subtitle",MetaInlines [Str "Subtitle"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])])) [Header 1 ("",[],[]) [Str "Level",Space,Str "one",Space,Str "header"] ,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,Header 2 ("",[],[]) [Str "Level",Space,Str "two",Space,Str "header"] @@ -172,11 +172,11 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp [[Para [Str "123-4567"]]])] ,Header 1 ("",[],[]) [Str "HTML",Space,Str "Blocks"] ,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] -,RawBlock (Format {unFormat = "html"}) "
foo
" +,RawBlock (Format "html") "
foo
" ,Para [Str "Now,",Space,Str "nested:"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
\n foo\n
\n
\n
" +,RawBlock (Format "html") "
\n
\n
\n foo\n
\n
\n
" ,Header 1 ("",[],[]) [Str "LaTeX",Space,Str "Block"] -,RawBlock (Format {unFormat = "latex"}) "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" +,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."] ,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "",Str "."] diff --git a/tests/s5.native b/tests/s5.native index 5796b74a0..def09cf80 100644 --- a/tests/s5.native +++ b/tests/s5.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Sam",Space,Str "Smith"],MetaInlines [Str "Jen",Space,Str "Jones"]]),("date",MetaInlines [Str "July",Space,Str "15,",Space,Str "2006"]),("title",MetaInlines [Str "My",Space,Str "S5",Space,Str "Document"])]}) +Pandoc (Meta (fromList [("author",MetaList [MetaInlines [Str "Sam",Space,Str "Smith"],MetaInlines [Str "Jen",Space,Str "Jones"]]),("date",MetaInlines [Str "July",Space,Str "15,",Space,Str "2006"]),("title",MetaInlines [Str "My",Space,Str "S5",Space,Str "Document"])])) [Header 1 ("first-slide",[],[]) [Str "First",Space,Str "slide"] ,BulletList [[Plain [Str "first",Space,Str "bullet"]] diff --git a/tests/testsuite.native b/tests/testsuite.native index f9cf606f3..503b3001e 100644 --- a/tests/testsuite.native +++ b/tests/testsuite.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]}) +Pandoc (Meta (fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])])) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,HorizontalRule ,Header 1 ("headers",[],[]) [Str "Headers"] @@ -228,45 +228,45 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "sublist"]]]]])] ,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"] ,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n" +,RawBlock (Format "html") "
\n" ,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
" +,RawBlock (Format "html") "
\n
\n
" ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
" +,RawBlock (Format "html") "
\n
\n
" ,Plain [Str "bar"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n" +,RawBlock (Format "html") "
\n
\n" ,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] -,RawBlock (Format {unFormat = "html"}) "\n\n\n\n
" +,RawBlock (Format "html") "\n\n\n\n\n\n
" ,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] -,RawBlock (Format {unFormat = "html"}) "" +,RawBlock (Format "html") "" ,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] -,RawBlock (Format {unFormat = "html"}) "
\n\n\n" +,RawBlock (Format "html") "
\n\n\n" ,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"] -,RawBlock (Format {unFormat = "html"}) "
\n " +,RawBlock (Format "html") "
\n " ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n" +,RawBlock (Format "html") "
\n" ,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] ,CodeBlock ("",[],[]) "
\n foo\n
" ,Para [Str "As",Space,Str "should",Space,Str "this:"] ,CodeBlock ("",[],[]) "
foo
" ,Para [Str "Now,",Space,Str "nested:"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
\n " +,RawBlock (Format "html") "
\n
\n
\n " ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
\n" +,RawBlock (Format "html") "
\n
\n
\n" ,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] -,RawBlock (Format {unFormat = "html"}) "\n" +,RawBlock (Format "html") "\n" ,Para [Str "Multiline:"] -,RawBlock (Format {unFormat = "html"}) "\n\n\n" +,RawBlock (Format "html") "\n\n\n" ,Para [Str "Code",Space,Str "block:"] ,CodeBlock ("",[],[]) "" ,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"] -,RawBlock (Format {unFormat = "html"}) " \n" +,RawBlock (Format "html") " \n" ,Para [Str "Code:"] ,CodeBlock ("",[],[]) "
" ,Para [Str "Hr\8217s:"] -,RawBlock (Format {unFormat = "html"}) "
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n" +,RawBlock (Format "html") "
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n" ,HorizontalRule ,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] @@ -294,7 +294,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,HorizontalRule ,Header 1 ("latex",[],[]) [Str "LaTeX"] ,BulletList - [[Plain [RawInline (Format {unFormat = "tex"}) "\\cite[22-23]{smith.1899}"]] + [[Plain [RawInline (Format "tex") "\\cite[22-23]{smith.1899}"]] ,[Plain [Math InlineMath "2+2=4"]] ,[Plain [Math InlineMath "x \\in y"]] ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]] @@ -309,7 +309,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]] ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] -,RawBlock (Format {unFormat = "latex"}) "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" +,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,HorizontalRule ,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] diff --git a/tests/textile-reader.native b/tests/textile-reader.native index 70b33f31d..31ab558d7 100644 --- a/tests/textile-reader.native +++ b/tests/textile-reader.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList []}) +Pandoc (Meta (fromList [])) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Space,Str "Textile",Space,Str "Reader",Str ".",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber",Str "\8217",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."] ,HorizontalRule ,Header 1 ("",[],[]) [Str "Headers"] @@ -137,23 +137,23 @@ Pandoc (Meta {unMeta = fromList []}) ,Header 1 ("",[],[]) [Str "Entities"] ,Para [Str "*",LineBreak,Str "&"] ,Header 1 ("",[],[]) [Str "Raw",Space,Str "HTML"] -,Para [Str "However",Str ",",Space,RawInline (Format {unFormat = "html"}) "",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline (Format {unFormat = "html"}) "",Space,Str "are",Space,Str "accepted",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"] -,RawBlock (Format {unFormat = "html"}) "
" +,Para [Str "However",Str ",",Space,RawInline (Format "html") "",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline (Format "html") "",Space,Str "are",Space,Str "accepted",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"] +,RawBlock (Format "html") "
" ,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold"] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Para [Str "Html",Space,Str "blocks",Space,Str "can",Space,Str "be"] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Para [Str "inlined"] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Para [Str "as",Space,Str "well",Str "."] ,BulletList [[Plain [Str "this",Space,Str "<",Str "div",Str ">",Space,Str "won",Str "\8217",Str "t",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,Str "<",Str "/div",Str ">"]] - ,[Plain [Str "but",Space,Str "this",Space,RawInline (Format {unFormat = "html"}) "",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline (Format {unFormat = "html"}) ""]]] + ,[Plain [Str "but",Space,Str "this",Space,RawInline (Format "html") "",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline (Format "html") ""]]] ,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"] ,Header 1 ("",[],[]) [Str "Raw",Space,Str "LaTeX"] ,Para [Str "This",Space,Str "Textile",Space,Str "reader",Space,Str "also",Space,Str "accepts",Space,Str "raw",Space,Str "LaTeX",Space,Str "for",Space,Str "blocks",Space,Str ":"] -,RawBlock (Format {unFormat = "latex"}) "\\begin{itemize}\n \\item one\n \\item two\n\\end{itemize}" -,Para [Str "and",Space,Str "for",Space,RawInline (Format {unFormat = "latex"}) "\\emph{inlines}",Str "."] +,RawBlock (Format "latex") "\\begin{itemize}\n \\item one\n \\item two\n\\end{itemize}" +,Para [Str "and",Space,Str "for",Space,RawInline (Format "latex") "\\emph{inlines}",Str "."] ,Header 1 ("",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"] ,Para [Str "PBS (Public Broadcasting System)"] ,Para [Str "Hi",Str "\8482"] diff --git a/tests/writer.native b/tests/writer.native index f9cf606f3..503b3001e 100644 --- a/tests/writer.native +++ b/tests/writer.native @@ -1,4 +1,4 @@ -Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]}) +Pandoc (Meta (fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])])) [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."] ,HorizontalRule ,Header 1 ("headers",[],[]) [Str "Headers"] @@ -228,45 +228,45 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "sublist"]]]]])] ,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"] ,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] -,RawBlock (Format {unFormat = "html"}) "
" +,RawBlock (Format "html") "
" ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n" +,RawBlock (Format "html") "
\n" ,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
" +,RawBlock (Format "html") "
\n
\n
" ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
" +,RawBlock (Format "html") "
\n
\n
" ,Plain [Str "bar"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n" +,RawBlock (Format "html") "
\n
\n" ,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] -,RawBlock (Format {unFormat = "html"}) "\n\n\n\n
" +,RawBlock (Format "html") "\n\n\n\n\n\n
" ,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] -,RawBlock (Format {unFormat = "html"}) "" +,RawBlock (Format "html") "" ,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] -,RawBlock (Format {unFormat = "html"}) "
\n\n\n" +,RawBlock (Format "html") "
\n\n\n" ,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"] -,RawBlock (Format {unFormat = "html"}) "
\n " +,RawBlock (Format "html") "
\n " ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n" +,RawBlock (Format "html") "
\n" ,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] ,CodeBlock ("",[],[]) "
\n foo\n
" ,Para [Str "As",Space,Str "should",Space,Str "this:"] ,CodeBlock ("",[],[]) "
foo
" ,Para [Str "Now,",Space,Str "nested:"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
\n " +,RawBlock (Format "html") "
\n
\n
\n " ,Plain [Str "foo"] -,RawBlock (Format {unFormat = "html"}) "
\n
\n
\n" +,RawBlock (Format "html") "
\n
\n
\n" ,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] -,RawBlock (Format {unFormat = "html"}) "\n" +,RawBlock (Format "html") "\n" ,Para [Str "Multiline:"] -,RawBlock (Format {unFormat = "html"}) "\n\n\n" +,RawBlock (Format "html") "\n\n\n" ,Para [Str "Code",Space,Str "block:"] ,CodeBlock ("",[],[]) "" ,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"] -,RawBlock (Format {unFormat = "html"}) " \n" +,RawBlock (Format "html") " \n" ,Para [Str "Code:"] ,CodeBlock ("",[],[]) "
" ,Para [Str "Hr\8217s:"] -,RawBlock (Format {unFormat = "html"}) "
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n" +,RawBlock (Format "html") "
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n" ,HorizontalRule ,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"] ,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."] @@ -294,7 +294,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,HorizontalRule ,Header 1 ("latex",[],[]) [Str "LaTeX"] ,BulletList - [[Plain [RawInline (Format {unFormat = "tex"}) "\\cite[22-23]{smith.1899}"]] + [[Plain [RawInline (Format "tex") "\\cite[22-23]{smith.1899}"]] ,[Plain [Math InlineMath "2+2=4"]] ,[Plain [Math InlineMath "x \\in y"]] ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]] @@ -309,7 +309,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]] ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]] ,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"] -,RawBlock (Format {unFormat = "latex"}) "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" +,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}" ,HorizontalRule ,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"] ,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"] -- cgit v1.2.3 From 441a7aebf8c141612203d1cab0032f8c55e536ed Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 16 Aug 2013 13:02:55 -0700 Subject: LaTeX writer: Avoid problem with footnotes in unnumbered headers. Closes #940. Added test case. --- src/Text/Pandoc/Writers/LaTeX.hs | 13 +++++++------ tests/Tests/Writers/LaTeX.hs | 6 ++++++ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 7f9a99801..98553c421 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -498,14 +498,15 @@ sectionHeader unnumbered ref level lst = do let noNote (Note _) = Str "" noNote x = x let lstNoNotes = walk noNote lst + txtNoNotes <- inlineListToLaTeX lstNoNotes let star = if unnumbered then text "*" else empty - -- footnotes in sections don't work unless you specify an optional - -- argument: \section[mysec]{mysec\footnote{blah}} - optional <- if lstNoNotes == lst + -- footnotes in sections don't work (except for starred variants) + -- unless you specify an optional argument: + -- \section[mysec]{mysec\footnote{blah}} + optional <- if unnumbered || lstNoNotes == lst then return empty else do - res <- inlineListToLaTeX lstNoNotes - return $ char '[' <> res <> char ']' + return $ brackets txtNoNotes let stuffing = star <> optional <> braces txt book <- gets stBook opts <- gets stOptions @@ -536,7 +537,7 @@ sectionHeader unnumbered ref level lst = do $$ if unnumbered then "\\addcontentsline{toc}" <> braces (text sectionType) <> - braces txt + braces txtNoNotes else empty -- | Convert list of inline elements to LaTeX. diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index b1427d91f..ebde5b97c 100644 --- a/tests/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs @@ -36,4 +36,10 @@ tests = [ testGroup "code blocks" [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?> "$\\sigma|_{\\{x\\}}$" ] + , testGroup "headers" + [ "unnumbered header" =: + headerWith ("foo",["unnumbered"],[]) 1 + (text "Header 1" <> note (plain $ text "note")) =?> + "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n" + ] ] -- cgit v1.2.3 From 8d441af3da4709fd48a44e860d5a0cd4d35792af Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 18 Aug 2013 14:36:40 -0700 Subject: Adjusted writers and tests for change in parsing of div/span. Textile, MediaWiki, Markdown, Org, RST will emit raw HTML div tags for divs. Otherwise Div and Span are "transparent" block containers. --- src/Text/Pandoc/Writers/Docbook.hs | 2 +- src/Text/Pandoc/Writers/Markdown.hs | 17 ++++++++++----- src/Text/Pandoc/Writers/MediaWiki.hs | 12 +++++++---- src/Text/Pandoc/Writers/Org.hs | 9 +++++++- src/Text/Pandoc/Writers/RST.hs | 6 +++++- src/Text/Pandoc/Writers/Shared.hs | 18 ++++++++++++++++ src/Text/Pandoc/Writers/Textile.hs | 8 ++++++-- tests/testsuite.native | 18 ++++------------ tests/testsuite.txt | 12 +++++------ tests/writer.docbook | 40 ++++++++++++++---------------------- tests/writer.fb2 | 2 +- tests/writer.html | 12 +++-------- tests/writer.markdown | 27 +++++++++++++++++++----- tests/writer.mediawiki | 28 +++++++++++++++++-------- tests/writer.native | 18 ++++------------ tests/writer.opml | 2 +- tests/writer.org | 35 ++++++++++++++++++++++++++----- tests/writer.plain | 5 +++++ tests/writer.rst | 35 ++++++++++++++++++++++++++----- tests/writer.textile | 31 +++++++++++++++++++++++----- 20 files changed, 225 insertions(+), 112 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 3d150d19b..7c03c07dc 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -149,7 +149,7 @@ listItemToDocbook opts item = -- | Convert a Pandoc block element to Docbook. blockToDocbook :: WriterOptions -> Block -> Doc blockToDocbook _ Null = empty -blockToDocbook opts (Div _ bs) = blocksToDocbook opts bs +blockToDocbook opts (Div _ bs) = blocksToDocbook opts $ map plainToPara bs blockToDocbook _ (Header _ _ _) = empty -- should not occur after hierarchicalize blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst -- title beginning with fig: indicates that the image is a figure diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 3d0ed8702..623c445df 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2013 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Markdown - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2013 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane @@ -301,7 +301,13 @@ blockToMarkdown :: WriterOptions -- ^ Options -> Block -- ^ Block element -> State WriterState Doc blockToMarkdown _ Null = return empty -blockToMarkdown opts (Div _ bs) = blockListToMarkdown opts bs +blockToMarkdown opts (Div attrs ils) = do + isPlain <- gets stPlain + contents <- blockListToMarkdown opts ils + return $ if isPlain + then contents <> blankline + else tagWithAttrs "div" attrs <> blankline <> + contents <> blankline <> "" <> blankline blockToMarkdown opts (Plain inlines) = do contents <- inlineListToMarkdown opts inlines return $ contents <> cr @@ -629,8 +635,9 @@ escapeSpaces x = x -- | Convert Pandoc inline element to markdown. inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc -inlineToMarkdown opts (Span _ ils) = - inlineListToMarkdown opts ils +inlineToMarkdown opts (Span attrs ils) = do + contents <- inlineListToMarkdown opts ils + return $ tagWithAttrs "span" attrs <> contents <> text "
" inlineToMarkdown opts (Emph lst) = do contents <- inlineListToMarkdown opts lst return $ "*" <> contents <> "*" diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index 4ffba1100..61741a61e 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -34,6 +34,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared +import Text.Pandoc.Pretty (render) import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.XML ( escapeStringForXML ) import Data.List ( intersect, intercalate, intersperse ) @@ -83,8 +84,10 @@ blockToMediaWiki :: WriterOptions -- ^ Options blockToMediaWiki _ Null = return "" -blockToMediaWiki opts (Div _ bs) = - blockListToMediaWiki opts bs +blockToMediaWiki opts (Div attrs bs) = do + contents <- blockListToMediaWiki opts bs + return $ render Nothing (tagWithAttrs "div" attrs) ++ "\n\n" ++ + contents ++ "\n\n" ++ "" blockToMediaWiki opts (Plain inlines) = inlineListToMediaWiki opts inlines @@ -332,8 +335,9 @@ inlineListToMediaWiki opts lst = -- | Convert Pandoc inline element to MediaWiki. inlineToMediaWiki :: WriterOptions -> Inline -> State WriterState String -inlineToMediaWiki opts (Span _ ils) = - inlineListToMediaWiki opts ils +inlineToMediaWiki opts (Span attrs ils) = do + contents <- inlineListToMediaWiki opts ils + return $ render Nothing (tagWithAttrs "span" attrs) ++ contents ++ "" inlineToMediaWiki opts (Emph lst) = do contents <- inlineListToMediaWiki opts lst diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index 34ae532b0..51083f52b 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -106,7 +106,14 @@ escapeString = escapeStringUsing $ blockToOrg :: Block -- ^ Block element -> State WriterState Doc blockToOrg Null = return empty -blockToOrg (Div _ bs) = blockListToOrg bs +blockToOrg (Div attrs bs) = do + contents <- blockListToOrg bs + let startTag = tagWithAttrs "div" attrs + let endTag = text "" + return $ blankline $$ "#+BEGIN_HTML" $$ + nest 2 startTag $$ "#+END_HTML" $$ blankline $$ + contents $$ blankline $$ "#+BEGIN_HTML" $$ + nest 2 endTag $$ "#+END_HTML" $$ blankline blockToOrg (Plain inlines) = inlineListToOrg inlines -- title beginning with fig: indicates that the image is a figure blockToOrg (Para [Image txt (src,'f':'i':'g':':':tit)]) = do diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 557658bc8..70c6b4421 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -161,7 +161,11 @@ bordered contents c = blockToRST :: Block -- ^ Block element -> State WriterState Doc blockToRST Null = return empty -blockToRST (Div _ bs) = blockListToRST bs +blockToRST (Div attr bs) = do + contents <- blockListToRST bs + let startTag = ".. raw:: html" $+$ nest 3 (tagWithAttrs "div" attr) + let endTag = ".. raw:: html" $+$ nest 3 "" + return $ blankline <> startTag $+$ contents $+$ endTag $$ blankline blockToRST (Plain inlines) = inlineListToRST inlines -- title beginning with fig: indicates that the image is a figure blockToRST (Para [Image txt (src,'f':'i':'g':':':tit)]) = do diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index e6ec853f8..89923822c 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2013 John MacFarlane @@ -32,9 +33,12 @@ module Text.Pandoc.Writers.Shared ( , getField , setField , defField + , tagWithAttrs ) where import Text.Pandoc.Definition +import Text.Pandoc.Pretty +import Text.Pandoc.XML (escapeStringForXML) import Control.Monad (liftM) import Text.Pandoc.Options (WriterOptions(..)) import qualified Data.HashMap.Strict as H @@ -120,3 +124,17 @@ defField field val (Object hashmap) = where f _newval oldval = oldval defField _ _ x = x +-- Produce an HTML tag with the given pandoc attributes. +tagWithAttrs :: String -> Attr -> Doc +tagWithAttrs tag (ident,classes,kvs) = hsep + ["<" <> text tag + ,if null ident + then empty + else "id=" <> doubleQuotes (text ident) + ,if null classes + then empty + else "class=" <> doubleQuotes (text (unwords classes)) + ] + <> hsep (map (\(k,v) -> text k <> "=" <> + doubleQuotes (text (escapeStringForXML v))) kvs) + <> ">" diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index 27e8b60ec..7c102cc86 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -33,6 +33,7 @@ module Text.Pandoc.Writers.Textile ( writeTextile ) where import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared +import Text.Pandoc.Pretty (render) import Text.Pandoc.Writers.Shared import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.XML ( escapeStringForXML ) @@ -101,8 +102,11 @@ blockToTextile :: WriterOptions -- ^ Options blockToTextile _ Null = return "" -blockToTextile opts (Div _ bs) = - blockListToTextile opts bs +blockToTextile opts (Div attr bs) = do + let startTag = render Nothing $ tagWithAttrs "div" attr + let endTag = "" + contents <- blockListToTextile opts bs + return $ startTag ++ "\n\n" ++ contents ++ "\n\n" ++ endTag ++ "\n" blockToTextile opts (Plain inlines) = inlineListToTextile opts inlines diff --git a/tests/testsuite.native b/tests/testsuite.native index d1b14b24e..678d7595f 100644 --- a/tests/testsuite.native +++ b/tests/testsuite.native @@ -228,15 +228,9 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "sublist"]]]]])] ,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"] ,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] -,RawBlock (Format "html") "
" -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n" +,Div ("",[],[]) [Plain [Str "foo"]] ,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] -,RawBlock (Format "html") "
\n
\n
" -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n
\n
" -,Plain [Str "bar"] -,RawBlock (Format "html") "
\n
\n" +,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]] ,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] ,RawBlock (Format "html") "\n\n\n\n
" ,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] @@ -244,17 +238,13 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] ,RawBlock (Format "html") "
\n\n\n" ,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"] -,RawBlock (Format "html") "
\n " -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n" +,Div ("",[],[]) [Plain [Str "foo"]] ,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] ,CodeBlock ("",[],[]) "
\n foo\n
" ,Para [Str "As",Space,Str "should",Space,Str "this:"] ,CodeBlock ("",[],[]) "
foo
" ,Para [Str "Now,",Space,Str "nested:"] -,RawBlock (Format "html") "
\n
\n
\n " -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n
\n
\n" +,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]]] ,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] ,RawBlock (Format "html") "\n" ,Para [Str "Multiline:"] diff --git a/tests/testsuite.txt b/tests/testsuite.txt index 3bb5d8cb5..4ddaae23f 100644 --- a/tests/testsuite.txt +++ b/tests/testsuite.txt @@ -377,7 +377,7 @@ Interpreted markdown in a table: Here's a simple block:
- foo +foo
This should be a code block, though: @@ -393,11 +393,11 @@ As should this: Now, nested:
-
-
- foo -
-
+
+
+ foo +
+
This should just be an HTML comment: diff --git a/tests/writer.docbook b/tests/writer.docbook index 1e77a61ed..e427d8ffc 100644 --- a/tests/writer.docbook +++ b/tests/writer.docbook @@ -862,22 +862,18 @@ These should not be escaped: \$ \\ \> \[ \{ Simple block on one line: -
- foo -
+ + foo + And nested without indentation: -
-
-
- foo -
-
-
- bar -
-
+ + foo + + + bar + Interpreted markdown in a table: @@ -896,10 +892,9 @@ These should not be escaped: \$ \\ \> \[ \{ Here’s a simple block: -
- - foo -
+ + foo + This should be a code block, though: @@ -917,14 +912,9 @@ These should not be escaped: \$ \\ \> \[ \{ Now, nested: -
-
-
- - foo -
-
-
+ + foo + This should just be an HTML comment: diff --git a/tests/writer.fb2 b/tests/writer.fb2 index 0bcbf1c2a..8106d2b91 100644 --- a/tests/writer.fb2 +++ b/tests/writer.fb2 @@ -1,2 +1,2 @@ -Pandoc Test SuiteJohnMacFarlaneAnonymousJuly 17, 2006pandoc<p>Pandoc Test Suite</p>

John MacFarlane

Anonymous

July 17, 2006

This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.

——————————

<p>Headers</p>
<p>Level 2 with an embedded link </url></p>
<p>Level 3 with emphasis</p>
<p>Level 4</p>
<p>Level 5</p>
<p>Level 1</p>
<p>Level 2 with emphasis</p>
<p>Level 3</p>

with no blank line

<p>Level 2</p>

with no blank line

——————————

<p>Paragraphs</p>

Here’s a regular paragraph.

In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.

Here’s one with a bullet. * criminey.

There should be a hard line breakhere.

——————————

<p>Block Quotes</p>

E-mail style:

This is a block quote. It is pretty short.

Code in a block quote:

sub status {

print "working";

}

A list:

 1. item one

 2. item two

Nested block quotes:

nested

nested

This should not be a block quote: 2 > 1.

And a following paragraph.

——————————

<p>Code Blocks</p>

Code:

---- (should be four hyphens)

sub status {

print "working";

}

this code block is indented by one tab

And:

this code block is indented by two tabs

These should not be escaped: \$ \\ \> \[ \{

——————————

<p>Lists</p>
<p>Unordered</p>

Asterisks tight:

• asterisk 1

• asterisk 2

• asterisk 3

Asterisks loose:

• asterisk 1

• asterisk 2

• asterisk 3

Pluses tight:

• Plus 1

• Plus 2

• Plus 3

Pluses loose:

• Plus 1

• Plus 2

• Plus 3

Minuses tight:

• Minus 1

• Minus 2

• Minus 3

Minuses loose:

• Minus 1

• Minus 2

• Minus 3

<p>Ordered</p>

Tight:

 1. First

 2. Second

 3. Third

and:

 1. One

 2. Two

 3. Three

Loose using tabs:

 1. First

 2. Second

 3. Third

and using spaces:

 1. One

 2. Two

 3. Three

Multiple paragraphs:

 1. Item 1, graf one.Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.

 2. Item 2.

 3. Item 3.

<p>Nested</p>

• Tab

◦ Tab

* Tab

Here’s another:

 1. First

 2. Second:

   • Fee

   • Fie

   • Foe

 3. Third

Same thing but with paragraphs:

 1. First

 2. Second:

   • Fee

   • Fie

   • Foe

 3. Third

<p>Tabs and spaces</p>

• this is a list item indented with tabs

• this is a list item indented with spaces

◦ this is an example list item indented with tabs

◦ this is an example list item indented with spaces

<p>Fancy list markers</p>

 (2) begins with 2

 (3) and now 3with a continuation

 (3) iv. sublist with roman numerals, starting with 4

 (3) v. more items

 (3) v. (A) a subsublist

 (3) v. (B) a subsublist

Nesting:

 A. Upper Alpha

 A. I. Upper Roman.

 A. I. (6) Decimal start with 6

 A. I. (6) c) Lower alpha with paren

Autonumbering:

 1. Autonumber.

 2. More.

 2. 1. Nested.

Should not be a list item:

M.A. 2007

B. Williams

——————————

<p>Definition Lists</p>

Tight using spaces:

apple

    red fruit

orange

    orange fruit

banana

    yellow fruit

Tight using tabs:

apple

    red fruit

orange

    orange fruit

banana

    yellow fruit

Loose:

apple

    red fruit

orange

    orange fruit

banana

    yellow fruit

Multiple blocks with italics:

apple

    red fruit    contains seeds, crisp, pleasant to taste

orange

    orange fruit

    { orange code block }

    orange block quote

Multiple definitions, tight:

apple

    red fruit    computer

orange

    orange fruit    bank

Multiple definitions, loose:

apple

    red fruit    computer

orange

    orange fruit    bank

Blank line after term, indented marker, alternate markers:

apple

    red fruit    computer

orange

    orange fruit

 1. sublist

 2. sublist

<p>HTML Blocks</p>

Simple block on one line:

<div>

foo

</div>

And nested without indentation:

<div>

<div>

<div>

foo

</div>

</div>

<div>

bar

</div>

</div>

Interpreted markdown in a table:

<table>

<tr>

<td>

This is emphasized

</td>

<td>

And this is strong

</td>

</tr>

</table>

<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>

Here’s a simple block:

<div>

foo

</div>

This should be a code block, though:

<div>

foo

</div>

As should this:

<div>foo</div>

Now, nested:

<div>

<div>

<div>

foo

</div>

</div>

</div>

This should just be an HTML comment:

<!-- Comment -->

Multiline:

<!--

Blah

Blah

-->

<!--

This is another comment.

-->

Code block:

<!-- Comment -->

Just plain comment, with trailing spaces on the line:

<!-- foo -->

Code:

<hr />

Hr’s:

<hr>

<hr />

<hr />

<hr>

<hr />

<hr />

<hr class="foo" id="bar" />

<hr class="foo" id="bar" />

<hr class="foo" id="bar">

——————————

<p>Inline Markup</p>

This is emphasized, and so is this.

This is strong, and so is this.

An emphasized link[1].

This is strong and em.

So is this word.

This is strong and em.

So is this word.

This is code: >, $, \, \$, <html>.

This is strikeout.

Superscripts: abcd ahello ahello there.

Subscripts: H2O, H23O, Hmany of themO.

These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.

——————————

<p>Smart quotes, ellipses, dashes</p>

“Hello,” said the spider. “‘Shelob’ is my name.”

‘A’, ‘B’, and ‘C’ are letters.

‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’

‘He said, “I want to go.”’ Were you alive in the 70’s?

Here is some quoted ‘code’ and a “quoted link[2]”.

Some dashes: one—two — three—four — five.

Dashes between numbers: 5–7, 255–66, 1987–1999.

Ellipses…and…and….

——————————

<p>LaTeX</p>

• 

• 2+2=4

• x \in y

• \alpha \wedge \omega

• 223

• p-Tree

• Here’s some display math: \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}

• Here’s one that has a line break in it: \alpha + \omega \times x^2.

These shouldn’t be math:

• To get the famous equation, write $e = mc^2$.

• $22,000 is a lot of money. So is $34,000. (It worked if “lot” is emphasized.)

• Shoes ($20) and socks ($5).

• Escaped $: $73 this should be emphasized 23$.

Here’s a LaTeX table:

\begin{tabular}{|l|l|}\hline

Animal & Number \\ \hline

Dog & 2 \\

Cat & 1 \\ \hline

\end{tabular}

——————————

<p>Special Characters</p>

Here is some unicode:

• I hat: Î

• o umlaut: ö

• section: §

• set membership: ∈

• copyright: ©

AT&T has an ampersand in their name.

AT&T is another way to write it.

This & that.

4 < 5.

6 > 5.

Backslash: \

Backtick: `

Asterisk: *

Underscore: _

Left brace: {

Right brace: }

Left bracket: [

Right bracket: ]

Left paren: (

Right paren: )

Greater-than: >

Hash: #

Period: .

Bang: !

Plus: +

Minus: -

——————————

<p>Links</p>
<p>Explicit</p>

Just a URL[3].

URL and title[4].

URL and title[5].

URL and title[6].

URL and title[7]

URL and title[8]

with_underscore[9]

Email link[10]

Empty[11].

<p>Reference</p>

Foo bar[12].

Foo bar[13].

Foo bar[14].

With embedded [brackets][15].

b[16] by itself should be a link.

Indented once[17].

Indented twice[18].

Indented thrice[19].

This should [not][] be a link.

[not]: /url

Foo bar[20].

Foo biz[21].

<p>With ampersands</p>

Here’s a link with an ampersand in the URL[22].

Here’s a link with an amersand in the link text: AT&T[23].

Here’s an inline link[24].

Here’s an inline link in pointy braces[25].

<p>Autolinks</p>

With an ampersand: http://example.com/?foo=1&bar=2[26]

• In a list?

• http://example.com/[27]

• It should.

An e-mail address: nobody@nowhere.net[28]

Blockquoted: http://example.com/[29]

Auto-links should not occur here: <http://example.com/>

or here: <http://example.com/>

——————————

<p>Images</p>

From “Voyage dans la Lune” by Georges Melies (1902):

lalune

Here is a movie movie icon.

——————————

<p>Footnotes</p>

Here is a footnote reference,[30] and another.[31] This should not be a footnote reference, because it contains a space.[^my note] Here is an inline note.[32]

Notes can go in quotes.[33]

 1. And in list items.[34]

This paragraph should not be part of the note, as it is not indented.

<p>1</p>

/url

<p>2</p>

http://example.com/?foo=1&bar=2

<p>3</p>

/url/

<p>4</p>

title: /url/

<p>5</p>

title preceded by two spaces: /url/

<p>6</p>

title preceded by a tab: /url/

<p>7</p>

title with "quotes" in it: /url/

<p>8</p>

title with single quotes: /url/

<p>9</p>

/url/with_underscore

<p>10</p>

mailto:nobody@nowhere.net

<p>11</p>

<p>12</p>

/url/

<p>13</p>

/url/

<p>14</p>

/url/

<p>15</p>

/url/

<p>16</p>

/url/

<p>17</p>

/url

<p>18</p>

/url

<p>19</p>

/url

<p>20</p>

Title with "quotes" inside: /url/

<p>21</p>

Title with "quote" inside: /url/

<p>22</p>

http://example.com/?foo=1&bar=2

<p>23</p>

AT&T: http://att.com/

<p>24</p>

/script?foo=1&bar=2

<p>25</p>

/script?foo=1&bar=2

<p>26</p>

http://example.com/?foo=1&bar=2

<p>27</p>

http://example.com/

<p>28</p>

mailto:nobody@nowhere.net

<p>29</p>

http://example.com/

<p>30</p>

Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.

<p>31</p>

Here’s the long note. This one contains multiple blocks.

Subsequent blocks are indented to show that they belong to the footnote (as with list items).

{ <code> }

If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.

<p>32</p>

This is easier to type. Inline notes may contain links[32] and ] verbatim characters, as well as [bracketed text].

<p>33</p>

In quote.

<p>34</p>

In list.

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
\ No newline at end of file +Pandoc Test SuiteJohnMacFarlaneAnonymousJuly 17, 2006pandoc<p>Pandoc Test Suite</p>

John MacFarlane

Anonymous

July 17, 2006

This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.

——————————

<p>Headers</p>
<p>Level 2 with an embedded link </url></p>
<p>Level 3 with emphasis</p>
<p>Level 4</p>
<p>Level 5</p>
<p>Level 1</p>
<p>Level 2 with emphasis</p>
<p>Level 3</p>

with no blank line

<p>Level 2</p>

with no blank line

——————————

<p>Paragraphs</p>

Here’s a regular paragraph.

In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.

Here’s one with a bullet. * criminey.

There should be a hard line breakhere.

——————————

<p>Block Quotes</p>

E-mail style:

This is a block quote. It is pretty short.

Code in a block quote:

sub status {

print "working";

}

A list:

 1. item one

 2. item two

Nested block quotes:

nested

nested

This should not be a block quote: 2 > 1.

And a following paragraph.

——————————

<p>Code Blocks</p>

Code:

---- (should be four hyphens)

sub status {

print "working";

}

this code block is indented by one tab

And:

this code block is indented by two tabs

These should not be escaped: \$ \\ \> \[ \{

——————————

<p>Lists</p>
<p>Unordered</p>

Asterisks tight:

• asterisk 1

• asterisk 2

• asterisk 3

Asterisks loose:

• asterisk 1

• asterisk 2

• asterisk 3

Pluses tight:

• Plus 1

• Plus 2

• Plus 3

Pluses loose:

• Plus 1

• Plus 2

• Plus 3

Minuses tight:

• Minus 1

• Minus 2

• Minus 3

Minuses loose:

• Minus 1

• Minus 2

• Minus 3

<p>Ordered</p>

Tight:

 1. First

 2. Second

 3. Third

and:

 1. One

 2. Two

 3. Three

Loose using tabs:

 1. First

 2. Second

 3. Third

and using spaces:

 1. One

 2. Two

 3. Three

Multiple paragraphs:

 1. Item 1, graf one.Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.

 2. Item 2.

 3. Item 3.

<p>Nested</p>

• Tab

◦ Tab

* Tab

Here’s another:

 1. First

 2. Second:

   • Fee

   • Fie

   • Foe

 3. Third

Same thing but with paragraphs:

 1. First

 2. Second:

   • Fee

   • Fie

   • Foe

 3. Third

<p>Tabs and spaces</p>

• this is a list item indented with tabs

• this is a list item indented with spaces

◦ this is an example list item indented with tabs

◦ this is an example list item indented with spaces

<p>Fancy list markers</p>

 (2) begins with 2

 (3) and now 3with a continuation

 (3) iv. sublist with roman numerals, starting with 4

 (3) v. more items

 (3) v. (A) a subsublist

 (3) v. (B) a subsublist

Nesting:

 A. Upper Alpha

 A. I. Upper Roman.

 A. I. (6) Decimal start with 6

 A. I. (6) c) Lower alpha with paren

Autonumbering:

 1. Autonumber.

 2. More.

 2. 1. Nested.

Should not be a list item:

M.A. 2007

B. Williams

——————————

<p>Definition Lists</p>

Tight using spaces:

apple

    red fruit

orange

    orange fruit

banana

    yellow fruit

Tight using tabs:

apple

    red fruit

orange

    orange fruit

banana

    yellow fruit

Loose:

apple

    red fruit

orange

    orange fruit

banana

    yellow fruit

Multiple blocks with italics:

apple

    red fruit    contains seeds, crisp, pleasant to taste

orange

    orange fruit

    { orange code block }

    orange block quote

Multiple definitions, tight:

apple

    red fruit    computer

orange

    orange fruit    bank

Multiple definitions, loose:

apple

    red fruit    computer

orange

    orange fruit    bank

Blank line after term, indented marker, alternate markers:

apple

    red fruit    computer

orange

    orange fruit

 1. sublist

 2. sublist

<p>HTML Blocks</p>

Simple block on one line:

foo

And nested without indentation:

foobar

Interpreted markdown in a table:

<table>

<tr>

<td>

This is emphasized

</td>

<td>

And this is strong

</td>

</tr>

</table>

<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>

Here’s a simple block:

foo

This should be a code block, though:

<div>

foo

</div>

As should this:

<div>foo</div>

Now, nested:

foo

This should just be an HTML comment:

<!-- Comment -->

Multiline:

<!--

Blah

Blah

-->

<!--

This is another comment.

-->

Code block:

<!-- Comment -->

Just plain comment, with trailing spaces on the line:

<!-- foo -->

Code:

<hr />

Hr’s:

<hr>

<hr />

<hr />

<hr>

<hr />

<hr />

<hr class="foo" id="bar" />

<hr class="foo" id="bar" />

<hr class="foo" id="bar">

——————————

<p>Inline Markup</p>

This is emphasized, and so is this.

This is strong, and so is this.

An emphasized link[1].

This is strong and em.

So is this word.

This is strong and em.

So is this word.

This is code: >, $, \, \$, <html>.

This is strikeout.

Superscripts: abcd ahello ahello there.

Subscripts: H2O, H23O, Hmany of themO.

These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.

——————————

<p>Smart quotes, ellipses, dashes</p>

“Hello,” said the spider. “‘Shelob’ is my name.”

‘A’, ‘B’, and ‘C’ are letters.

‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’

‘He said, “I want to go.”’ Were you alive in the 70’s?

Here is some quoted ‘code’ and a “quoted link[2]”.

Some dashes: one—two — three—four — five.

Dashes between numbers: 5–7, 255–66, 1987–1999.

Ellipses…and…and….

——————————

<p>LaTeX</p>

• 

• 2+2=4

• x \in y

• \alpha \wedge \omega

• 223

• p-Tree

• Here’s some display math: \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}

• Here’s one that has a line break in it: \alpha + \omega \times x^2.

These shouldn’t be math:

• To get the famous equation, write $e = mc^2$.

• $22,000 is a lot of money. So is $34,000. (It worked if “lot” is emphasized.)

• Shoes ($20) and socks ($5).

• Escaped $: $73 this should be emphasized 23$.

Here’s a LaTeX table:

\begin{tabular}{|l|l|}\hline

Animal & Number \\ \hline

Dog & 2 \\

Cat & 1 \\ \hline

\end{tabular}

——————————

<p>Special Characters</p>

Here is some unicode:

• I hat: Î

• o umlaut: ö

• section: §

• set membership: ∈

• copyright: ©

AT&T has an ampersand in their name.

AT&T is another way to write it.

This & that.

4 < 5.

6 > 5.

Backslash: \

Backtick: `

Asterisk: *

Underscore: _

Left brace: {

Right brace: }

Left bracket: [

Right bracket: ]

Left paren: (

Right paren: )

Greater-than: >

Hash: #

Period: .

Bang: !

Plus: +

Minus: -

——————————

<p>Links</p>
<p>Explicit</p>

Just a URL[3].

URL and title[4].

URL and title[5].

URL and title[6].

URL and title[7]

URL and title[8]

with_underscore[9]

Email link[10]

Empty[11].

<p>Reference</p>

Foo bar[12].

Foo bar[13].

Foo bar[14].

With embedded [brackets][15].

b[16] by itself should be a link.

Indented once[17].

Indented twice[18].

Indented thrice[19].

This should [not][] be a link.

[not]: /url

Foo bar[20].

Foo biz[21].

<p>With ampersands</p>

Here’s a link with an ampersand in the URL[22].

Here’s a link with an amersand in the link text: AT&T[23].

Here’s an inline link[24].

Here’s an inline link in pointy braces[25].

<p>Autolinks</p>

With an ampersand: http://example.com/?foo=1&bar=2[26]

• In a list?

• http://example.com/[27]

• It should.

An e-mail address: nobody@nowhere.net[28]

Blockquoted: http://example.com/[29]

Auto-links should not occur here: <http://example.com/>

or here: <http://example.com/>

——————————

<p>Images</p>

From “Voyage dans la Lune” by Georges Melies (1902):

lalune

Here is a movie movie icon.

——————————

<p>Footnotes</p>

Here is a footnote reference,[30] and another.[31] This should not be a footnote reference, because it contains a space.[^my note] Here is an inline note.[32]

Notes can go in quotes.[33]

 1. And in list items.[34]

This paragraph should not be part of the note, as it is not indented.

<p>1</p>

/url

<p>2</p>

http://example.com/?foo=1&bar=2

<p>3</p>

/url/

<p>4</p>

title: /url/

<p>5</p>

title preceded by two spaces: /url/

<p>6</p>

title preceded by a tab: /url/

<p>7</p>

title with "quotes" in it: /url/

<p>8</p>

title with single quotes: /url/

<p>9</p>

/url/with_underscore

<p>10</p>

mailto:nobody@nowhere.net

<p>11</p>

<p>12</p>

/url/

<p>13</p>

/url/

<p>14</p>

/url/

<p>15</p>

/url/

<p>16</p>

/url/

<p>17</p>

/url

<p>18</p>

/url

<p>19</p>

/url

<p>20</p>

Title with "quotes" inside: /url/

<p>21</p>

Title with "quote" inside: /url/

<p>22</p>

http://example.com/?foo=1&bar=2

<p>23</p>

AT&T: http://att.com/

<p>24</p>

/script?foo=1&bar=2

<p>25</p>

/script?foo=1&bar=2

<p>26</p>

http://example.com/?foo=1&bar=2

<p>27</p>

http://example.com/

<p>28</p>

mailto:nobody@nowhere.net

<p>29</p>

http://example.com/

<p>30</p>

Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.

<p>31</p>

Here’s the long note. This one contains multiple blocks.

Subsequent blocks are indented to show that they belong to the footnote (as with list items).

{ <code> }

If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.

<p>32</p>

This is easier to type. Inline notes may contain links[32] and ] verbatim characters, as well as [bracketed text].

<p>33</p>

In quote.

<p>34</p>

In list.

/9j/4AAQSkZJRgABAQEASABIAAD//gBQVGhpcyBhcnQgaXMgaW4gdGhlIHB1YmxpYyBkb21haW4uIEtldmluIEh1Z2hlcywga2V2aW5oQGVpdC5jb20sIFNlcHRlbWJlciAxOTk1/9sAQwABAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB/9sAQwEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB/8AAEQgAFgAUAwEiAAIRAQMRAf/EABoAAQACAwEAAAAAAAAAAAAAAAAICQUGCgf/xAAjEAABBQEAAwABBQAAAAAAAAAGAwQFBwgCAAEJChEVOXa3/8QAFgEBAQEAAAAAAAAAAAAAAAAABggA/8QAJhEBAAECBQEJAAAAAAAAAAAAAQIAAwQFBhEhszE0NlFUcXR1tP/aAAwDAQACEQMRAD8AqQzziPNmpiqnIO1q4H+WkB84MdlzRSuM82/jVw/JCORtRmQz5d2VTy6WmS2eSYx3U/qkSRbgFsqRzH2Is4/mCluXc33vy8xTnJjTNqV/T8LKmkhr8Hq1da2aOvTfIh2CFeNt+GxFBP8AJFdFUbPWh+4FdXV7OtZOMR7mK9lBWNN+JBmMQ5cwmfH8DEFhTZUCRlE6CBq/ds/nBh9oYygeY1L9FnCUnBSN1t+w0l9bNomx1cllsOrL9OCTKtKOIqua6UVjP0dEvTyM7gp/3whbkAD0ScX3r6MLg+C2/XsMhCnJRn/5cVNHyJHiX6JKIFhhqnFeagm9BIgjfcJyNBTZiROBUk6Mp8CJRmT4NWU2MatV7n495DPk/wAbMJSRJOTBDItq0KR5s/nJN7LPW8AJWtYAoKQaDp+u4XShxgXhYcbHoxNTllCwETGQ8ag2jmDVsk8w/wCOp/C/hn+mWV/utpePH+D5wmF39NY6UakjUYR1Dn0YgRM5zQAAAMdfAA4AOAOArjkMNQ3vgm7UKtBR+m9QHFD5tpnDtpy+t2R20gK/OsmFtuDpaL5mVyiT5qdEVAvZci5ch5VoSGKbwlWTBr0RPoZT07av9lHfrXo6yLApWMugKpPM9SV1cDm65s/wkOHZBojoqiM+6GpMSj4FhtayNAUi5H3LfQBG2KWssFoSPuJdKyMLKtpuLi+e3jwFICUg7CSHsNVlYlKdizOTvKdq3KTsG8pQirsAG6vAB5FdhP490U4gfjxi+DedoqO4YftmKdKNulO26jiOv+2Ga/bftVNFXpHtVHrpLpRFJTpP3z77T469++fTx48e4LueE+NY6UKk7UniLP8A7rNf3X6//9k=/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAD6APoDAREAAhEBAxEB/8QAHAAAAAcBAQAAAAAAAAAAAAAAAQIDBAUGBwAI/8QAPhAAAgEDAwIEBAQFAgUFAAMAAQIDAAQRBRIhBjETIkFRB2FxgRQykaEjQlKxwRXwFjNictEIJEPh8SZTgv/EABcBAQEBAQAAAAAAAAAAAAAAAAABAgT/xAAbEQEBAQEAAwEAAAAAAAAAAAAAARECEiExQf/aAAwDAQACEQMRAD8A2t0YoQpwT2qVzMV+N3UHgrDY2eoM0y58VEbgfp9K1yMRmnuJ5h40jyYHGSeKrWE8u2QAApOMdqGCsmT8h70TAJwMAZx249aKBy4c9vTNUC0zDCgmmmG7Ockjkj1PrUTAjcy5XP0ouCgHae4IomOJHhgIc55PHY0Uk5IXLMcUBQ27n96JYO2MYLebHtRBA7BcMx29sdxQJqwZRtIP+BQKpjHHc+xzigNGoAO/k+nPAoAYlee5oBiGeWySO9AJCgY5PHagFCADzj2GaA2N2TkjA/U0HMwbPPeiyBLDfkkj04FCl1cBMgn6URwYFGySR6D2oAeQDAxnHGKAhU4IbGc+tFwnwDj9aK7f8v2oNu+IHxNvJdXmt9EmKWSqArA/mPvxUxMZNe3Ml1dvNcMzSSEsxPOferJhht/OWyAPc0UfdgDcuM8n50AMCykZFARsngcY/egTcbjnJz9O9AB2kZGSQOcUCX8x83bntQCMruJ4B7D1oCyOGzxtJ9M80CAdg5UjFE0aFJrghLeNpHY4IRdx/QUNWCw6D6q1EZttEvirHAZ4ig/U4qw1b9H+CHVN3Mq6hJaWMJ5ZjJ4hA/7R3P3q3ET+pf8Ap/lWNm03XkkkA8qTW+3PHupP9qxopV78G+s7VSV0+OcAn/kzqSfscVvIKzqPTWu6XKE1LSL+Bhz5oDg/cd6lEZzGwLrtPqrA8frUCJfcw9gfegUjZsEAffNADyHt78UAjCjzDJxRcO5Pw3gwCGOVJQp8ZncMGOeNoxwMY96GCbQffFFcUXKjDDt2NEo+N3yyM5z3okKuqJgIzONoJyuMGi4QfGcqSfXBoYHJx659qKIRnnsfUGgJn/poJYoTIGLY+eDzQFlQK2G/KCTmgbspfO0qce/agPGcR7nHf9vnQFfBPlOc88Gg7uucc/M0Bd208YJJweKAYrea4kKQICRGW5IUYUZJ570DYqcknt3FE0VuVyDzj1oamOlulda6puvC0a0eZVIWSbtGn1Y1NNbX0x8ENH0qL8X1NdtqDoNxiQbIh8u+WpqL70Tc6fcxypouiRadbW8hhLFFXcB7Edz+tNFvEZxkmmgShbA9PlUA+Hgg/wBqDgmBkd6ArJuJBGR7VdEdqWgaVqMfh6hp9pcLj/5Ig2KaKJrvwW6S1EFoLaWwmPIe2fAz81ORTRm3UfwI1mzBbRL+K/ReyS/w3x/b+1Wexmev9O6xoE2zWdOubUDszr5T9G7H9auCJj2n3PPrUXTlGBB2kYx96GlQMjJJHuRRXBgDgk8DtRKH8w4OfYA0SUlIMsFXJ4oujHH8ufnRRGOSNoJNAeFC77F2jPucfvQFEqgY3nj/AKaCUY58wwq54AoCzOmVMke9QeRnGR7ZoEIF7pnaTk49KDpSSwQntQJsGKjgggZ9uDQc4OOe1Am2UCkHOR7dqA8t/cSW8MEkrGGEsUTPCk4zj9KJT3pzQtS6m1aPT9Jh8SVxlmJwqL/UfYURuuhfArR7f8NLrF1cXciKDJCrbI2b7c4+9NGtaRptrpdqltYW0VtAn5Y41wBUodvGjqUdQyn0YZqAIreOBFSFFRF7BQAKA1xcRwKplcJuOBn1NAR7y2ikWMzoZnGVQHJNAuQcD3oBKkD2FBy8jnvQFxnjjmg4rxwKBMqCBtPNA3vbCC+tngvYo54HGGSRQQR9DV0Y91n8DNOvFkuOmZmsrk5PgSNuiY98D1X+1XRhWu6DqWgX72er2j2069t/ZvmD2IoGG7jbnj1FFlB224PB+VClN4DYJHyAojmPGCck8cetCAxgjPp6UaAGKtx6+9ATAXO7nFBw8HHLN+goJhBuj2FeAcnmgNazW8U0vjweODGyqpYrsYjytx3x3oGa5LEEjH9XvQGlgmjjMmQq4HBPfPYgevagG5nhe3tkFuInQHxJQTmQntn0wKBKTlAeDx60DSY+U9zn+mgsnQvROr9Y3W2xi8KxV8SXUnCrjvj1Y/IUR6c6A6H03o6wMVgrSXMoBmuX/NIf8Djt/eiLfjJwO9ZBiOfmKDhktzQAzYBLZ8oyaDF+rOptVv8AUjNZL4tjA/lT+kr3wvqTQX/pi3Y+DqFxKXurmFWAaPaVzg4I/b0oHlxqV7penRTXFu93dPLsESYB2k8n7CgnradLq1WaIOFI/K42sPkRQCg3Kcd6Dgp3d6AdrGg5VxnjmgKWB8uQGxnFAUgKuSefSghuqNC0jXbAWGtxQyJKdsYc4YMf6T6GtDzR8S/hnqfSUz3NvuvNILYSZR5o+ezj/Pb6UGfLzyD/AJoFFySQVBHpQDJ5kGByPahAbWxn5+po0OF3D+XPtQJsNwOe+aAuygmMkebgHnHFALHYpJwSeGz2oGpOJWAI49BQEZlYAHkg4oARVOMvtBIJJ7AUAX6xxSOsUgmjViFcKRuHviiVfvhT8NZuqpk1LVFeHRkPlHZpznsP+n50qPS+mWVppdnFa2cEcFtGu1I41ChR8qyHVxK8cLPDD4kgGVQHBNAa0maaBJGTYzDJXOcUCy5JOaA2OMfoaArkheM7vlQNYNOtoWLJCgLHJwo5NApPKLaNpGRQB6j2oGmnRvcyNd3O/DkeErLhkWgklIdCyZOCRzxzQEeRxhdpUnncBkD5UCxXjJ7+tAlctMsIMLohz5mcZAH09aBQYdQwyAeaAuA7MAQxHH0oG1481nbGVInuWU5Kr+bHrgepoKB1u+o6jqlvBH05NevEBPBK0pQR4I4BHZj+1Bb9IS7lsFtNWtYwDGFYB/EXHqpJ7/WtQYx8VfhGbdZtV6Uh8gy81mpyR6koPb5UGKY4YkeYd88fbFAI5AC98c5oQBb+U9+9GnN5RgDgjOPWgAN3yMfWgAqc91/UUD2RSSRg9+49KCR6e0WfX9WS0icRwgb55WOFijH5nP0FBYNRi6dSR7HRNPmu0hOW1GaXaZMdwBwAP3oynE0XRYrFtV02wS4ECj8dp1wcsE7eJEf39qlFZ616ZttPu7Kbp9Zbi0vYzNCcgjHqoHuKsEp8LPh7P1PqjXerxywaXaviRSu1pWH8g+XuflQemIIY7S3SK3hVIo12pGoAAA7AClEL1N1RH0/oTalcwx+IACLaSQKx59Ppmshv0D1jH1ZbTubU27xkkAnKsuSMg/UUFluLlLaJXETyecKAg554zigXiubeRnSKeJ5FOGVXBIPsaBLULoWkIfw3kYsAqIOSTQJMbpm3oqlmwACeF9yfn+1A+Bx34oE5IY5P+YFbnPIzQKAckHuRQCAQOO1AL8r9KDhkZOT9M8UCcrxgAyYJzwD70CT3Itxm8kgi3fly+P7/AOKA9pskhEkZysnOfeg6RH8w3tgjAHtQRZ1uystSg0m5eRJ2UbHceV8fP3oJkBSAVII9xQFdSRwKDDvjN8L/AMSJte6chxcgFrm1QcSf9aj39x61YMH8Q+CkfhqpQncxBDH5H6VRwXJ/Ke1Am2QchuMYOaNFSAVznB9qAm8f10D2RmX8jDHP3oLbebtA6ej0m2LrfX6LcX7IMskf8kf6HcffIoG8yTadZxSTxCK3kRZUwSFfkruIJ78GhiS6Y1OS3160uZJFWO5bwZtxzuQ8bcfPNMZXvo2wsLnQ9R0q/maJNNv5Yo3bjCuMAHPzqA2jdUan0lF0/ZXcElxp9zE+5WVd/DE71IPPB7H2po1bSNXsdYthLp1ykyEcj+ZT817ioITrnoux6vs1gv5JYnjz4ckZ/Ln5etA+6N0BemdBttMina4WEFfFdQpIJJ7D60E5I4Vo9qnnsQO1A3k0yzeTxhCizZJ3qNpz9RQO449igMSxHGW5NAIwBtUAUAMORkfegMhG3jtQD8+fvQGXJz7UAHuRQA5YDI5FB0qCQA5yaCs2/SFit/Jd3AmvJ2bO64ctt5zwD2oLMilVAUDgcAelAJLbhgZz3oGN9HPIYmhtrWRw2czjt7Y+dA+h3mJS67W9gc0AvuLYANADpkZABHY85oPOnxy+Hx06Z+odGjC2jt/7qBRwjH+cY9D6/OrKMebcceHwfaqCYIyDgZ96GhHOFJI4/WjQpXnsaCz9J6fDqGvRC8OLO3Vri5PB/hqMkfc4H3oDT3UupapcXrKS9zISgDdhnAGPbsKC5aLLBHq9p01c6bbagPE23kpJYhmz5IySAAMj6nNGdRnT2lu3V9vaQQrJDHfCMFj5kAfufsMUFogu5H0jrLUYXK+Lq0aRse/lf/8AOKlFfudagvbnQpNQRmtILydCwPdCQcgMOMZFQanPoeiawBd9M6s9jeKPK1vKQp+RFA4septa6fuFtuqbRrmzx5b+BAdo927A+vsflQXfTr2z1O3W5025juIW/mjOR9KAZI914khaRNo4XdwT9KAl3b2+oWpjMoZWbOVfnI9sUCrXUNssUU8w3sQoJH5jQLvwQQC3NAKvuUPtK54waDg23v6UA7weBnNAIOBigMr+hoOjdZQdhBx3waAVG0Z7UBWfAOQSflQChyNxBAxQRutarb6bHALi9trSW4kEcJnGd7ewFA/j8QEK/IA/MBjmgWDDBB7igj9dupLTTbiaHZ4oQ7A7bQW9ATVgwXSNV6onl8azW6t45pWdxHIxWA/zNtz7A8Glg2S1u7fX+nt0J/H2c4MMhmQoW9GBUjj60g8sfEHpebpDqi4sHLG2Y77eQ486E8fcdvtVFekGW4UfegKVAAKgnFGhuDzxQXbpDTZF6a13UnUqrCOzQ5wGZmXIJ+lE0ppkEK6nJcRWcTW9hA08iKcjcowpye/mxQ0+6VRbC/jvLm48L8LG9y8pIOXxkDnuSTipqHXQMng3es9S3fhn8DbvcZI5Mr/lH700dc3Dad8NtPs4nU6jeXD6nMCwBRF5XOfU8YHrTNJFF1X8RawW1jc4GxTKNrZB385yPkBTFw1stSu7Ni9tPLGSQfK5Aphi8J8UNUm6fn0u72yvJ5fGbuF/39aYYtGgadp9/axXnRetzaXqnhqZI3bEcj4547Ak/X6UxFisPiXe6NMdO65057eQAr+LhUlHHbOPX07UwWXpQ6BqMo1LpgW0sioVI8Qgxk+684qC028M5890Y3kHKbUwF+lA4LDOzu2M4FAOG3DaoI9cntQdJxzQEyR259f/AKoGl5fSQRFo7ZpB/MhYIR9zxQdayyXKb7gqox5Yo2yB9WHc0DPUIWnhWKxkuYFRs5gcKWbPY59KBkx6isVeSGW31JNwHhyOUkA+o8v9qCfjkMo/LJFKqBmRvSgc2swnRyFcYODuXGfpQMtRsLK8vYJL+wjuGiUtHK6hghz6Z7H6UEmCsig84I9RigiruC9t0DaaVmIIHhTOQMeuGwT9qCJ1ywv9T0U29xFFiaVBJGHz5M5ODgYPY/arKJPTtLW1t44i7SKq48w8x+ZPrTRJoipGFQAAdgKgzX47dMJrXSrXkUe6807MykDkp/MP8/aro80FQyZ+tUJ7hvH0x270XQ7KGtXvIk0T4c9P2bIhkvpnvJVfjIxhf7qftRDXpu0/1DpzXltUlkvmWMBI+2zdnn64oYa6yX0XTm0i4jQ3t6wmuV53xov5UPpyeeKyLbpFtZ6Xpmn6TqNq7/ic6pqQRR/DVf8Alq2fTOP0FXBnXU+ox32o3lzeW+JrxlMXHKR9wfbJ/tVWK5f3AnaAjafCTwwcY4BOM/qKKSjA4Dg8j37UHZKkE5P0olSFlcLDdJPbTNBOigjxOVZu3+80Rbbnrq9l0t9I6isRd2rgKpPlZMdyre9An07oupoh1zo2+lea2fMlr+WZFx7ZwwqWDVug/ihDq7R6b1EPwmpMNokPlVj8xng1BqEUe1EAJOMDOc5oDSxq6YYeuaAJF4oCBUQ7mJ45zQHYB14wR86AVjBXyjge1AEcRTHlA9hQE8kbgEohJ5yQM0ETHNqMOr3IZQ9tIMQyEjKt7D3FBLqywRPJKTuxlj3zQI3Ut14e+yhWRj28Q7RjH60EfpF3rU/jLqFrHbS4/hqpJXH19aCRa8jgiVr1xGwXzYyf99qA9tc29/aRXFnKs1vINyOO2KByoxwe9AYocHGKBvdwLcWzxSLuR1KuD6gjBoPHXWujt071Nf6YSSkUnkJ4yp5H7f2rQgWAA3Y+1An4j/1t+tBrHxKuYS+gx24LRx6ZFtI/lz60FY0+/v8ASphNpd68EpXY5AGNvzFF1YOirZbzVrvX9dkNxZWH8eeaY5Lyj8qj7kcVlETqOqXd/HrPUNzcNE16Tbwxf1JkEgD2AA/etBte9R2Oq2cv+p6XHJfBFjgmjkMaRgAAEqO5o1FWfbgjsR8+9AlI5CgEggeoNAq0iug8uD7g80KKmCcZ7fPmjJzJfT/hWtjJvhOPK/OOe49u9A96X1W90/VrRtNkkSfxQF8I5yScdvX6UGidSLpfVFzcvbRiy6kgZBGysFW7B9T7HHNSjU+o9S1iz0e2uNLmX8RYxJ+KgYeVwVGTn5d6gjug/iU3UOt/6TewQpP59skL5B29x/8AYoNHPB78Ggb2l3bXO78PKsoyVyvIBHBFAoSkbfyhn4GfWgTnmWFN7ybAvc4Jz9hQRdx1dp0S3Dw+JJHbDdPIUZUjX3yRz9Bmrgzbqb4x9Oxho4bB751O5HPkXPsc80wQHT/xrJ1IHUbGKO0kdRiBiAgz+YjnsPpTKN/tLy3vLOK5t5klt5F3LKhyCPemAYLuK5XMDEj1OCP71ArGWLMPT0oIbU7h11u2t49OllWWNm/FIRsjI4AI/egfQ2ktpbww2XgxoDl9wJ49cUCHUGv2GixM13Mkcm0squwUH5/SrgxDW/jFcXOteHb3otrKEEiRISRM3zGc49v1qDT+gfiBpvV7y2unxTxywRhz4ozuHbOR2+9Bmf8A6kNIEWpaZqiooEqtBIR6kHI/atfRjDEt3AKjgVQjug9j+lQWh72e/htTOzyeCnhHPomeMYoJvQum7vVD47K9jpsQBkvZ5NoAHcgUAa7rKamE0Lp9Xh0G1OZZTwZSO8jn9cCsivdS38F9cJDZIY7G2URxKe5x/MT7nNaEKrENwAFPPlosFwS2cd/cc0UlIm3JOeKDo2LH+UA0SjgDk98URzPiJ2449e/NAbS7v8PdpKkpikQ5WQLkqccGgmYNQmXWLeQLG9wVRQVPlcj+Yn3xQa98OviAjz3WjdXSpFdliEuJCNjDtsJ7enepRdel+kdL0rqOTVdIsoYklV1dixO3nunpg9jUCnU3WMeka5b2EUcl3JInmigQs6ZPlJAHY8+vpQP9O1m3nthNo0cTwM2JDwoVj6H5gd6CbhtUiVn8TcXO4ktkZ+We1BAf8Z6fZ2uqXWpyxQrbStGseQzMB2IA961B59+IHXmodXal+HsPFh04HbHCo25+bY/zQWv4f/CCxvII73qC8iuXYb1tYZeF9txHf6U3BatX+DvSl86x6cr2dwjbnEUmcj6Enj6U8hLdJdEX/SmowJp2tTT6Oc+La3HO0442+3NBf1LmRUjjQAfmc+nyHvWQockYyQcY3CgaabaPZxGNnaUFi3mPb6f+KA2q3RstNurnBxDE0mPfCk1YPMemaP1L8RtYN9fJPc2aMUaVmCKg54H0z6VRYendf6Z6T1W56a6j6fgfwJyguhGJmPzbIzjHtSjTn0zSunbi01fSkt9Os5GAmWNCDOGxtXb6HnNZEZ8etOF90DPKFy1rKk3zAzg/3rXI8u7zvOTg4zVoTLDJ81QWDTb2SwuvFgcrkbXwM5H0PFGqsjpd6+kcT61Nc2ieb8OikFc/9PA+WfSjKA1nWBzpFlZ/hLWM4KH8zsPVj6mghN4IyQRk5NGo5BkFmyAfSgVjChdpGO/FAXYpOHLBe/FAQqoBJbA9sUBGxgtgEj/eaCf6DGjt1TZf8RNGumKS7mQZQkDIB+WaMrf8Ub/ovV7V20JIYL62K4khhCLOCcEcAdu9BmCuEQvxvyFUg42+v+/rQaj0zax/EXRY9Nns0t9TtM+BqCKAjEclXA98jn+1Si7Cz6u6O0tLjTrxLu2tQJJrDwcKE/m2M2SfeoLrpupDV9Mh1OytUS2vIN8m4BZQf6T7+vPpj50GfdK9L6rJqk1y1y0elRDKRqdjHHoyDhjx39e9BZr7fagW0j3kul3iETRqHkeF8ZBUjkZIxjtk5rQ86dW6r+O1OcW0UtvaRsY4oWfLKBxz7k/5NA46P6X1rqS6WPS7V9v88rAqi/f3oN46X6C1DSotkus+BIwKl8hn2+3PapROXPT2t20bPY6kJ5UGYmbIfIHGW5z68VBI6DrzzWSrrAjtrwFUbDja5OBlfuaCbluJLeNwIpLiVF3bVXAP0Pv8qBxLO8cYcW7vnuqkAigNFKs8CyxlwG/lcYI+1A31ayF/pt1auSFmiaM/LIxVgwfoO413o3qqfSLyUSwodogAyZVGcbPTPr71aNDvendJ6wtbu7Fi1lezK0bS4VZMjtnFZE0bC5u9Jh0qRAr2yw4uWx59vBI44PegN1tpbap0lqOk2sipLPB4aFsnHbBNOR5A1exFhqFxbeKkngyMhdOxIPcVuhiZFz/zBUEwcKvYnP6fWi0+6chjn6h062uATFLcRrIMnzAsO9EehNR+GvTV3GUh0+O2YsGaWHIf9amjIfib0no3S0VtFY3M000zMzLJtLKvvkenyx96oz0rwNjA8cj2osFLbVAbOc9jRQiXOAwxnj3oBlAxwDj37UDY+vHOQeTQBIdqjcPMfnQwJclWyBgCjJBFeefw4VaVycBUGST2wAKD0L8H9C1rSIILjWLSCytY1lZASVnlL4PI/wD8+vvUo1uwbxI5GkjdVc7isvOBjtj2qBWKFZiQ8CJCB5FHYj5jHFArDbQ20ey3RY1HOAOPsKCH1u61CPSLt9MtlXUHUrbCbJBbPdtvYetXR5T1y2udD6lni1ErJdJLvlK4wWOCePvVgsV/8Sr67UW1vA0NiowIonMe4+7FeT9ARQRmodWa9EYpPBhs1Tygw26rk9xknkn70EjonxZ17TXjAeKTkZ3L+YZ7N8vpSjX+lOpNM6umgkMG3EgBV1DYbG4kewz2NZGkC43CP8MPFBONysMAD50DaHVH8S6N1a+BaxMUjd280pA5wPb296DrXWLK9WNoJdtwybxDKPDcAnHIoJBifTBzzmgaz2UFzPFNNbwvLCcxuyglT7igdRRKg8qAZ5JAAzQEnuYoHiSWQIZW2ID/ADH2H6UERr12BY6hueIQJaO7SK/nHfnHtx3pyPGWoN4jynuCfU963RF+DL/UtQWTkjaWY/8ATnHFGql+j1VerdJY8r+KiJz/ANwoy9C/EjqSbpbRY723RJC8ojIcZ4IJ/wAVkecer9en1+9FzeLCCq4URjgDP7mtLhteadBY2kMczyHUpcO0YxtiUjgH/q9celAiLy1kjCX1ruyMLNGdrj0+h+lE0+t+kNQltJ7yKS3jgiTxUFw/hySp7qp70NV6YEBgWUNjBoaKeAODnHrRoVgDnBP0ozpxZ2f4y5trVeGuJFiBPpk4zQep9C0LTembS30fQbWP8ZsDyTugZgf6ix9fYZpbgmbXSmXULaa6kMzpltzcjJ//AGpaLCY1CDsF74PrUCgHY0HbSx7Z96BGUfxB2xjtQZ11t0Tb6jNfyw2wM18gV5AcBdpzyPnV0Yp1F0o/TEczXjXaTOQYpIk3QlT3B9Rj0zVl0VKbVppImheUSwbsgFfXHc0De0tri/ujFYQSSyfmKopPHqaDV/g9p+padr/gkSRTzKu0kZRlPLYPbOPf2pg9GWzRCMJAFxH5do4wayKX1z/G0CdzqLWRkiaTxQBLudclQvovbv3oMU/4Z67uwnUAt3u1Zw42yhmx3/Ln8v0oN86L1d00i3i1UiGQIocNnEbnkqT2xgiguEbI4DIysp7EHNAZnxQQ/Usksej3EsCl5EUthR5sY52/Mjigr6Qrp3R15LqEcIlmgdpFGAsY2navPJApyPJtwd8rnGBuJz6Gt0MzGSTyf0qCwSKA5ZsAjnn2otTXQYj/AOMNIDqCrXUZwf8AuGDRG6fF6Gyfo6+ub0CR4EPgIScLIeAcfc1keatN0661a+S3sYTPKzAbV9B7/StLrQ/iXp9pYLp8elWsUM11AzXMqt53I7g7j244oiB6W6Tn6j2TeAy2FspTeB+Z+/8AmgtnWlvpdl1Dp1pq07Ja20GFQpuDHHAwPf39KDHriVTKSPOCeBnHHtQGsrG5v5pfwcTOIlMjgEeVfck0XRIreS7uUigRpJXOEVe5PtRE/wBJ9HaxqvUcdhNFJp0lviaSWVcMgzxgdySeBipo9T6O8NppUJ1K4iW5KgSvIyqxb5jPH0paJm1NvKivE6Mp7MpyP1FQLRTwy58F0cjuAckfagOTtO3+Y8igMWCIWbOPlzQNhNBOWEbq5Q+YKc4+tAD7JEZgQfXj0oI/VtIttXsZLW5hRopByCP/ADVlGRa78Erae63aXK1tG3LAncM/Kmh10l8IZdBv4rxtTE0yggJsyoz6/P0po0zSNKEMdo9xGnjxuzkqMAEgjj7GmialjWQMgyCRyQcGoITqHT7q/a30+G2jFmwLSzl8GPBGFA9c5NBPRwJDbpHCipEi4CjtigqfWltqCaG8WhNbxyzOBIs8W8FcY4+dWQQ/wtuZdIGqadrknhy2u2QyOSEZOeRngY+XvTBZZevOmhC8janbqiZ53Zzj2FMFcs+sh1ZqsFrp8UkGkrlpbh+DNzhVX5Z5NQTfXyWUXSV2t+wW3EZ5I4HHt61eYPI0mA5C9snFaoLsPv8AvUEk5JcA8cZG480WnOlXX4PVLO4yQ0cyP244Yf8AiiPUfUump1B0/c2O8xfi4v8AmL3UcGpgw/SujNX0Trj8PpckimOMvHO/kEg9Rjs3PpV0aFq/Qqa1ZJ/qcrverEqNOwGM+uMfemiVtrKbQdMNjp9rvtkhPht6mU5yT8u1BkvXg1qXUtOvddgRY1R3j2YHiMvZSD27CgzSCyuNQ1KK0giL3Mz4VAOc/wDignoNNOnaHeiW8hgkku/Al2+Ziqgn09M0ETp0qpqSmGKOdFcEeLwMfPHag3JLuCRtPmQWsDhNphtVAcn1w3BPFSwDdWGpX1/OYdOtbbSrlQ80szHdn0GR24/c1AbWemdatLbTJdGvJIJypDQwMV3exwOPatSz9Ei/R+txy2mr3evyHV4miWIDhGwwyGA7nGRS2YNZAUBWYDdjGayEvxMYB3nYu4KCfU+woG93c2enWs1xcPFDCp8zEgDPzq4GGgz22saS1zZSZhkdsFePXt86YHWmySeLNDMYikZ4YNlvvUD+VARxQJqgwRQHUAAe2O1AWOFRM8mDlgB37fagb6reXFt4ItLZJnZsuWfaI0Hdjwcn2FAz0nWX1i4u4xY3VpFbv4eZ1x4vGdy/KgkriN2aMRlQoOW3DOR/5qwYr1P1tp2pdS3WnanKkGh24kRl2eaYgcb/AFxnnAqiv9Jno0dRLJPbtdQtkNPIALaMnODsPPpSjbdK0DTbWQXui+Gsco3BU5hPP5gPT7VkU74t6PZHpq/1N5ZZbwrtRnmOwDPOFJwPsK1xR5ybudw788VaC5X2WoJRULSBpAe5PA/aiinAZnHck4A70THq/Qr23/4Y0u4lmCpLBGA7epxjH60Du+WGOBvFlFuWOFcYyCfbPrUojri6k06xX8PFNfBUJ3ltzM3scVBjfVvVXVNit5dapNDZGQGK3shjeAe7YHIwAOT3zVggNTiu+orrR4p7m+upJFR7h3TPhggDaoBwRjnPH5hV0af0xotnoD3l5dWdrY2YjGLhwPEHoef996CC6m0HpuPpk3Wny2s9sJPHJ3AeI2D39T37UGU9QTDULuGPSLPwIyoVIYk2lj6/X70G2/DPp0hVudRuBLcwxhRGkeEjB9M+p96DSLprVHiieaAE+YxHkke4H1qUOIBawL4uAuc8nvj71AwjRtQ1eO78QNp9odyLju/qT8uf70Gb6r8SpLzryy0vp+4NxYSSCEswI2u2Rn3OOD9qC4dVamen9NlaC7tUaIFvCmnHiy4HJXJxnOeDVwed+rOvLnqSyWO4jZSru/kc7ck+30GKosXw2+KmqaDJDY3jR3OmqNoRhtZAP6SP7Ggtmt63qbTJ1XLazJpslwBFblypEOAA7L2OWANS+xrnR2vW3UmjJeWp8wJSRf6WHeoJdSPMCRmgMq8DmgBpNsgUIxBGSccD70DczmS8MDWoe28MN4+f588rj980CktuJZYpFdlKZ4B4OfegQ1hpIrVjbsRMBhBj8x9qsHnX/hm36y1O/u9V1ddPmS6aD8OkQdyxOSe4OMmqLUvwQsYY4Xjv7m4YEEhwFyMY7fXB5pRbvhp0jqfSMV7b6jqZvLGQAwxAEBDk54PuD6VkVb49a5DBpiaNaeF/FIaQDumOwpzMGDEZQZ5+VboR8In1I+9QWDY6gFn7jjHpQhtJEFbAGBnijT0P8H7qPVOh47a42yNaymPBOcDupoykep+m73V7g/8Av2itQowvJIx6j5/OpRjfUWrax051RPY6LqFy8YACkebO4Z7HjNWCY0ToW2utJbqPreW5na4O4R78cehY9+fQVKLX05p1ro97awC4kX8VFmJLeEKdoyfOxJPbHbHYVAz0rqKPWNauri9t1ktJgILYgEiNFJ/Op9STmrBBdeaFCo0y3jt444DI3jLE204Y5DD+9UPPhv0NaRtPq99mSLOy22nOfdh75oNC0vT7m1uJGvGiii3AW8UDbQAeDu9zUohLlhouqap1VciF4I1FtbxSthtobBIPuTn7VBJ2vUth1TYk2ULi9iALwyKQYz6Z9CM0Ft060/DWEcDHe2Mucdye9BFW3SekWt3LPb2cUTsd2UGCG9x7VYMzufhzdX/WmoXj+BPpx3I7XZMmXYckc8EVRKaP8I+nXikLQuxOQSTnBzj6UEjonw90XSrq3S3s7dplJcl1EhGDx396lFx1TQ4NVjaC7UNCU2lAO/8AvNWDCLp9X+E/WgWImXSp2LRq7eSRT3B9iP8AFSjd9P1+21TRodVsMS2rLmTbyUGOePXFQSltcLcW0c1vh4mXcjDswoDLdRm4FvISsgXeTghDzjAPbPyzmgVFxCzuiOC0WN3sM+5oDqySJmNg3rx7UFb60tNUubGJdFdEvhIdryflUFSM49TVgyTQenJemOorf/U4H1Fpp1edAh/hOQTuQ9375JA4q0bnbPBcxxT20wkjKkqYzlT9ayGWu38um2MbLEJ7iRtoUds+/wAgBzQeW/iHqi6j1PdzeL44HkL9txHtWhVUOVyvHNB2F9zQT8hUAhAdp5FCG0mSAzE4HGDRppvwL1bwOpJbEsFiuYyVX3deR98Zoy2ZtRgmjkSRZocEp51K7se3vUow/rfpFE124mVpfD4mk2MWdCc4A+VWCH1281/UmFnpklzPYRFBEG8uGC4yQfcn9alGgaJo95rRsbi53WaxwrHOm7BjYcHnvz/moJaw07pXSI5IW1K0CQnDhpAWB9R796CudY62msTRW+gadI8KnDXMkLLv9MA8HGOKC3dAXF1dRfh75f41moi4G0AdwcfTj7UFhv7RjqMBV5AJFZHkR8FRjIx6CgpXVNjJ1JqNn07p26CztSJLlpIydyj2J+fGaC+afplrazqLa3SKNIggx3IHYUEsBk4wQc4oK11L1z070/M9rql6wuVA3QopLcjNBDwfFboqeSO2W7kQNxuaEhQfnQLt8TuireVoV1UeXnckTFT9DigHRuv+mbu9ZV1W3Nyc4IRlVl9O47/KgtU+s6baw+JcX1umRkAuM/p3oK/1t0rYdX6cqXKESqN8Ug/Mp9P1qwZ702mo9GdUTWJsmOn3EY8CAORGXJAwScjJ5q0bJDNLb6YklxbKsgA3wwndg9sDtWQN3aw3ZKTwLLEQOGORn6ehoG1vYAw3FikRt7JSuH3Hc/GSc5P0oHn4aO2uGuYyiose044wBQIm6F1dwfh5ARs8R8L2BHGfnQHv9PS4PjxrGLtFKxysm4qD3oCxboIIo7e1jhQHzAYUJ8wP8VYM56j1ktaal1BMrS2sAaK1OQDD6eUepY9yfQVR5zv7hrmaSaRtzyHJY0DcE4BPIPb5UBwOO4oJYzFvzEYHAH9XvQhNZN7AEgDOSDRo/wBA1SXRdVtNQgb/AJUgfBHcZ/8AGaGPVlhPbarZ2t5CEeORBKje2RUrI1zYxTBhMinIwcjvUEcugWkO4AMisMEA8N69u3yoERrOhWNxNYy6hapcxAeJHM+D8u9ASLStLlm/EWdpZyxy+Z3RQ3I5B44oJKTT4blFWSNBEOeBg5+goFYbOK1TKhIxnIbGMH50Cpcyo6AMrIcM2OD68Ggb6Lbbllu5Cd88hYBu6rztWglSNkfm4P70Gaat8Rba96w0vp3R2mhufxyi4kO3YyDOV9+f8VYMw+P0cP8Ax4JVuEKzW8bEr5tuMj0+lUZ7Y2X4288GK+towRlZXYqv9uKCQi6YmbT2u11GzaJWKnYxbBB49KCFnhubdiwL+U8OhP60ElpXUFxY6nDdXQF0qYbZKxwT9vWg3npb42aHcmC11C3uLSQjEkpIdQfr3xUondP6x6e6tv7e101hczRzrNtaFiFC/wAxPYHtUF+lj8bYCTgMG59cUC4OBQQOo2eoXepFTeL/AKYQN1sEwWx6Fu+DQLX2kw3Ok3Vjas9qJ48Exd1PHb9KCE6R0G86Ut7mK71KK4gklM7TyKRIBjtjtjj96AOreudJsrMJbXksk8jBCbVdzRjONxBHP/3QQ9x1jcWGkERWWqXdpMPCt7x4wfFOOWPbA+fAqwZr8TJ9Qbp2ymvEjsrSTEVvawyHz45Lv6E4wPqaoyl8g91OKDlYEc8mgKW5PH7UE80f8PPHl7gDFAZkUjawUIQG8w5ouknAUbl9Dg59KK1X4Z9XXFvo8mlRXax3KHfBG8Rk3qe6jHOc54+dMZO7jr/qK8vWtba4tYu38TwvDOMc8N60wPLbrW10PS7pnvrnUtbAKobgBUUk9jg8f/lMC2rydMdRSaRqWoLEbx4UefwxkL2BVvvn9Klgv3Tp0lPxFno6wJ4IVmEOMEHsf2xUD2e4ks7n+NGDaCMu8q8lCMcEfPNA6tW/EwrMybEYZUHnI9Cf/FAzu7G4LXTWs38SRNqhs4Bz3z9KCO6x07UNT6altNMvEs7xkC7nPlI9R2/egwbrDT+r+kupLCeK9nu3KBYGRy+QvdWFWCU6avtA6h1iKDqLRhpmpvkxz2p8JGb3z7k557VRX77TdHteuPBut401CAouyXGcdvmASaC069030brYaay/CwPFwWspRErfUN7UGZX2hWSiY6ZrMc0CvhUlBUk/UcGgiLq2mtG8F54yDwfDfIoGkrRsSZXwOB2zmgsvw06XHVfUcFvI22xQ753Ze4H8v3OBUo9a6XodjpltHbabDHZIhVsQqBuA9DxznFQTQUe5oDYGMnn7UEbpV3JqDyz+BJFbBtsXiDBf/qx6CgDXL42cSRwGM3UzBQrHGFzy32oG2i2kKTSI80lzMow0rqQoyew+3tQO59KtJJRI9rEzgg7igz3z/egZ6paJdGGwW4eBXy7pGeXUdwT6A5qwebPjJrcOr9TvbWZQ2Onr+Gi2nIJHcj7+vyqigOuRk+vtxQAqEk4BU0ABj7j96CzzKxYD0GeM0CQG3OMAjkfOgbSZwzE4PJyfWi6caTdzaffW95akrPFIrLg/tRHpGzs9C6t0W31FrO3Y43MrcbH9c/eloZ6v0JpWoKlrHHBbScSFEHYc5Pz71NDXUoJrK1g0dvw9qsspW3nXaN6KMrHnH5ieSfan0U3Rr1uidaRbiwk8BUSS6naQkjc3ZcHaRnn70wbja6lZX+nw3NvMksM+FXnPJ9DUCeoXj2hSG2t2km7op4U/f/FAvHaNePb3N0jRzRA7VD8Akc9u/FAvcxnawZQ3HYtjJoKfDFAdeub6Vo1dSULIBtTbgYOfU8jNWUVvrm5ih0m1urixhlsI5HJliOwR5/LkkHHJPamjHdQ0HWdemlutN0+YWBYtC0rHDhjwVz3zWgx1n4e9U6QE8XT5Zd//APR5se9XBXbjS9S0zAvbO5tyWKAOhG4/KpQ3ZHXO5JFK98qRUGhfCbph77Uvx91pv463wVjR0LR7s483796WjW7rTrXpHWrSW2YK7lmXTbaIFpCRjjHOOSeeBipaNLtXuIre3R43lnkGXYADZnnmoH6Dkbzn6UDGWe9a/hKG3jsW8riQMJS3svp86B6zgMQmDtGT8qDNb6XUpOoPx72tzOkjFYowOduDwDjj70Gg6Wsq2KNeAJKRuKk52fIn5DvVkENrvW+iaSAsl0txI2Asdud5Yk4A4pgzv4l9ST6JZSXbyyprWpw+FFa5G21gz5icfzH3pgwCSQlh688+tUEwjjngZ7UHAHuWAHpn+1AXj5frQWXOGBZcKSe3c/rQIyAtnI27eBj/ADQIMAuH8vHBB9DQwVpPLjOckEZ/ahi9/Czqj/S9VhtLm6aG1uZFUsT5VOfX5Gpg9GiNJArxsrxsv1BHypYGF7pljeG3kvLZSlqzNGGxhSRjP6GoG1yLUWiWc2nSPA4KJGItyYHYHHarop3wu0jWYNUvzriNBp8ErraRMANxJ/N7nA7ZqDUHgSQLvAbacjI7H3oOuIFuYzGS68jJRyp4+lA0m0yDwGjiTw3bzBwTuDe+TQVbV+mLmW1NtbSok9weZiC2zPLEZ+/FBM6Xo40/TYdL8Jr21G4vJcuCck55HbFWUKQ/h4tR/DTz2o8TK21qmMgKOf8AfpmrokljG1i5BHI57D5VNorut9Lab1LA638W6H8sboNrqQckq3pntV0RWsfD6K7SGC3vTFahQJY2iVmkI9d+Mimie0Hp2DQ7AQacio3JZgqjcT3zxk1KHGldPWtnqMupS5uNTmGGnk5KjGNqf0r8qgmkhVGcquGblm96BDUZZYLGVrdN8+MIvux7UGKTdXdbaRrFvbaxbWN4d58BmwCjHPORycLx2q4LNe9S9TdN6I13qkWmzSXdwBCGlO4hiMKAB2A9ag0WySQwpLLtMjDcQBhVz6CgoHxF17XbnUYunulgsUsu4TTvjIUAEhR+x4qwZwtkOi7651PXJobm4tohHbQhdgecjnaPZeOfeqMy1vWLvWNQlvb+ZpJpWyT2A9gB6Cgjy5AO4A5oAGRgBR39aA7Z8MkFtxPY0AbV9UGfpQWhj5TkBQGxuBoEGG1iQCyHvj1oELgSkK6oRnIBIxzRdJ28Q3+fHiAds96LoH3AF1wCfyijNbF8JviI1rbQ6Pq/iSopxFOx5Uf0n3qUbWQk8II2SRyDPuCDUHMpSIiJQSBwDwKAgTxApnEbyIQ+APyn0+9A5B3AgfmoEWgcb3VlMpGFYjt+negSs7zxH/C3RWO9UElM8SAHG5fl/agNdXcEbJAZ1WadvDQDJO7Gf7c0ED1dqWv2enzw6Rb24nZfJd3EwREHqxyMZHzOKBbT7H8PZWTK5uZ9o3Xm1SzEry5PsT7UFF+JnUezSZ9LttRs2km2m5KSFWXDZI491AyBzVwK6J8T7CRtPjee0tbaGAtdNISdoXgLEo5JJxyfSmC6aF1fo2vELZXDJOxwkMybHYe4HtUFiJWJd8rKqjuTQcZV8SNI0dy43BlGVA+ZoBniE0RU7tp77Tg5zQUv4hNrU2tdNWOhylPEnaS5UHGYlAzn5cn74oHGt6l0z07k6nJC123HhKPFlbPptGTj9q0Kx0XMvU+ty6vqQtpWlZo4LOdGDWsak8Aflycgk+v2qC8a1q8OnaXLPOz2kCIWkZ+CqjgYx6n0xTBkmp9Sabp0KdRyI5vJkaGw08MVKIDw8jA557896QY1q2o3eqXr3N7O8skjnlnzgn5e1UMCGV/MOM0BJFOVwfX0oFtgZTjkg8UBtpOeO1B3hg85FBZXVMM+VJAA2+h96BO4IMJ/p7qvuKBKacmOKB5CYYx5UzgDPfHzoGwD5OApJHAHrQEAk8NWdNpx+XdkA0AIGhkGWOQcgg8UGw/DP4kmwhi07WCTZqAiSbstGc4+pFKNvs5o7q2Sa3kWaJxkOp4NZDOHUh/qL2k8LW78eG7kbZv+0+/yoEZp7fUpX/BXpgvYZTCSRtO7vtwe/vQdY6jeyatPp91FEPw8aSNMoYbi2cADt6Z70DS60KW7luJdV1JniJzBtURG2b0KN7+/vQKSWUWnLLqN3cSLP4ex5Y8jxiPykr23+nzzigpXUPVOu6Vqmmf8UWttb9OXDqkjRnfI3H849uRkDOKC0axLFr+nLB0rrUMM0bqCIGGGX1AH09qsGc9UfBiTV9Vhu9Pu5oPGLNeG6bczN7jHvVEr058Gre3sLeDVrmOdo3LmSFNjEH+XdntQXO51XQOl5YrCKGWa8SMYS3tzMyLjjJHb9alDqz1S5ktJ7nVdLmSVDiOONfEMiE4Xy+h9xUDm11CaTxEOn3VmpHFxKFCr9s5GPmKAus6jb9M6RJf3c88yxpjcxL7uM5OO3HrQVTSupoOuYdZMTSpptriNFtXKXDA/Pjhs9h2xQOJ7Xpnpa2S91WK2swqjbGw3ysfcnuxrQsGmapYvpwvra1FtDL52Mi+Gx49sZoMb+LXV0t+jWl3OYLGTO2zjx4h2nyszHsG4/Sgxt5ZJmEsjl3PB3GgSlyXBxkDnNADseB2PsaA8SoXQyFgmQCV70B5R/EIjYmPJxnvigEKcYDfrQF2/X9aCwqC7l2zwfT/FAJJ5747E5oGTqZArKOfccftQHZWwmOD23Z4NAEkTEBmwR7g5AoG7KSSE5HyFAMTyQsMHa/cEcEc5oL58P+v7rppdryPNAXx+GfsQe7Z9D2/Wg3zSdX0fqzT08F433eYwscOpHt9PcVkQPW632mX9vfWdrbXiRgrIdu2eHIwGD57+nIoKdc/ELVdC0u5afp27SUtta5vJMMzk+UDjzYHtQWDpj4gxXmif/wAitXZkGZzFGW8MehZO+PmM0Fibr/poWQmF6xXA2xmFg59sKRk0C2nQP1KFvdb0vwIUJNtDKcsVP8zD0Jx2oJDTNA0vR5p7qzs44pJOXkUc/SgNfa/pNvbF5L2JgTsCo2WJzjGKA1jcNcxOF/m/I0zbt4+gxgenNA5s7CCxWWYQxpNLgyMiY3nt2oHajcuexAoEL1C1uyFkVHO1ixHb17/KgwT4rdXWep6oul2OpywaTYqVLxDyySDjaM9x6Z+tWDPdB1TW7Wa9sumpGlursqMQRlpXwd3BA4571RcdN0i41G7h/wBSmNxqdkwn1O6u5/4cAXlYgcnngE/pQNvih8S211obHRyYbWInfJG/Ex9MD2+tBmNzcTXTtJcSSSSHH5jngDAH0oEdxbg5A9wKAzPwO+fegSLfLJoFoR5fUfegXOcHGAT8qAM+XaBzQCCwGDuyPlQWJpV37Q5TIweM7u/f9qA9vNYpFML2KaR8YiaJgAh55PvQRvnYoqA+MThcDnPai4PKWQlH3K6tggjnPaiEmz4ZznBPfFAVWG0AZDH1z2HzoE7lhv8AJIHI/mGRQI8AEeuOMGgndN6pu7V4RJLKY4WDLhypXj0oNL6d+MMS4ttetDdQgDNwAPEwPRh2NZGkabrvTXVZiexvba5aI+ILWZQG3Y4IDdvtQScvTdjK8chtFjkQ+VlYgqPXGKA17daV07apJrV9CsZbELTgbu3YY78UEHf9evJ4K9P6JqGoiR1XxjCUjAJ5OT3NBM9YdSWPTenwy3t7bWbSuBunUthfUhRyT+1BA2vXnS/jGdeo9LnIHljeLwSCe5zgmgejrOz1S3kGhazoaXYGAJ5Sw3e38uaCsJfX02rPD1XfXtvcCXdBJGjLbOO+EK88Y7nIoLB1H1Bb6WkN1ddSQ29io/5MZEjzt7DGTjj2FXNGUfEH4wRaxCtnp2kwGGM7llvBvIOO4XOAe/fNMwZbqusalfLBHfzSvFH+SIgKo+igYqiwWfWV30rpp03p6exJnUPJexQnxuR+Ulu2PkKCrT6jcSiTxZnbxCWcFidxPJJ96BBDlQ35fbFAbahBHJIGO+KAIwg5YnB455oDkKcbW7UAOowSMjOORQcCVXPp+9AqDkHcDmgMNpHPcUBTuzQWCJXcFvKR2Y0CMiqjnz4UcH/6oG8gKluwxyAfSjQ6ylEJBJfv37/OiYQMjbjkZXOSP/FEELAEkNn1waBCXdjORnPoc80CZeTb5wQe2BQAm4y7jlhjvQcWO3cW4GB7ZpgGC5a3uUeNyGQ5GCR+45pgt+l/EzqLTgxj1O5Zc4CSOXCj70wOE+Jd/Pq0V7qVvb3bISAWUBhnuc+/2pgvkHx0soLaNIdKkEiqR5yDg47cYpgresfELSNc1n8VrFtAw2ZBiiywwcgeb14x2xTBYNA13ozUo/GOqWVizDc1nf6crIh/7wOf1rOURvVupdE6ncpFeakiSWsZdbjSLfw1Zs+VVyMHA75xWsFDHU0idTJdf65rT28YKpPvHjKp9Bk49qYK/rGpXF/qU9zPdyzyyMSJJAAx9ifnVlwNZ7vxYEh8GAEHO8DDH5H5U0IPK8jHxSzFQAMnOKgJkFwPT6UBlAII5z3zQCjnA5OKBXeuAT9KABMA208DtxQHRhzgUC3KjJx9z2oAP6/L3NAHC8Hg/XNAcNtGe4oEy5yeaCdLk7yx2qQCAO1AmXZSSexHbPNAhJuLJkgjvzRonuAJy2cd8UCbyOi453Dj7GiYTZyVPPl74oYLJIyq68EH3Gf3oYTDEjLbiP1FEDHOUOdgOfXIBFAm77j5Mnng/WgLI5UE8Eg9iO9AnuJbuQx5wOBQFRxuIbOc54PrQK28ws76F722EyI4d4HJUOPb35yKBm8oeQsi4BPbPb71RyYIHmPGRg00GRsbsHIPY0Bg52AEEseBUCQJyOPXtQDtcdvvjtQCQ/GBwKAuXU4PrQBvZE5IGeO1AffjBJ57UBvEO045HagFWAAzktQKIzBeMg0C5kz5mOG/WgMrDJJ7jmgEnIyOccYoA3cEMRj05oC7/wDeBQTduzEoNxwcZGaAJOWfPNAlISVOT60aIQfkj+amgJ3bnnigKeFGPQUCf/x0Smw4V8exogX/AOY3+/SgKxKxeU459KAgJOckntQJkkcgkGgAAFFz/XQEmJaY7jnk96BM9yPQelAf/wCX7UBv/jagGP8AKB6ZoDf00HMfO/0oAH5TQA/5moECSMDPFAvGASMjPP8AigVX+b60BW7/AHoHEJJD55oDd4snv70CsSjCcDmgVAAbgYoGYJ3nk9qBUAYHAoP/2Q==
\ No newline at end of file diff --git a/tests/writer.html b/tests/writer.html index b0227e21b..e8e619f44 100644 --- a/tests/writer.html +++ b/tests/writer.html @@ -324,7 +324,6 @@ These should not be escaped: \$ \\ \> \[ \{
foo
-

And nested without indentation:

@@ -336,7 +335,6 @@ foo bar
-

Interpreted markdown in a table:

@@ -353,10 +351,8 @@ And this is strong

Here’s a simple block:

- foo
-

This should be a code block, though:

<div>
     foo
@@ -365,14 +361,12 @@ foo
 
<div>foo</div>

Now, nested:

-
-
- +
+
foo
-
- +

This should just be an HTML comment:

diff --git a/tests/writer.markdown b/tests/writer.markdown index 2201ac8d1..7d67e4e87 100644 --- a/tests/writer.markdown +++ b/tests/writer.markdown @@ -356,20 +356,31 @@ HTML Blocks Simple block on one line:
+ foo +
And nested without indentation:
+
+
+ foo +
+
+
+ bar +
+
Interpreted markdown in a table: @@ -390,8 +401,9 @@ And this is **strong** Here’s a simple block:
- + foo +
This should be a code block, though: @@ -407,12 +419,17 @@ As should this: Now, nested:
-
-
- + +
+ +
+ foo +
-
+ +
+
This should just be an HTML comment: diff --git a/tests/writer.mediawiki b/tests/writer.mediawiki index 7eccc44e8..2f3726285 100644 --- a/tests/writer.mediawiki +++ b/tests/writer.mediawiki @@ -311,22 +311,30 @@ Blank line after term, indented marker, alternate markers: Simple block on one line:
+ foo -
+
And nested without indentation:
+
+
+ foo +
+
+ bar -
+
+
Interpreted markdown in a table:
@@ -345,10 +353,10 @@ And this is '''strong''' Here’s a simple block:
- + foo -
+ This should be a code block, though:
<div>
@@ -360,14 +368,18 @@ As should this:
 Now, nested:
 
 
-
-
- + +
+ +
+ foo +
-
+
+
This should just be an HTML comment: diff --git a/tests/writer.native b/tests/writer.native index d1b14b24e..678d7595f 100644 --- a/tests/writer.native +++ b/tests/writer.native @@ -228,15 +228,9 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,[Plain [Str "sublist"]]]]])] ,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"] ,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"] -,RawBlock (Format "html") "
" -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n" +,Div ("",[],[]) [Plain [Str "foo"]] ,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"] -,RawBlock (Format "html") "
\n
\n
" -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n
\n
" -,Plain [Str "bar"] -,RawBlock (Format "html") "
\n
\n" +,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]] ,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"] ,RawBlock (Format "html") "
\n\n\n\n
" ,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]] @@ -244,17 +238,13 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]] ,RawBlock (Format "html") "
\n\n\n" ,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"] -,RawBlock (Format "html") "
\n " -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n" +,Div ("",[],[]) [Plain [Str "foo"]] ,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"] ,CodeBlock ("",[],[]) "
\n foo\n
" ,Para [Str "As",Space,Str "should",Space,Str "this:"] ,CodeBlock ("",[],[]) "
foo
" ,Para [Str "Now,",Space,Str "nested:"] -,RawBlock (Format "html") "
\n
\n
\n " -,Plain [Str "foo"] -,RawBlock (Format "html") "
\n
\n
\n" +,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]]] ,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"] ,RawBlock (Format "html") "\n" ,Para [Str "Multiline:"] diff --git a/tests/writer.opml b/tests/writer.opml index b0954a439..228cad247 100644 --- a/tests/writer.opml +++ b/tests/writer.opml @@ -44,7 +44,7 @@ - + diff --git a/tests/writer.org b/tests/writer.org index b8058a406..85016f352 100644 --- a/tests/writer.org +++ b/tests/writer.org @@ -359,7 +359,13 @@ And nested without indentation: #+BEGIN_HTML
+#+END_HTML + +#+BEGIN_HTML
+#+END_HTML + +#+BEGIN_HTML
#+END_HTML @@ -367,7 +373,13 @@ foo #+BEGIN_HTML
+#+END_HTML + +#+BEGIN_HTML
+#+END_HTML + +#+BEGIN_HTML
#+END_HTML @@ -375,6 +387,9 @@ bar #+BEGIN_HTML
+#+END_HTML + +#+BEGIN_HTML
#+END_HTML @@ -407,7 +422,6 @@ Here's a simple block: #+BEGIN_HTML
- #+END_HTML foo @@ -434,16 +448,27 @@ Now, nested: #+BEGIN_HTML
-
-
- +#+END_HTML + +#+BEGIN_HTML +
+#+END_HTML + +#+BEGIN_HTML +
#+END_HTML foo #+BEGIN_HTML
-
+#+END_HTML + +#+BEGIN_HTML +
+#+END_HTML + +#+BEGIN_HTML
#+END_HTML diff --git a/tests/writer.plain b/tests/writer.plain index cc61916d2..60e7bb329 100644 --- a/tests/writer.plain +++ b/tests/writer.plain @@ -352,10 +352,13 @@ HTML Blocks Simple block on one line: foo + And nested without indentation: foo + bar + Interpreted markdown in a table: This is emphasized @@ -363,6 +366,7 @@ And this is strong Here’s a simple block: foo + This should be a code block, though:
@@ -376,6 +380,7 @@ As should this: Now, nested: foo + This should just be an HTML comment: Multiline: diff --git a/tests/writer.rst b/tests/writer.rst index 41da5bc73..68bc4a06c 100644 --- a/tests/writer.rst +++ b/tests/writer.rst @@ -394,7 +394,13 @@ And nested without indentation: .. raw:: html
+ +.. raw:: html +
+ +.. raw:: html +
foo @@ -402,7 +408,13 @@ foo .. raw:: html
+ +.. raw:: html +
+ +.. raw:: html +
bar @@ -410,6 +422,9 @@ bar .. raw:: html
+ +.. raw:: html +
Interpreted markdown in a table: @@ -442,7 +457,6 @@ Here’s a simple block: .. raw:: html
- foo @@ -469,16 +483,27 @@ Now, nested: .. raw:: html
-
-
- + +.. raw:: html + +
+ +.. raw:: html + +
foo .. raw:: html
-
+ +.. raw:: html + +
+ +.. raw:: html +
This should just be an HTML comment: diff --git a/tests/writer.textile b/tests/writer.textile index 31789a2b0..5042f79cb 100644 --- a/tests/writer.textile +++ b/tests/writer.textile @@ -352,20 +352,33 @@ h1(#html-blocks). HTML Blocks Simple block on one line:
+ foo +
And nested without indentation:
+
+
+ foo +
+ +
+
+ bar +
+ +
Interpreted markdown in a table: @@ -386,8 +399,9 @@ And this is *strong* Here's a simple block:
- + foo +
This should be a code block, though: @@ -405,12 +419,19 @@ bc.
foo
Now, nested:
-
-
- + +
+ +
+ foo + +
+ +
-
+ +
This should just be an HTML comment: -- cgit v1.2.3 From e8ddcfd997bd1733b715a4321f0e57c7860071d2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 19 Aug 2013 16:03:22 -0700 Subject: Scale LaTeX tables so they don't exceed columnwidth. --- src/Text/Pandoc/Writers/LaTeX.hs | 6 +++- tests/tables.latex | 64 ++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 33 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 98553c421..ab579a326 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -470,9 +470,13 @@ tableRowToLaTeX header aligns widths cols = do AlignRight -> "\\raggedleft" AlignCenter -> "\\centering" AlignDefault -> "\\raggedright" + -- scale factor compensates for extra space between columns + -- so the whole table isn't larger than columnwidth + let scaleFactor = 0.97 ** fromIntegral (length aligns) let toCell 0 _ c = c toCell w a c = "\\begin{minipage}" <> valign <> - braces (text (printf "%.2f\\columnwidth" w)) <> + braces (text (printf "%.2f\\columnwidth" + (w * scaleFactor))) <> (halign a <> cr <> c <> cr) <> "\\end{minipage}" let cells = zipWith3 toCell widths aligns renderedCells return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}" diff --git a/tests/tables.latex b/tests/tables.latex index 82abeb9a5..c27e10461 100644 --- a/tests/tables.latex +++ b/tests/tables.latex @@ -54,34 +54,34 @@ Multiline table with caption: \begin{longtable}[c]{@{}clrl@{}} \hline\noalign{\medskip} -\begin{minipage}[b]{0.15\columnwidth}\centering +\begin{minipage}[b]{0.13\columnwidth}\centering Centered Header -\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright Left Aligned -\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft Right Aligned -\end{minipage} & \begin{minipage}[b]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright Default aligned \end{minipage} \\\noalign{\medskip} \hline\noalign{\medskip} -\begin{minipage}[t]{0.15\columnwidth}\centering +\begin{minipage}[t]{0.13\columnwidth}\centering First -\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright row -\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft 12.0 -\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Example of a row that spans multiple lines. \end{minipage} \\\noalign{\medskip} -\begin{minipage}[t]{0.15\columnwidth}\centering +\begin{minipage}[t]{0.13\columnwidth}\centering Second -\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright row -\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft 5.0 -\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Here's another one. Note the blank line between rows. \end{minipage} \\\noalign{\medskip} @@ -94,34 +94,34 @@ Multiline table without caption: \begin{longtable}[c]{@{}clrl@{}} \hline\noalign{\medskip} -\begin{minipage}[b]{0.15\columnwidth}\centering +\begin{minipage}[b]{0.13\columnwidth}\centering Centered Header -\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright Left Aligned -\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft Right Aligned -\end{minipage} & \begin{minipage}[b]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright Default aligned \end{minipage} \\\noalign{\medskip} \hline\noalign{\medskip} -\begin{minipage}[t]{0.15\columnwidth}\centering +\begin{minipage}[t]{0.13\columnwidth}\centering First -\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright row -\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft 12.0 -\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Example of a row that spans multiple lines. \end{minipage} \\\noalign{\medskip} -\begin{minipage}[t]{0.15\columnwidth}\centering +\begin{minipage}[t]{0.13\columnwidth}\centering Second -\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright row -\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft 5.0 -\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Here's another one. Note the blank line between rows. \end{minipage} \\\noalign{\medskip} @@ -145,23 +145,23 @@ Multiline table without column headers: \begin{longtable}[c]{@{}clrl@{}} \hline\noalign{\medskip} -\begin{minipage}[t]{0.15\columnwidth}\centering +\begin{minipage}[t]{0.13\columnwidth}\centering First -\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright row -\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft 12.0 -\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Example of a row that spans multiple lines. \end{minipage} \\\noalign{\medskip} -\begin{minipage}[t]{0.15\columnwidth}\centering +\begin{minipage}[t]{0.13\columnwidth}\centering Second -\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright row -\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft +\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft 5.0 -\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright +\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Here's another one. Note the blank line between rows. \end{minipage} \\\noalign{\medskip} -- cgit v1.2.3 From 7048c130ec9d128dd1c9d1ddf8e7ce3c15eaf435 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 18 Aug 2013 23:01:23 -0700 Subject: Create Cite element even if no matching reference in the biblio. * Add ??? as fallback text for non-resolved citations. * Biblio: Put references (including a header at the end of the document, if one exists) inside a Div with class "references". This gives some control over styling of references, and allows scripts to manipulate them. * Markdown writer: Print markdown citation codes, and disable printing of references, if `citations` extension is enabled. NOTE: It would be good to improve what citeproc-hs does for a nonexistent key. --- src/Text/Pandoc/Biblio.hs | 5 +- src/Text/Pandoc/Readers/Markdown.hs | 21 ++++---- src/Text/Pandoc/Writers/Markdown.hs | 35 +++++++------ tests/Tests/Old.hs | 2 +- tests/markdown-citations.chicago-author-date.txt | 10 +++- tests/markdown-citations.ieee.txt | 40 ++++++++------- tests/markdown-citations.mhra.txt | 62 ++++++++++++++---------- 7 files changed, 105 insertions(+), 70 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs index 206b38530..1c0975f11 100644 --- a/src/Text/Pandoc/Biblio.hs +++ b/src/Text/Pandoc/Biblio.hs @@ -55,7 +55,10 @@ processBiblio (Just style) r p = cits_map = M.fromList $ zip grps (citations result) biblioList = map (renderPandoc' style) (bibliography result) Pandoc m b = bottomUp mvPunct . deNote . topDown (processCite style cits_map) $ p' - in Pandoc m $ b ++ biblioList + (bs, lastb) = case reverse b of + x@(Header _ _ _) : xs -> (reverse xs, [x]) + _ -> (b, []) + in Pandoc m $ bs ++ [Div ("",["references"],[]) (lastb ++ biblioList)] -- | Substitute 'Cite' elements with formatted citations. processCite :: Style -> M.Map [Citation] [FormattedOutput] -> Inline -> Inline diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index a653c2e98..05662d9b5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -55,7 +55,6 @@ import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock ) import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag, isTextTag, isCommentTag ) import Text.Pandoc.Biblio (processBiblio) -import qualified Text.CSL as CSL import Data.Monoid (mconcat, mempty) import Control.Applicative ((<$>), (<*), (*>), (<$)) import Control.Monad @@ -1797,11 +1796,13 @@ rawHtmlInline = do cite :: MarkdownParser (F Inlines) cite = do guardEnabled Ext_citations - getOption readerReferences >>= guard . not . null - citations <- textualCite <|> normalCite - return $ flip B.cite mempty <$> citations + citations <- textualCite <|> (fmap (flip B.cite unknownC) <$> normalCite) + return citations + +unknownC :: Inlines +unknownC = B.str "???" -textualCite :: MarkdownParser (F [Citation]) +textualCite :: MarkdownParser (F Inlines) textualCite = try $ do (_, key) <- citeKey let first = Citation{ citationId = key @@ -1813,8 +1814,12 @@ textualCite = try $ do } mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite case mbrest of - Just rest -> return $ (first:) <$> rest - Nothing -> option (return [first]) $ bareloc first + Just rest -> return $ (flip B.cite unknownC . (first:)) <$> rest + Nothing -> (fmap (flip B.cite unknownC) <$> bareloc first) <|> + return (do st <- askF + return $ case M.lookup key (stateExamples st) of + Just n -> B.str (show n) + _ -> B.cite [first] unknownC) bareloc :: Citation -> MarkdownParser (F [Citation]) bareloc c = try $ do @@ -1846,8 +1851,6 @@ citeKey = try $ do let internal p = try $ p >>~ lookAhead (letter <|> digit) rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_+?<>~/") let key = first:rest - citations' <- map CSL.refId <$> getOption readerReferences - guard $ key `elem` citations' return (suppress_author, key) suffix :: MarkdownParser (F Inlines) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 623c445df..d617954dd 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -186,7 +186,12 @@ pandocToMarkdown opts (Pandoc meta blocks) = do let toc = if writerTableOfContents opts then tableOfContents opts headerBlocks else empty - body <- blockListToMarkdown opts blocks + -- Strip off final 'references' header if markdown citations enabled + let blocks' = case reverse blocks of + (Div (_,["references"],_) _):xs + | isEnabled Ext_citations opts -> reverse xs + _ -> blocks + body <- blockListToMarkdown opts blocks' st <- get notes' <- notesToMarkdown opts (reverse $ stNotes st) st' <- get -- note that the notes may contain refs @@ -304,10 +309,10 @@ blockToMarkdown _ Null = return empty blockToMarkdown opts (Div attrs ils) = do isPlain <- gets stPlain contents <- blockListToMarkdown opts ils - return $ if isPlain + return $ if isPlain || not (isEnabled Ext_markdown_in_html_blocks opts) then contents <> blankline else tagWithAttrs "div" attrs <> blankline <> - contents <> blankline <> "
" <> blankline + contents <> blankline <> "
" <> blankline blockToMarkdown opts (Plain inlines) = do contents <- inlineListToMarkdown opts inlines return $ contents <> cr @@ -711,17 +716,20 @@ inlineToMarkdown opts (LineBreak) | isEnabled Ext_escaped_line_breaks opts = return $ "\\" <> cr | otherwise = return $ " " <> cr inlineToMarkdown _ Space = return space -inlineToMarkdown opts (Cite (c:cs) lst@[RawInline "latex" _]) +inlineToMarkdown opts (Cite [] lst) = inlineListToMarkdown opts lst +inlineToMarkdown opts (Cite (c:cs) lst) | not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst - | citationMode c == AuthorInText = do - suffs <- inlineListToMarkdown opts $ citationSuffix c - rest <- mapM convertOne cs - let inbr = suffs <+> joincits rest - br = if isEmpty inbr then empty else char '[' <> inbr <> char ']' - return $ text ("@" ++ citationId c) <+> br - | otherwise = do - cits <- mapM convertOne (c:cs) - return $ text "[" <> joincits cits <> text "]" + | otherwise = + if citationMode c == AuthorInText + then do + suffs <- inlineListToMarkdown opts $ citationSuffix c + rest <- mapM convertOne cs + let inbr = suffs <+> joincits rest + br = if isEmpty inbr then empty else char '[' <> inbr <> char ']' + return $ text ("@" ++ citationId c) <+> br + else do + cits <- mapM convertOne (c:cs) + return $ text "[" <> joincits cits <> text "]" where joincits = hcat . intersperse (text "; ") . filter (not . isEmpty) convertOne Citation { citationId = k @@ -738,7 +746,6 @@ inlineToMarkdown opts (Cite (c:cs) lst@[RawInline "latex" _]) return $ pdoc <+> r modekey SuppressAuthor = "-" modekey _ = "" -inlineToMarkdown opts (Cite _ lst) = inlineListToMarkdown opts lst inlineToMarkdown opts (Link txt (src, tit)) = do linktext <- inlineListToMarkdown opts txt let linktitle = if null tit diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index 0ba240084..8609781d0 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -196,7 +196,7 @@ markdownCitationTests ++ [test "natbib" wopts "markdown-citations.txt" "markdown-citations.txt"] where - ropts = ["-r", "markdown", "-w", "markdown", "--bibliography", + ropts = ["-r", "markdown", "-w", "markdown-citations", "--bibliography", "biblio.bib", "--no-wrap"] wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"] styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"]) diff --git a/tests/markdown-citations.chicago-author-date.txt b/tests/markdown-citations.chicago-author-date.txt index de242300d..81d7482cb 100644 --- a/tests/markdown-citations.chicago-author-date.txt +++ b/tests/markdown-citations.chicago-author-date.txt @@ -1,9 +1,9 @@ Pandoc with citeproc-hs ======================= -- [@nonexistent] +- ([CSL BIBLIOGRAPHIC DATA ERROR: reference "nonexistent" not found.]) -- @nonexistent +- ([CSL BIBLIOGRAPHIC DATA ERROR: reference "nonexistent" not found.]) - Doe (2005) says blah. @@ -29,15 +29,21 @@ Pandoc with citeproc-hs - With some markup (*see* Doe 2005, 32). +
+ References ========== +“Nonexistent Not Found!” + Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press. ———. 2006. “Article.” *Journal of Generic Studies* 6: 33–34. Doe, John, and Jenny Roe. 2007. “Why Water Is Wet.” In *Third Book*, edited by Sam Smith. Oxford: Oxford University Press. +
+ [^1]: Doe and Roe (2007, 12) and a citation without locators (Doe and Roe 2007). [^2]: Some citations (see Doe 2005, chap. 3; Doe and Roe 2007; Doe 2006). diff --git a/tests/markdown-citations.ieee.txt b/tests/markdown-citations.ieee.txt index a397e3f38..4085a7c63 100644 --- a/tests/markdown-citations.ieee.txt +++ b/tests/markdown-citations.ieee.txt @@ -1,45 +1,51 @@ Pandoc with citeproc-hs ======================= -- [@nonexistent] +- [] -- @nonexistent +- -- Reference 1 says blah. +- Reference 2 says blah. -- Reference 1 says blah. +- Reference 2 says blah. -- Reference 1 says blah. +- Reference 2 says blah. -- Reference 1 [3] says blah. +- Reference 2 [4] says blah. - In a note.[^1] -- A citation group [1], [3]. +- A citation group [2], [4]. -- Another one [1]. +- Another one [2]. - And another one in a note.[^2] -- Citation with a suffix and locator [1]. +- Citation with a suffix and locator [2]. -- Citation with suffix only [1]. +- Citation with suffix only [2]. - Now some modifiers.[^3] -- With some markup [1]. +- With some markup [2]. + +
References ========== -[1] J. Doe, *First Book*. Cambridge: Cambridge University Press, 2005. +[1]“nonexistent not found!” . + +[2] J. Doe, *First Book*. Cambridge: Cambridge University Press, 2005. + +[3] J. Doe, “Article,” *Journal of Generic Studies*, vol. 6, pp. 33–34, 2006. -[2] J. Doe, “Article,” *Journal of Generic Studies*, vol. 6, pp. 33–34, 2006. +[4] J. Doe and J. Roe, “Why Water Is Wet,” in *Third Book*, S. Smith, Ed. Oxford: Oxford University Press, 2007. -[3] J. Doe and J. Roe, “Why Water Is Wet,” in *Third Book*, S. Smith, Ed. Oxford: Oxford University Press, 2007. +
-[^1]: Reference 3 and a citation without locators [3]. +[^1]: Reference 4 and a citation without locators [4]. -[^2]: Some citations [1–3]. +[^2]: Some citations [2–4]. -[^3]: Like a citation without author: [1], and now Doe with a locator [2]. +[^3]: Like a citation without author: [2], and now Doe with a locator [3]. diff --git a/tests/markdown-citations.mhra.txt b/tests/markdown-citations.mhra.txt index d33a1b94b..01d9c45ca 100644 --- a/tests/markdown-citations.mhra.txt +++ b/tests/markdown-citations.mhra.txt @@ -1,33 +1,35 @@ Pandoc with citeproc-hs ======================= -- [@nonexistent] +- [^1] -- @nonexistent +- [^2] -- John Doe[^1] says blah. +- John Doe[^3] says blah. -- Doe[^2] says blah. +- Doe[^4] says blah. -- Doe[^3] says blah. +- Doe[^5] says blah. -- Doe[^4] says blah. +- Doe[^6] says blah. -- In a note.[^5] +- In a note.[^7] -- A citation group.[^6] +- A citation group.[^8] -- Another one.[^7] +- Another one.[^9] -- And another one in a note.[^8] +- And another one in a note.[^10] -- Citation with a suffix and locator.[^9] +- Citation with a suffix and locator.[^11] -- Citation with suffix only.[^10] +- Citation with suffix only.[^12] -- Now some modifiers.[^11] +- Now some modifiers.[^13] -- With some markup.[^12] +- With some markup.[^14] + +
References ========== @@ -38,26 +40,34 @@ Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33–34. Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed. by Sam Smith (Oxford: Oxford University Press, 2007). -[^1]: *First Book* (Cambridge: Cambridge University Press, 2005). +‘Nonexistent Not Found!’. + +
+ +[^1]: [CSL BIBLIOGRAPHIC DATA ERROR: reference "nonexistent" not found.]. + +[^2]: [CSL STYLE ERROR: reference with no printed form.]. + +[^3]: *First Book* (Cambridge: Cambridge University Press, 2005). -[^2]: *First Book*, p. 30. +[^4]: *First Book*, p. 30. -[^3]: *First Book*, p. 30, with suffix. +[^5]: *First Book*, p. 30, with suffix. -[^4]: *First Book*; ‘Article’, *Journal of Generic Studies*, 6 (2006), 33–34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed. by Sam Smith (Oxford: Oxford University Press, 2007). +[^6]: *First Book*; ‘Article’, *Journal of Generic Studies*, 6 (2006), 33–34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed. by Sam Smith (Oxford: Oxford University Press, 2007). -[^5]: Doe and Roe, p. 12 and a citation without locators Doe and Roe. +[^7]: Doe and Roe, p. 12 and a citation without locators Doe and Roe. -[^6]: See Doe, *First Book*, chap. 3; also Doe and Roe, pp. 34–35. +[^8]: See Doe, *First Book*, chap. 3; also Doe and Roe, pp. 34–35. -[^7]: See Doe, *First Book*, pp. 34–35. +[^9]: See Doe, *First Book*, pp. 34–35. -[^8]: Some citations see Doe, *First Book*, chap. 3; Doe and Roe; Doe, ‘Article’, 33–34. +[^10]: Some citations see Doe, *First Book*, chap. 3; Doe and Roe; Doe, ‘Article’, 33–34. -[^9]: Doe, *First Book*, pp. 33, 35–37, and nowhere else. +[^11]: Doe, *First Book*, pp. 33, 35–37, and nowhere else. -[^10]: Doe, *First Book* and nowhere else. +[^12]: Doe, *First Book* and nowhere else. -[^11]: Like a citation without author: *First Book*, and now Doe with a locator ‘Article’, 33–34 (p. 44). +[^13]: Like a citation without author: *First Book*, and now Doe with a locator ‘Article’, 33–34 (p. 44). -[^12]: *See* Doe, *First Book*, p. 32. +[^14]: *See* Doe, *First Book*, p. 32. -- cgit v1.2.3 From 5f09cf7ff033ae11c5094fe39f8cd2ac11657229 Mon Sep 17 00:00:00 2001 From: Florian Eitel Date: Thu, 22 Aug 2013 20:15:36 +0200 Subject: Write id for code block to label attr in latex when listing is used The code: ~~~{#test} asdf ~~~ gets compiled to html:
    asdf
    
So it is possible to link to the identifier `test` But this doesn't happen on latex When using the listings package (`--listings`) it is possible to set the identifier using the `label=test` property: \begin{lstlisting}[label=id] hi \end{lstlisting} And this is exactly what this patch is doing. Modified LaTeX Reader/Writer and added tests for this. --- src/Text/Pandoc/Readers/LaTeX.hs | 3 ++- src/Text/Pandoc/Writers/LaTeX.hs | 8 ++++++-- tests/Tests/Readers/LaTeX.hs | 7 +++++++ tests/Tests/Writers/LaTeX.hs | 7 +++++++ 4 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index ded57df5a..b785a9852 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -47,6 +47,7 @@ import Text.Pandoc.Builder import Data.Char (isLetter) import Control.Applicative import Data.Monoid +import Data.Maybe (fromMaybe) import System.Environment (getEnv) import System.FilePath (replaceExtension, ()) import Data.List (intercalate, intersperse) @@ -901,7 +902,7 @@ environments = M.fromList lookup "numbers" options == Just "left" ] ++ maybe [] (:[]) (lookup "language" options >>= fromListingsLanguage) - let attr = ("",classes,kvs) + let attr = (fromMaybe "" (lookup "label" options),classes,kvs) codeBlockWith attr <$> (verbEnv "lstlisting")) , ("minted", do options <- option [] keyvals lang <- grouped (many1 $ satisfy (/='}')) diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ab579a326..bf056001f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -313,7 +313,7 @@ blockToLaTeX (BlockQuote lst) = do _ -> do contents <- blockListToLaTeX lst return $ "\\begin{quote}" $$ contents $$ "\\end{quote}" -blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do +blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do opts <- gets stOptions case () of _ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes && @@ -344,7 +344,11 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do [ (if key == "startFrom" then "firstnumber" else key) ++ "=" ++ attr | - (key,attr) <- keyvalAttr ] + (key,attr) <- keyvalAttr ] ++ + (if identifier == "" + then [] + else [ "label=" ++ identifier ]) + else [] printParams | null params = empty diff --git a/tests/Tests/Readers/LaTeX.hs b/tests/Tests/Readers/LaTeX.hs index 88029b7c2..dff6e4537 100644 --- a/tests/Tests/Readers/LaTeX.hs +++ b/tests/Tests/Readers/LaTeX.hs @@ -55,6 +55,13 @@ tests = [ testGroup "basic" "hi % this is a comment\nthere\n" =?> para "hi there" ] + , testGroup "code blocks" + [ "identifier" =: + "\\begin{lstlisting}[label=test]\\end{lstlisting}" =?> codeBlockWith ("test", [], [("label","test")]) "" + , "no identifier" =: + "\\begin{lstlisting}\\end{lstlisting}" =?> codeBlock "" + ] + , testGroup "citations" [ natbibCitations , biblatexCitations diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index ebde5b97c..5f702a85d 100644 --- a/tests/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs @@ -10,6 +10,9 @@ import Tests.Arbitrary() latex :: (ToString a, ToPandoc a) => a -> String latex = writeLaTeX def . toPandoc +latexListing :: (ToString a, ToPandoc a) => a -> String +latexListing = writeLaTeX def{ writerListings = True } . toPandoc + {- "my test" =: X =?> Y @@ -31,6 +34,10 @@ tests :: [Test] tests = [ testGroup "code blocks" [ "in footnotes" =: note (para "hi" <> codeBlock "hi") =?> "\\footnote{hi\n\n\\begin{Verbatim}\nhi\n\\end{Verbatim}\n}" + , test latexListing "identifier" $ codeBlockWith ("id",[],[]) "hi" =?> + ("\\begin{lstlisting}[label=id]\nhi\n\\end{lstlisting}" :: String) + , test latexListing "no identifier" $ codeBlock "hi" =?> + ("\\begin{lstlisting}\nhi\n\\end{lstlisting}" :: String) ] , testGroup "math" [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?> -- cgit v1.2.3 From deb59b62354e38df9c85ce6985e5c28dd2301ee7 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 24 Aug 2013 22:27:08 -0700 Subject: Removed dependency on citeproc-hs. Going forward we'll use pandoc-citeproc, as an external filter. The `--bibliography`, `--csl`, and `--citation-abbreviation` fields have been removed. Instead one must include `bibliography`, `csl`, or `csl-abbrevs` fields in the document's YAML metadata. The filter can then be used as follows: pandoc --filter pandoc-citeproc The `Text.Pandoc.Biblio` module has been removed. Henceforth, `Text.CSL.Pandoc` from pandoc-citations can be used by library users. The Markdown and LaTeX readers now longer format bibliographies and citations. That must be done using `processCites` or `processCites'` from Text.CSL.Pandoc. All bibliography-related fields have been removed from `ReaderOptions` and `WriterOptions`: `writerBiblioFiles`, `readerReferences`, `readerCitationStyle`. API change. --- README | 105 ++++----- data/default.csl | 458 ------------------------------------ pandoc.cabal | 7 +- pandoc.hs | 68 +----- src/Text/Pandoc/Biblio.hs | 216 ----------------- src/Text/Pandoc/Options.hs | 7 - src/Text/Pandoc/Readers/LaTeX.hs | 5 +- src/Text/Pandoc/Readers/Markdown.hs | 5 +- src/Text/Pandoc/Writers/LaTeX.hs | 8 +- tests/Tests/Old.hs | 14 -- 10 files changed, 50 insertions(+), 843 deletions(-) delete mode 100644 data/default.csl delete mode 100644 src/Text/Pandoc/Biblio.hs (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 7a2b01f49..f85e62e14 100644 --- a/README +++ b/README @@ -598,54 +598,6 @@ Options affecting specific writers Citation rendering ------------------ -`--bibliography=`*FILE* -: Specify bibliography database to be used in resolving - citations. The database type will be determined from the - extension of *FILE*, which may be `.mods` (MODS format), - `.bib` (BibLaTeX format, which will normally work for BibTeX - files as well), `.bibtex` (BibTeX format), - `.ris` (RIS format), `.enl` (EndNote format), - `.xml` (EndNote XML format), `.wos` (ISI format), - `.medline` (MEDLINE format), `.copac` (Copac format), - or `.json` (citeproc JSON). If you want to use multiple - bibliographies, just use this option repeatedly. - -`--csl=`*FILE* -: Specify [CSL] style to be used in formatting citations and - the bibliography. If *FILE* is not found, pandoc will look - for it in - - $HOME/.csl - - in unix, - - C:\Documents And Settings\USERNAME\Application Data\csl - - in Windows XP, and - - C:\Users\USERNAME\AppData\Roaming\csl - - in Windows 7. If the `--csl` option is not specified, pandoc - will use a default style: either `default.csl` in the - user data directory (see `--data-dir`), or, if that is - not present, the Chicago author-date style. - -`--citation-abbreviations=`*FILE* -: Specify a file containing abbreviations for journal titles and - other bibliographic fields (indicated by setting `form="short"` - in the CSL node for the field). The format is described at - . - Here is a short example: - - { "default": { - "container-title": { - "Lloyd's Law Reports": "Lloyd's Rep", - "Estates Gazette": "EG", - "Scots Law Times": "SLT" - } - } - } - `--natbib` : Use natbib for citations in LaTeX output. @@ -2378,9 +2330,14 @@ Citations **Extension: `citations`** -Pandoc can automatically generate citations and a bibliography in a number of -styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature, -you will need a bibliographic database in one of the following formats: +Using an external filter, `pandoc-citeproc`, pandoc can automatically generate +citations and a bibliography in a number of styles. Basic usage is + + pandoc --filter pandoc-citeproc myinput.txt + +In order to use this feature, you will need to specify a bibliography file +using the `bibliography` metadata field in a YAML metadata section. +The bibliography may have any of these formats: Format File extension ------------ -------------- @@ -2398,18 +2355,40 @@ you will need a bibliographic database in one of the following formats: Note that `.bib` can generally be used with both BibTeX and BibLaTeX files, but you can use `.bibtex` to force BibTeX. -You will need to specify the bibliography file using the `--bibliography` -command-line option (which may be repeated if you have several -bibliographies). - -By default, pandoc will use a Chicago author-date format for citations -and references. To use another style, you will need to use the -`--csl` option to specify a [CSL] 1.0 style file. A primer on -creating and modifying CSL styles can be found at -. -A repository of CSL styles can be found at -. -See also for easy browsing. +Alternatively you can use a `references` field in the document's YAML +metadata. This should include an array of YAML-encoded references, +for example: + + --- + references: + - id: fenner2012a + title: One-click science marketing + author: + - family: Fenner + given: Martin + container-title: Nature Materials + volume: 11 + URL: 'http://dx.doi.org/10.1038/nmat3283' + DOI: 10.1038/nmat3283 + issue: 4 + publisher: Nature Publishing Group + page: 261-263 + type: article-journal + issued: + year: 2012 + month: 3 + ... + +(The program `mods2yaml`, which comes with `pandoc-citeproc`, can help produce +these from a MODS reference collection.) + +By default, `pandoc-citeproc` will use a Chicago author-date format for +citations and references. To use another style, you will need to specify +a [CSL] 1.0 style file in the `csl` metadata field. A primer on creating and +modifying CSL styles can be found at +. A repository of CSL styles +can be found at . See also + for easy browsing. Citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of '@' + the citation diff --git a/data/default.csl b/data/default.csl deleted file mode 100644 index 83a70d0b5..000000000 --- a/data/default.csl +++ /dev/null @@ -1,458 +0,0 @@ - - diff --git a/pandoc.cabal b/pandoc.cabal index ac28ad068..0ab990a17 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -99,8 +99,6 @@ Data-Files: data/slideous/slideous.js, -- data for dzslides writer data/dzslides/template.html, - -- data for citeproc - data/default.csl, -- sample lua custom writer data/sample.lua -- documentation @@ -250,7 +248,6 @@ Library xml >= 1.3.12 && < 1.4, random >= 1 && < 1.1, extensible-exceptions >= 0.1 && < 0.2, - citeproc-hs >= 0.3.7 && < 0.4, pandoc-types >= 1.12 && < 1.13, aeson >= 0.6 && < 0.7, tagsoup >= 0.12.5 && < 0.14, @@ -323,7 +320,6 @@ Library Text.Pandoc.UTF8, Text.Pandoc.Templates, Text.Pandoc.XML, - Text.Pandoc.Biblio, Text.Pandoc.SelfContained, Text.Pandoc.Process Other-Modules: Text.Pandoc.Readers.Haddock.Lex, @@ -353,8 +349,7 @@ Executable pandoc extensible-exceptions >= 0.1 && < 0.2, highlighting-kate >= 0.5.5 && < 0.6, aeson >= 0.6 && < 0.7, - HTTP >= 4000.0.5 && < 4000.3, - citeproc-hs >= 0.3.7 && < 0.4 + HTTP >= 4000.0.5 && < 4000.3 Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind Ghc-Prof-Options: -auto-all -caf-all -rtsopts -with-rtsopts=-K16m if os(windows) diff --git a/pandoc.hs b/pandoc.hs index 8eed67544..6ad5694f1 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -35,7 +35,7 @@ import Text.Pandoc.PDF (makePDF) import Text.Pandoc.Readers.LaTeX (handleIncludes) import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile, safeRead, headerShift, normalize, err, warn ) -import Text.Pandoc.XML ( toEntities, fromEntities ) +import Text.Pandoc.XML ( toEntities ) import Text.Pandoc.SelfContained ( makeSelfContained ) import Text.Pandoc.Process (pipeProcess) import Text.Highlighting.Kate ( languages, Style, tango, pygments, @@ -46,20 +46,18 @@ import System.FilePath import System.Console.GetOpt import Data.Char ( toLower ) import Data.List ( intercalate, isPrefixOf, sort ) -import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable ) +import System.Directory ( getAppUserDataDirectory, findExecutable ) import System.IO ( stdout, stderr ) import System.IO.Error ( isDoesNotExistError ) import qualified Control.Exception as E import Control.Exception.Extensible ( throwIO ) import qualified Text.Pandoc.UTF8 as UTF8 -import qualified Text.CSL as CSL import Control.Monad (when, unless, liftM) import Data.Foldable (foldrM) import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..)) import Network.URI (parseURI, isURI, URI(..)) import qualified Data.ByteString.Lazy as B import qualified Data.ByteString as BS -import Text.CSL.Reference (Reference(..)) import Data.Aeson (eitherDecode', encode) copyrightMessage :: String @@ -70,7 +68,7 @@ copyrightMessage = "\nCopyright (C) 2006-2013 John MacFarlane\n" ++ compileInfo :: String compileInfo = - "\nCompiled with citeproc-hs " ++ VERSION_citeproc_hs ++ ", texmath " ++ + "\nCompiled with texmath " ++ VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate ++ ".\nSyntax highlighting is supported for the following languages:\n " ++ wrapWords 4 78 @@ -146,9 +144,6 @@ data Opt = Opt , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks , optDataDir :: Maybe FilePath , optCiteMethod :: CiteMethod -- ^ Method to output cites - , optBibliography :: [String] - , optCslFile :: Maybe FilePath - , optAbbrevsFile :: Maybe FilePath , optListings :: Bool -- ^ Use listings package for code blocks , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf , optSlideLevel :: Maybe Int -- ^ Header level that creates slides @@ -203,9 +198,6 @@ defaultOpts = Opt , optIndentedCodeClasses = [] , optDataDir = Nothing , optCiteMethod = Citeproc - , optBibliography = [] - , optCslFile = Nothing - , optAbbrevsFile = Nothing , optListings = False , optLaTeXEngine = "pdflatex" , optSlideLevel = Nothing @@ -650,24 +642,6 @@ options = "PROGRAM") "" -- "Name of latex program to use in generating PDF" - , Option "" ["bibliography"] - (ReqArg - (\arg opt -> return opt { optBibliography = (optBibliography opt) ++ [arg] }) - "FILENAME") - "" - - , Option "" ["csl"] - (ReqArg - (\arg opt -> return opt { optCslFile = Just arg }) - "FILENAME") - "" - - , Option "" ["citation-abbreviations"] - (ReqArg - (\arg opt -> return opt { optAbbrevsFile = Just arg }) - "FILENAME") - "" - , Option "" ["natbib"] (NoArg (\opt -> return opt { optCiteMethod = Natbib })) @@ -904,9 +878,6 @@ main = do , optIdentifierPrefix = idPrefix , optIndentedCodeClasses = codeBlockClasses , optDataDir = mbDataDir - , optBibliography = reffiles - , optCslFile = mbCsl - , optAbbrevsFile = cslabbrevs , optCiteMethod = citeMethod , optListings = listings , optLaTeXEngine = latexEngine @@ -1007,36 +978,6 @@ main = do $ lines dztempl return $ ("dzslides-core", dzcore) : variables' else return variables' - - -- unescape reference ids, which may contain XML entities, so - -- that we can do lookups with regular string equality - let unescapeRefId ref = ref{ refId = fromEntities (refId ref) } - - refs <- mapM (\f -> E.catch (CSL.readBiblioFile f) - (\e -> let _ = (e :: E.SomeException) - in err 23 $ "Error reading bibliography `" ++ f ++ - "'" ++ "\n" ++ show e)) - reffiles >>= - return . map unescapeRefId . concat - - mbsty <- if citeMethod == Citeproc && not (null refs) - then do - csl <- CSL.parseCSL =<< - case mbCsl of - Nothing -> readDataFileUTF8 datadir - "default.csl" - Just cslfile -> do - exists <- doesFileExist cslfile - if exists - then UTF8.readFile cslfile - else do - csldir <- getAppUserDataDirectory "csl" - readDataFileUTF8 (Just csldir) - (replaceExtension cslfile "csl") - abbrevs <- maybe (return []) CSL.readJsonAbbrevFile cslabbrevs - return $ Just csl { CSL.styleAbbrevs = abbrevs } - else return Nothing - let sourceURL = case sources of [] -> Nothing (x:_) -> case parseURI x of @@ -1054,8 +995,6 @@ main = do , readerColumns = columns , readerTabStop = tabStop , readerOldDashes = oldDashes - , readerReferences = refs - , readerCitationStyle = mbsty , readerIndentedCodeClasses = codeBlockClasses , readerApplyMacros = not laTeXOutput , readerDefaultImageExtension = defaultImageExtension @@ -1069,7 +1008,6 @@ main = do writerHTMLMathMethod = mathMethod, writerIncremental = incremental, writerCiteMethod = citeMethod, - writerBiblioFiles = reffiles, writerIgnoreNotes = False, writerNumberSections = numberSections, writerNumberOffset = numberFrom, diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs deleted file mode 100644 index 1c0975f11..000000000 --- a/src/Text/Pandoc/Biblio.hs +++ /dev/null @@ -1,216 +0,0 @@ -{-# LANGUAGE PatternGuards #-} -{- -Copyright (C) 2008 Andrea Rossato - -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 -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --} - -{- | - Module : Text.Pandoc.Biblio - Copyright : Copyright (C) 2008-2010 Andrea Rossato - License : GNU GPL, version 2 or above - - Maintainer : Andrea Rossato - Stability : alpha - Portability : portable --} - -module Text.Pandoc.Biblio ( processBiblio ) where - -import Data.List -import Data.Char ( isDigit, isPunctuation ) -import qualified Data.Map as M -import Text.CSL hiding ( Cite(..), Citation(..), endWithPunct ) -import qualified Text.CSL as CSL ( Cite(..) ) -import Text.Pandoc.Definition -import Text.Pandoc.Generic -import Text.Pandoc.Walk -import Text.Pandoc.Shared (stringify) -import Text.Parsec hiding (State) -import Control.Monad -import Control.Monad.State - --- | Process a 'Pandoc' document by adding citations formatted --- according to a CSL style, using 'citeproc' from citeproc-hs. -processBiblio :: Maybe Style -> [Reference] -> Pandoc -> Pandoc -processBiblio Nothing _ p = p -processBiblio _ [] p = p -processBiblio (Just style) r p = - let p' = evalState (bottomUpM setHash p) 1 - grps = query getCitation p' - result = citeproc procOpts style r (setNearNote style $ - map (map toCslCite) grps) - cits_map = M.fromList $ zip grps (citations result) - biblioList = map (renderPandoc' style) (bibliography result) - Pandoc m b = bottomUp mvPunct . deNote . topDown (processCite style cits_map) $ p' - (bs, lastb) = case reverse b of - x@(Header _ _ _) : xs -> (reverse xs, [x]) - _ -> (b, []) - in Pandoc m $ bs ++ [Div ("",["references"],[]) (lastb ++ biblioList)] - --- | Substitute 'Cite' elements with formatted citations. -processCite :: Style -> M.Map [Citation] [FormattedOutput] -> Inline -> Inline -processCite s cs (Cite t _) = - case M.lookup t cs of - Just (x:xs) - | isTextualCitation t && not (null xs) -> - let xs' = renderPandoc s xs - in if styleClass s == "note" - then Cite t (renderPandoc s [x] ++ [Note [Para xs']]) - else Cite t (renderPandoc s [x] ++ [Space | not (startWithPunct xs')] ++ xs') - | otherwise -> if styleClass s == "note" - then Cite t [Note [Para $ renderPandoc s (x:xs)]] - else Cite t (renderPandoc s (x:xs)) - _ -> Strong [Str "???"] -- TODO raise error instead? -processCite _ _ x = x - -isNote :: Inline -> Bool -isNote (Note _) = True -isNote (Cite _ [Note _]) = True -isNote _ = False - -mvPunct :: [Inline] -> [Inline] -mvPunct (Space : Space : xs) = Space : xs -mvPunct (Space : x : ys) | isNote x, startWithPunct ys = - Str (headInline ys) : x : tailFirstInlineStr ys -mvPunct (Space : x : ys) | isNote x = x : ys -mvPunct xs = xs - --- A replacement for citeproc-hs's endWithPunct, which wrongly treats --- a sentence ending in '.)' as not ending with punctuation, leading --- to an extra period. -endWithPunct :: [Inline] -> Bool -endWithPunct [] = True -endWithPunct xs@(_:_) = case reverse (stringify [last xs]) of - [] -> True - (')':c:_) | isEndPunct c -> True - (c:_) | isEndPunct c -> True - | otherwise -> False - where isEndPunct c = c `elem` ".,;:!?" - -deNote :: Pandoc -> Pandoc -deNote = topDown go - where go (Cite (c:cs) [Note xs]) = - Cite (c:cs) [Note $ bottomUp go' $ sanitize c xs] - go (Note xs) = Note $ bottomUp go' xs - go x = x - go' (Note [Para xs]:ys) = - if startWithPunct ys && endWithPunct xs - then initInline xs ++ ys - else xs ++ ys - go' xs = xs - sanitize :: Citation -> [Block] -> [Block] - sanitize Citation{citationPrefix = pref} [Para xs] = - case (null pref, endWithPunct xs) of - (True, False) -> [Para $ xs ++ [Str "."]] - (True, True) -> [Para xs] - (False, False) -> [Para $ toCapital $ xs ++ [Str "."]] - (False, True) -> [Para $ toCapital xs] - sanitize _ bs = bs - -isTextualCitation :: [Citation] -> Bool -isTextualCitation (c:_) = citationMode c == AuthorInText -isTextualCitation _ = False - --- | Retrieve all citations from a 'Pandoc' docuument. To be used with --- 'query'. -getCitation :: Inline -> [[Citation]] -getCitation i | Cite t _ <- i = [t] - | otherwise = [] - -setHash :: Citation -> State Int Citation -setHash c = do - ident <- get - put $ ident + 1 - return c{ citationHash = ident } - -toCslCite :: Citation -> CSL.Cite -toCslCite c - = let (l, s) = locatorWords $ citationSuffix c - (la,lo) = parseLocator l - s' = case (l,s) of - -- treat a bare locator as if it begins with space - -- so @item1 [blah] is like [@item1, blah] - ("",(x:_)) - | not (isPunct x) -> [Space] ++ s - _ -> s - isPunct (Str (x:_)) = isPunctuation x - isPunct _ = False - citMode = case citationMode c of - AuthorInText -> (True, False) - SuppressAuthor -> (False,True ) - NormalCitation -> (False,False) - in emptyCite { CSL.citeId = citationId c - , CSL.citePrefix = PandocText $ citationPrefix c - , CSL.citeSuffix = PandocText s' - , CSL.citeLabel = la - , CSL.citeLocator = lo - , CSL.citeNoteNumber = show $ citationNoteNum c - , CSL.authorInText = fst citMode - , CSL.suppressAuthor = snd citMode - , CSL.citeHash = citationHash c - } - -locatorWords :: [Inline] -> (String, [Inline]) -locatorWords inp = - case parse pLocatorWords "suffix" $ breakup inp of - Right r -> r - Left _ -> ("",inp) - where breakup [] = [] - breakup (Str x : xs) = map Str (splitup x) ++ breakup xs - breakup (x : xs) = x : breakup xs - splitup = groupBy (\x y -> x /= '\160' && y /= '\160') - -pLocatorWords :: Parsec [Inline] st (String, [Inline]) -pLocatorWords = do - l <- pLocator - s <- getInput -- rest is suffix - if length l > 0 && last l == ',' - then return (init l, Str "," : s) - else return (l, s) - -pMatch :: (Inline -> Bool) -> Parsec [Inline] st Inline -pMatch condition = try $ do - t <- anyToken - guard $ condition t - return t - -pSpace :: Parsec [Inline] st Inline -pSpace = pMatch (\t -> t == Space || t == Str "\160") - -pLocator :: Parsec [Inline] st String -pLocator = try $ do - optional $ pMatch (== Str ",") - optional pSpace - f <- (guardFollowingDigit >> return [Str "p"]) -- "page" the default - <|> many1 (notFollowedBy pSpace >> anyToken) - gs <- many1 pWordWithDigits - return $ stringify f ++ (' ' : unwords gs) - -guardFollowingDigit :: Parsec [Inline] st () -guardFollowingDigit = do - t <- lookAhead anyToken - case t of - Str (d:_) | isDigit d -> return () - _ -> mzero - -pWordWithDigits :: Parsec [Inline] st String -pWordWithDigits = try $ do - optional pSpace - r <- many1 (notFollowedBy pSpace >> anyToken) - let s = stringify r - guard $ any isDigit s - return s - diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index c7c37d6b8..48e418ab2 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -48,7 +48,6 @@ import Data.Set (Set) import qualified Data.Set as Set import Data.Default import Text.Pandoc.Highlighting (Style, pygments) -import qualified Text.CSL as CSL -- | Individually selectable syntax extensions. data Extension = @@ -205,8 +204,6 @@ data ReaderOptions = ReaderOptions{ , readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior -- in parsing dashes; -- is em-dash; -- - before numerial is en-dash - , readerReferences :: [CSL.Reference] -- ^ Bibliographic references - , readerCitationStyle :: Maybe CSL.Style -- ^ Citation style , readerApplyMacros :: Bool -- ^ Apply macros to TeX math , readerIndentedCodeClasses :: [String] -- ^ Default classes for -- indented code blocks @@ -223,8 +220,6 @@ instance Default ReaderOptions , readerColumns = 80 , readerTabStop = 4 , readerOldDashes = False - , readerReferences = [] - , readerCitationStyle = Nothing , readerApplyMacros = True , readerIndentedCodeClasses = [] , readerDefaultImageExtension = "" @@ -289,7 +284,6 @@ data WriterOptions = WriterOptions , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory , writerCiteMethod :: CiteMethod -- ^ How to print cites - , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations , writerHtml5 :: Bool -- ^ Produce HTML5 , writerHtmlQTags :: Bool -- ^ Use @@ tags for quotes in HTML , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show @@ -332,7 +326,6 @@ instance Default WriterOptions where , writerSourceURL = Nothing , writerUserDataDir = Nothing , writerCiteMethod = Citeproc - , writerBiblioFiles = [] , writerHtml5 = False , writerHtmlQTags = False , writerBeamer = False diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index ded57df5a..e558ed1b9 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -38,7 +38,6 @@ import Text.Pandoc.Definition import Text.Pandoc.Walk import Text.Pandoc.Shared import Text.Pandoc.Options -import Text.Pandoc.Biblio (processBiblio) import Text.Pandoc.Parsing hiding ((<|>), many, optional, space) import qualified Text.Pandoc.UTF8 as UTF8 import Data.Char ( chr, ord ) @@ -67,9 +66,7 @@ parseLaTeX = do eof st <- getState let meta = stateMeta st - refs <- getOption readerReferences - mbsty <- getOption readerCitationStyle - let (Pandoc _ bs') = processBiblio mbsty refs $ doc bs + let (Pandoc _ bs') = doc bs return $ Pandoc meta bs' type LP = Parser [Char] ParserState diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 05662d9b5..658335202 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -54,7 +54,6 @@ import Text.Pandoc.Parsing hiding (tableWith) import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock ) import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag, isTextTag, isCommentTag ) -import Text.Pandoc.Biblio (processBiblio) import Data.Monoid (mconcat, mempty) import Control.Applicative ((<$>), (<*), (*>), (<$)) import Control.Monad @@ -327,9 +326,7 @@ parseMarkdown = do st <- getState let meta = runF (stateMeta' st) st let Pandoc _ bs = B.doc $ runF blocks st - mbsty <- getOption readerCitationStyle - refs <- getOption readerReferences - return $ processBiblio mbsty refs $ Pandoc meta bs + return $ Pandoc meta bs addWarning :: Maybe SourcePos -> String -> MarkdownParser () addWarning mbpos msg = diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ab579a326..6a781ddec 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -43,7 +43,6 @@ import Data.Char ( toLower, isPunctuation ) import Control.Applicative ((<|>)) import Control.Monad.State import Text.Pandoc.Pretty -import System.FilePath (dropExtension) import Text.Pandoc.Slides import Text.Pandoc.Highlighting (highlight, styleToLaTeX, formatLaTeXInline, formatLaTeXBlock, @@ -120,7 +119,6 @@ pandocToLaTeX options (Pandoc meta blocks) = do (biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader let main = render colwidth $ vsep body st <- get - let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options let context = defField "toc" (writerTableOfContents options) $ defField "toc-depth" (show (writerTOCDepth options - if writerChapters options @@ -152,11 +150,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do $ writerHighlightStyle options ) else id) $ (case writerCiteMethod options of - Natbib -> defField "biblio-files" biblioFiles . - defField "biblio-title" biblioTitle . + Natbib -> defField "biblio-title" biblioTitle . defField "natbib" True - Biblatex -> defField "biblio-files" biblioFiles . - defField "biblio-title" biblioTitle . + Biblatex -> defField "biblio-title" biblioTitle . defField "biblatex" True _ -> id) $ metadata diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index 8609781d0..5054559a1 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -63,7 +63,6 @@ tests = [ testGroup "markdown" "markdown-reader-more.txt" "markdown-reader-more.native" , lhsReaderTest "markdown+lhs" ] - , testGroup "citations" markdownCitationTests ] , testGroup "rst" [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst") @@ -190,19 +189,6 @@ fb2WriterTest title opts inputfile normfile = ignoreBinary = unlines . filter (not . startsWith " [String] -- ^ Options to pass to pandoc -- cgit v1.2.3 From 8b0052ba5b0578814a5aca14a0e02874a10cf947 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 1 Sep 2013 15:05:51 -0700 Subject: Mathjax in HTML slide shows: include explicit "Typeset" instruction. This seems to be needed for some formats (e.g. slideous) and won't hurt in others. Closes #966. --- src/Text/Pandoc/Writers/HTML.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 25079574e..63b466af3 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -143,7 +143,8 @@ pandocToHtml opts (Pandoc meta blocks) = do MathJax url -> H.script ! A.src (toValue url) ! A.type_ "text/javascript" - $ mempty + $ preEscapedString + "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);" JsMath (Just url) -> H.script ! A.src (toValue url) ! A.type_ "text/javascript" -- cgit v1.2.3 From 8d43e08ce7be8673cc399b948d29386f525e9e1f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 6 Sep 2013 22:26:18 -0700 Subject: Markdown writer: Fixed bugs in YAML header output. --- src/Text/Pandoc/Writers/Markdown.hs | 6 +++--- tests/writer.markdown | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index d617954dd..23e730bf0 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -39,7 +39,7 @@ import Text.Pandoc.Writers.Shared import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (blankline, char, space) import Data.List ( group, isPrefixOf, find, intersperse, transpose, sortBy ) -import Data.Char ( isSpace ) +import Data.Char ( isSpace, isPunctuation ) import Data.Ord ( comparing ) import Text.Pandoc.Pretty import Control.Monad.State @@ -143,7 +143,7 @@ jsonToYaml (Object hashmap) = | otherwise -> (k' <> ":") $$ x (k', Object _, x) -> (k' <> ":") $$ nest 2 x (_, String "", _) -> empty - (k', _, x) -> k' <> ":" <> space <> x) + (k', _, x) -> k' <> ":" <> space <> hang 2 "" x) $ sortBy (comparing fst) $ H.toList hashmap jsonToYaml (Array vec) = vcat $ map (\v -> hang 2 "- " (jsonToYaml v)) $ V.toList vec @@ -151,7 +151,7 @@ jsonToYaml (String "") = empty jsonToYaml (String s) = case T.unpack s of x | '\n' `elem` x -> hang 2 ("|" <> cr) $ text x - | not (any (`elem` x) "\"'#:[]{}?-") -> text x + | not (any isPunctuation x) -> text x | otherwise -> text $ "'" ++ substitute "'" "''" x ++ "'" jsonToYaml (Bool b) = text $ show b jsonToYaml (Number n) = text $ show n diff --git a/tests/writer.markdown b/tests/writer.markdown index 7d67e4e87..9cf153637 100644 --- a/tests/writer.markdown +++ b/tests/writer.markdown @@ -2,7 +2,7 @@ author: - John MacFarlane - Anonymous -date: July 17, 2006 +date: 'July 17, 2006' title: Pandoc Test Suite ... -- cgit v1.2.3 From 81e2df32c92ee95771f2613b9ad30aeaf11423e5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 8 Sep 2013 15:47:50 -0700 Subject: Made . . . for pause work in all slide show formats except slideous. --- README | 5 ++--- changelog | 5 +---- src/Text/Pandoc/Writers/HTML.hs | 22 +++++++++++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 7d926216b..56ad50b3c 100644 --- a/README +++ b/README @@ -2680,9 +2680,8 @@ a single document. Inserting pauses ---------------- -In reveal.js and beamer slide shows, you can add "pauses" within -a slide by including a paragraph containing three dots, separated -by spaces: +You can add "pauses" within a slide by including a paragraph containing +three dots, separated by spaces: # Slide with a pause diff --git a/changelog b/changelog index b7091460f..b3e9d8b0b 100644 --- a/changelog +++ b/changelog @@ -413,7 +413,7 @@ as markdown citations, it is redundant to have a bibliography, since one will be generated automatically.) - * Added syntax for "pauses" in beamer or reaveljs slide shows. + * Added syntax for "pauses" in slide shows: This gives @@ -421,9 +421,6 @@ a pause. - [note - no longer seems to work in recente revealjs - perhaps - this should be reverted] - * Use new flexible metadata type. + Depend on `pandoc-types` 1.12. This changes the type of diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 63b466af3..78a3edce8 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -268,11 +268,24 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen else blockToHtml opts (Header level' (id',classes,keyvals) title') let isSec (Sec _ _ _ _ _) = True isSec (Blk _) = False + let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."] + isPause _ = False + let fragmentClass = case writerSlideVariant opts of + RevealJsSlides -> "fragment" + _ -> "incremental" + let inDiv xs = Blk (RawBlock (Format "html") ("
")) : + (xs ++ [Blk (RawBlock (Format "html") "
")]) innerContents <- mapM (elementToHtml slideLevel opts) $ if titleSlide -- title slides have no content of their own then filter isSec elements - else elements + else if slide + then case splitBy isPause elements of + [] -> [] + [x] -> x + xs -> concatMap inDiv xs + else elements let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts] let classes' = ["titleslide" | titleSlide] ++ ["slide" | slide] ++ ["section" | (slide || writerSectionDivs opts) && @@ -401,10 +414,6 @@ blockToHtml opts (Para [Image txt (s,'f':'i':'g':':':tit)]) = do [nl opts, img, capt, nl opts] else H.div ! A.class_ "figure" $ mconcat [nl opts, img, capt, nl opts] --- . . . indicates a pause in a slideshow -blockToHtml opts (Para [Str ".",Space,Str ".",Space,Str "."]) - | writerSlideVariant opts == RevealJsSlides = - blockToHtml opts (RawBlock "html" "
") blockToHtml opts (Para lst) = do contents <- inlineListToHtml opts lst return $ H.p contents @@ -580,8 +589,7 @@ toListItem opts item = nl opts >> H.li item blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html blockListToHtml opts lst = - mapM (blockToHtml opts) lst >>= - return . mconcat . intersperse (nl opts) + fmap (mconcat . intersperse (nl opts)) $ mapM (blockToHtml opts) lst -- | Convert list of Pandoc inline elements to HTML. inlineListToHtml :: WriterOptions -> [Inline] -> State WriterState Html -- cgit v1.2.3 From ca6842349e23b3f60cb2665d1c20de9951bea268 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 12 Sep 2013 09:24:25 -0700 Subject: HTML writer: Ensure proper escaping in header metadata. --- changelog | 1 + src/Text/Pandoc/Writers/HTML.hs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/changelog b/changelog index f2742664c..a892ab0ec 100644 --- a/changelog +++ b/changelog @@ -405,6 +405,7 @@ + Fixed `--no-highlight` (Alexander Kondratskiy). + Don't convert to lowercase in email obfuscation (#839). + + Ensure proper escaping in `` and `<meta>` fields. * AsciiDoc writer: diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 78a3edce8..902c8bc53 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -39,7 +39,7 @@ import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Slides import Text.Pandoc.Highlighting ( highlight, styleToCss, formatHtmlInline, formatHtmlBlock ) -import Text.Pandoc.XML (fromEntities) +import Text.Pandoc.XML (fromEntities, escapeStringForXML) import Network.HTTP ( urlEncode ) import Numeric ( showHex ) import Data.Char ( ord, toLower ) @@ -115,8 +115,9 @@ pandocToHtml opts (Pandoc meta blocks) = do (fmap renderHtml . blockListToHtml opts) (fmap renderHtml . inlineListToHtml opts) meta - let authsMeta = map stringify $ docAuthors meta - let dateMeta = stringify $ docDate meta + let stringifyHTML = escapeStringForXML . stringify + let authsMeta = map stringifyHTML $ docAuthors meta + let dateMeta = stringifyHTML $ docDate meta let slideLevel = maybe (getSlideLevel blocks) id $ writerSlideLevel opts let sects = hierarchicalize $ if writerSlideVariant opts == NoSlides @@ -168,7 +169,7 @@ pandocToHtml opts (Pandoc meta blocks) = do maybe id (defField "toc" . renderHtml) toc $ defField "author-meta" authsMeta $ maybe id (defField "date-meta") (normalizeDate dateMeta) $ - defField "pagetitle" (stringify $ docTitle meta) $ + defField "pagetitle" (stringifyHTML $ docTitle meta) $ defField "idprefix" (writerIdentifierPrefix opts) $ -- these should maybe be set in pandoc.hs defField "slidy-url" -- cgit v1.2.3 From 37471041788f079632ec369a970a184864799c3d Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Thu, 12 Sep 2013 11:23:34 -0700 Subject: Markdown writer: Print references if output is 'plain'. --- src/Text/Pandoc/Writers/Markdown.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 23e730bf0..a36bb8e14 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -189,7 +189,8 @@ pandocToMarkdown opts (Pandoc meta blocks) = do -- Strip off final 'references' header if markdown citations enabled let blocks' = case reverse blocks of (Div (_,["references"],_) _):xs - | isEnabled Ext_citations opts -> reverse xs + | not isPlain && isEnabled Ext_citations opts + -> reverse xs _ -> blocks body <- blockListToMarkdown opts blocks' st <- get -- cgit v1.2.3 From d27e5a6ff002d575004bdb7abaebdc9c50e02b50 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 19 Sep 2013 09:48:02 -0700 Subject: DOCX writer: Add missing settings.xml to the zip container. Closes #990. --- src/Text/Pandoc/Writers/Docx.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index c8673ae48..1214e7f8b 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -257,6 +257,7 @@ writeDocx opts doc@(Pandoc meta _) = do docPropsAppEntry <- entryFromArchive "docProps/app.xml" themeEntry <- entryFromArchive "word/theme/theme1.xml" fontTableEntry <- entryFromArchive "word/fontTable.xml" + settingsEntry <- entryFromArchive "word/settings.xml" webSettingsEntry <- entryFromArchive "word/webSettings.xml" -- Create archive @@ -264,7 +265,8 @@ writeDocx opts doc@(Pandoc meta _) = do contentTypesEntry : relsEntry : contentEntry : relEntry : footnoteRelEntry : numEntry : styleEntry : footnotesEntry : docPropsEntry : docPropsAppEntry : themeEntry : - fontTableEntry : webSettingsEntry : imageEntries + fontTableEntry : settingsEntry : webSettingsEntry : + imageEntries return $ fromArchive archive styleToOpenXml :: Style -> [Element] -- cgit v1.2.3 From e135955b1e37b4bee72ffc6d7f4dc60e99dcecae Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 19 Sep 2013 10:08:49 -0700 Subject: LaTeX writer: Don't print biblio if --natbib or --biblatex option used. --- src/Text/Pandoc/Writers/LaTeX.hs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 37ca60ce3..8b05cfb43 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -82,10 +82,17 @@ writeLaTeX options document = pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String pandocToLaTeX options (Pandoc meta blocks) = do + -- Strip off final 'references' header if --natbib or --biblatex + let method = writerCiteMethod options + let blocks' = if method == Biblatex || method == Natbib + then case reverse blocks of + (Div (_,["references"],_) _):xs -> reverse xs + _ -> blocks + else blocks -- see if there are internal links let isInternalLink (Link _ ('#':xs,_)) = [xs] isInternalLink _ = [] - modify $ \s -> s{ stInternalLinks = query isInternalLink blocks } + modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' } let template = writerTemplate options -- set stBook depending on documentclass let bookClasses = ["memoir","book","report","scrreprt","scrbook"] @@ -107,15 +114,15 @@ pandocToLaTeX options (Pandoc meta blocks) = do (fmap (render colwidth) . blockListToLaTeX) (fmap (render colwidth) . inlineListToLaTeX) meta - let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then - (blocks, []) - else case last blocks of - Header 1 _ il -> (init blocks, il) - _ -> (blocks, []) - blocks'' <- if writerBeamer options - then toSlides blocks' - else return blocks' - body <- mapM (elementToLaTeX options) $ hierarchicalize blocks'' + let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then + (blocks', []) + else case last blocks' of + Header 1 _ il -> (init blocks', il) + _ -> (blocks', []) + blocks''' <- if writerBeamer options + then toSlides blocks'' + else return blocks'' + body <- mapM (elementToLaTeX options) $ hierarchicalize blocks''' (biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader let main = render colwidth $ vsep body st <- get -- cgit v1.2.3 From 255037a0912c5cc819985f4224057659f7af50fa Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 19 Sep 2013 10:09:32 -0700 Subject: Markdown reader: small code improvement. --- src/Text/Pandoc/Writers/Markdown.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index a36bb8e14..69ca05216 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -187,11 +187,11 @@ pandocToMarkdown opts (Pandoc meta blocks) = do then tableOfContents opts headerBlocks else empty -- Strip off final 'references' header if markdown citations enabled - let blocks' = case reverse blocks of - (Div (_,["references"],_) _):xs - | not isPlain && isEnabled Ext_citations opts - -> reverse xs - _ -> blocks + let blocks' = if not isPlain && isEnabled Ext_citations opts + then case reverse blocks of + (Div (_,["references"],_) _):xs -> reverse xs + _ -> blocks + else blocks body <- blockListToMarkdown opts blocks' st <- get notes' <- notesToMarkdown opts (reverse $ stNotes st) -- cgit v1.2.3 From e149d4e138fdf42df07ff8400a4748b6f7bde150 Mon Sep 17 00:00:00 2001 From: Václav Zeman <vhaisman@gmail.com> Date: Wed, 25 Sep 2013 01:18:39 +0200 Subject: src/Text/Pandoc/Writers/OpenDocument.hs: Fix formatting of strikeout code. --- src/Text/Pandoc/Writers/OpenDocument.hs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 3ec5c2073..0f9044601 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -192,8 +192,15 @@ writeOpenDocument opts (Pandoc meta blocks) = listStyles = map listStyle (stListStyles s) automaticStyles = inTagsIndented "office:automatic-styles" $ vcat $ reverse $ styles ++ listStyles + fontFaceDecls = inTagsIndented "office:font-face-decls" $ vcat $ + [selfClosingTag "style:font-face" [ + ("style:name", "Courier New") + , ("style:font-family-generic", "modern") + , ("style:font-pitch", "fixed") + , ("svg:font-family", "'Courier New'")]] context = defField "body" body $ defField "automatic-styles" (render' automaticStyles) + $ defField "font-face-decls" (render' fontFaceDecls) $ metadata in if writerStandalone opts then renderTemplate' (writerTemplate opts) context @@ -373,18 +380,18 @@ inlineToOpenDocument o ils | Subscript l <- ils = withTextStyle Sub $ inlinesToOpenDocument o l | SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l | Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l - | Code _ s <- ils = preformatted s + | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s) | Cite _ l <- ils = inlinesToOpenDocument o l | RawInline f s <- ils = if f == "opendocument" || f == "html" - then preformatted s + then withTextStyle Pre $ inTextStyle $ preformatted s else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l | Image _ (s,t) <- ils = return $ mkImg s t | Note l <- ils = mkNote l | otherwise = return empty where - preformatted = return . inSpanTags "Teletype" . handleSpaces . escapeStringForXML + preformatted s = handleSpaces $ escapeStringForXML s mkLink s t = inTags False "text:a" [ ("xlink:type" , "simple") , ("xlink:href" , s ) , ("office:name", t ) @@ -524,7 +531,8 @@ paraTableStyles t s (a:xs) [ ("fo:text-align", x) , ("style:justify-single-word", "false")] -data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC deriving ( Eq,Ord ) +data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC | Pre + deriving ( Eq,Ord ) textStyleAttr :: TextStyle -> [(String,String)] textStyleAttr s @@ -538,5 +546,8 @@ textStyleAttr s | Sub <- s = [("style:text-position" ,"sub 58%" )] | Sup <- s = [("style:text-position" ,"super 58%" )] | SmallC <- s = [("fo:font-variant" ,"small-caps")] + | Pre <- s = [("style:font-name" ,"Courier New") + ,("style:font-name-asian" ,"Courier New") + ,("style:font-name-complex" ,"Courier New")] | otherwise = [] -- cgit v1.2.3 From d76a6e23720f4acb292d3384ee020dfb072a120c Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 24 Sep 2013 18:41:19 -0700 Subject: OpenDocument writer: don't use font-face-decls variable. --- data/templates | 2 +- src/Text/Pandoc/Writers/OpenDocument.hs | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/data/templates b/data/templates index 1ccb16bb3..0bb5f9ba2 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 1ccb16bb33e8022c9511284e6718386efa3a0bbf +Subproject commit 0bb5f9ba204ea242e361c264f019490ead1cf313 diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 0f9044601..206be7133 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -192,15 +192,8 @@ writeOpenDocument opts (Pandoc meta blocks) = listStyles = map listStyle (stListStyles s) automaticStyles = inTagsIndented "office:automatic-styles" $ vcat $ reverse $ styles ++ listStyles - fontFaceDecls = inTagsIndented "office:font-face-decls" $ vcat $ - [selfClosingTag "style:font-face" [ - ("style:name", "Courier New") - , ("style:font-family-generic", "modern") - , ("style:font-pitch", "fixed") - , ("svg:font-family", "'Courier New'")]] context = defField "body" body $ defField "automatic-styles" (render' automaticStyles) - $ defField "font-face-decls" (render' fontFaceDecls) $ metadata in if writerStandalone opts then renderTemplate' (writerTemplate opts) context -- cgit v1.2.3 From dbd4aee7305ed82c9daf33a59fd0c29d3e3461d6 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sun, 6 Oct 2013 17:21:33 -0700 Subject: Removed code that forces MathJax to typeset. Closes #1012. Reopens #966. A better solution for #966 will just affect slideous, not the other slide writers. --- src/Text/Pandoc/Writers/HTML.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 902c8bc53..f6775b13a 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -144,8 +144,7 @@ pandocToHtml opts (Pandoc meta blocks) = do MathJax url -> H.script ! A.src (toValue url) ! A.type_ "text/javascript" - $ preEscapedString - "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);" + $ mempty JsMath (Just url) -> H.script ! A.src (toValue url) ! A.type_ "text/javascript" -- cgit v1.2.3 From de10b1653e0624d91bc9b0b96d2f84c4673c6d98 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Fri, 11 Oct 2013 22:01:58 -0700 Subject: RST writer: Skip spaces after display math. Otherwise we get indentation problems, and part of the next paragraph may be rendered as part of the math. --- src/Text/Pandoc/Writers/RST.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 70c6b4421..dd2c3186c 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -296,8 +296,14 @@ blockListToRST blocks = mapM blockToRST blocks >>= return . vcat -- | Convert list of Pandoc inline elements to RST. inlineListToRST :: [Inline] -> State WriterState Doc -inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat - where insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed +inlineListToRST lst = + mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>= return . hcat + where -- remove spaces after displaymath, as they screw up indentation: + removeSpaceAfterDisplayMath (Math DisplayMath x : zs) = + Math DisplayMath x : dropWhile (==Space) zs + removeSpaceAfterDisplayMath (x:xs) = x : removeSpaceAfterDisplayMath xs + removeSpaceAfterDisplayMath [] = [] + insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed insertBS (x:y:z:zs) | isComplex y && surroundComplex x z = x : y : RawInline "rst" "\\ " : insertBS (z:zs) -- cgit v1.2.3 From 2ae7f5e2a0a741fa4822448ad378280f77ab0dd5 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sun, 13 Oct 2013 11:31:33 -0700 Subject: HTML writer: Insert command to typeset mathjax for slideous output. Closes #966. --- src/Text/Pandoc/Writers/HTML.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index f6775b13a..cee07cff5 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -144,7 +144,11 @@ pandocToHtml opts (Pandoc meta blocks) = do MathJax url -> H.script ! A.src (toValue url) ! A.type_ "text/javascript" - $ mempty + $ case writerSlideVariant opts of + SlideousSlides -> + preEscapedString + "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);" + _ -> mempty JsMath (Just url) -> H.script ! A.src (toValue url) ! A.type_ "text/javascript" -- cgit v1.2.3 From 0df7cce37da162c656aa88ecb67788109749668c Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sun, 13 Oct 2013 15:36:19 -0700 Subject: Treat div with class "notes" as speaker notes in slide formats. Currently beamer goes to `\note{}`, revealjs to `<aside class="notes">`, and the notes are simply suppressed in other formats. Closes #925. --- README | 18 ++++++++++++++++++ src/Text/Pandoc/Writers/HTML.hs | 11 +++++++++-- src/Text/Pandoc/Writers/LaTeX.hs | 7 ++++++- 3 files changed, 33 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index ba1f93661..133c99f64 100644 --- a/README +++ b/README @@ -2731,6 +2731,24 @@ bibliographies: # References {.allowframebreaks} +Speaker notes +------------- + +reveal.js has good support for speaker notes. You can add notes to your +markdown document thus: + + <div class="notes"> + This is my note. + + - It can contain markdown + - like this list + + </div> + +To show the notes window, press `s` while viewing the presentation. +Notes are not yet supported for other slide formats, but the notes +will not appear on the slides themselves. + Literate Haskell support ======================== diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index cee07cff5..22f5b8074 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -421,9 +421,16 @@ blockToHtml opts (Para [Image txt (s,'f':'i':'g':':':tit)]) = do blockToHtml opts (Para lst) = do contents <- inlineListToHtml opts lst return $ H.p contents -blockToHtml opts (Div attr bs) = do +blockToHtml opts (Div attr@(_,classes,_) bs) = do contents <- blockListToHtml opts bs - return $ addAttrs opts attr $ H.div $ nl opts >> contents >> nl opts + let contents' = nl opts >> contents >> nl opts + return $ + if "notes" `elem` classes + then case writerSlideVariant opts of + RevealJsSlides -> addAttrs opts attr $ H5.aside $ contents' + NoSlides -> addAttrs opts attr $ H.div $ contents' + _ -> mempty + else addAttrs opts attr $ H.div $ contents' blockToHtml _ (RawBlock f str) | f == Format "html" = return $ preEscapedString str | otherwise = return mempty diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 8b05cfb43..d31e33a3a 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -285,7 +285,12 @@ isLineBreakOrSpace _ = False blockToLaTeX :: Block -- ^ Block to convert -> State WriterState Doc blockToLaTeX Null = return empty -blockToLaTeX (Div _ bs) = blockListToLaTeX bs +blockToLaTeX (Div (_,classes,_) bs) = do + beamer <- writerBeamer `fmap` gets stOptions + contents <- blockListToLaTeX bs + if beamer && "notes" `elem` classes -- speaker notes + then return $ "\\note" <> braces contents + else return contents blockToLaTeX (Plain lst) = inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst -- title beginning with fig: indicates that the image is a figure -- cgit v1.2.3 From 386e933432f5badf3149da1e6edaeb2e693bbb9b Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Wed, 16 Oct 2013 09:48:11 -0700 Subject: Use isURI instead of isAbsoluteURI. It allows fragments identifiers. --- src/Text/Pandoc/SelfContained.hs | 6 +++--- src/Text/Pandoc/Shared.hs | 4 ++-- src/Text/Pandoc/Writers/LaTeX.hs | 4 ++-- src/Text/Pandoc/Writers/Markdown.hs | 4 ++-- src/Text/Pandoc/Writers/RST.hs | 4 ++-- src/Text/Pandoc/Writers/RTF.hs | 4 ++-- src/Text/Pandoc/Writers/Texinfo.hs | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 0547bc065..6112e764f 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -32,7 +32,7 @@ the HTML using data URIs. -} module Text.Pandoc.SelfContained ( makeSelfContained ) where import Text.HTML.TagSoup -import Network.URI (isAbsoluteURI, escapeURIString) +import Network.URI (isURI, escapeURIString) import Data.ByteString.Base64 import qualified Data.ByteString.Char8 as B import Data.ByteString (ByteString) @@ -86,7 +86,7 @@ cssURLs userdata d orig = "\"" -> B.takeWhile (/='"') $ B.drop 1 u "'" -> B.takeWhile (/='\'') $ B.drop 1 u _ -> u - let url' = if isAbsoluteURI url + let url' = if isURI url then url else d </> url (raw, mime) <- getRaw userdata "" url' @@ -97,7 +97,7 @@ cssURLs userdata d orig = getItem :: Maybe FilePath -> String -> IO (ByteString, Maybe String) getItem userdata f = - if isAbsoluteURI f + if isURI f then openURL f >>= either handleErr return else do -- strip off trailing query or fragment part, if relative URL. diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 9a9a092fc..d6ccdae66 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -91,7 +91,7 @@ import Data.Char ( toLower, isLower, isUpper, isAlpha, isLetter, isDigit, isSpace ) import Data.List ( find, isPrefixOf, intercalate ) import qualified Data.Map as M -import Network.URI ( escapeURIString, isAbsoluteURI, unEscapeString ) +import Network.URI ( escapeURIString, isURI, unEscapeString ) import System.Directory import Text.Pandoc.MIME (getMimeType) import System.FilePath ( (</>), takeExtension, dropExtension ) @@ -624,7 +624,7 @@ readDataFileUTF8 userDir fname = fetchItem :: Maybe String -> String -> IO (Either E.SomeException (BS.ByteString, Maybe String)) fetchItem sourceURL s - | isAbsoluteURI s = openURL s + | isURI s = openURL s | otherwise = case sourceURL of Just u -> openURL (u ++ "/" ++ s) Nothing -> E.try readLocalFile diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index d31e33a3a..dbfa57137 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -36,7 +36,7 @@ import Text.Pandoc.Writers.Shared import Text.Pandoc.Options import Text.Pandoc.Templates import Text.Printf ( printf ) -import Network.URI ( isAbsoluteURI, unEscapeString ) +import Network.URI ( isURI, unEscapeString ) import Data.List ( (\\), isSuffixOf, isInfixOf, isPrefixOf, intercalate, intersperse ) import Data.Char ( toLower, isPunctuation ) @@ -671,7 +671,7 @@ inlineToLaTeX (Link txt (src, _)) = contents <> char '}' inlineToLaTeX (Image _ (source, _)) = do modify $ \s -> s{ stGraphics = True } - let source' = if isAbsoluteURI source + let source' = if isURI source then source else unEscapeString source source'' <- stringToLaTeX URLString source' diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 69ca05216..33cb110b5 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -47,7 +47,7 @@ import qualified Data.Set as Set import Text.Pandoc.Writers.HTML (writeHtmlString) import Text.Pandoc.Readers.TeXMath (readTeXMath) import Text.HTML.TagSoup (renderTags, parseTags, isTagText, Tag(..)) -import Network.URI (isAbsoluteURI) +import Network.URI (isURI) import Data.Default import Data.Yaml (Value(Object,String,Array,Bool,Number)) import qualified Data.HashMap.Strict as H @@ -753,7 +753,7 @@ inlineToMarkdown opts (Link txt (src, tit)) = do then empty else text $ " \"" ++ tit ++ "\"" let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src - let useAuto = isAbsoluteURI src && + let useAuto = isURI src && case txt of [Str s] | escapeURI s == srcSuffix -> True _ -> False diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index dd2c3186c..1a62f7250 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -38,7 +38,7 @@ import Text.Pandoc.Writers.Shared import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Builder (deleteMeta) import Data.List ( isPrefixOf, intersperse, transpose ) -import Network.URI (isAbsoluteURI) +import Network.URI (isURI) import Text.Pandoc.Pretty import Control.Monad.State import Control.Applicative ( (<$>) ) @@ -393,7 +393,7 @@ inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para) inlineToRST Space = return space -- autolink inlineToRST (Link [Str str] (src, _)) - | isAbsoluteURI src && + | isURI src && if "mailto:" `isPrefixOf` src then src == escapeURI ("mailto:" ++ str) else src == escapeURI str = do diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 0e8ce2ece..cb5fb3232 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -40,7 +40,7 @@ import Data.Char ( ord, chr, isDigit, toLower ) import System.FilePath ( takeExtension ) import qualified Data.ByteString as B import Text.Printf ( printf ) -import Network.URI ( isAbsoluteURI, unEscapeString ) +import Network.URI ( isURI, unEscapeString ) import qualified Control.Exception as E -- | Convert Image inlines into a raw RTF embedded image, read from a file. @@ -48,7 +48,7 @@ import qualified Control.Exception as E rtfEmbedImage :: Inline -> IO Inline rtfEmbedImage x@(Image _ (src,_)) = do let ext = map toLower (takeExtension src) - if ext `elem` [".jpg",".jpeg",".png"] && not (isAbsoluteURI src) + if ext `elem` [".jpg",".jpeg",".png"] && not (isURI src) then do let src' = unEscapeString src imgdata <- E.catch (B.readFile src') diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs index b1fd3d6af..d62e50880 100644 --- a/src/Text/Pandoc/Writers/Texinfo.hs +++ b/src/Text/Pandoc/Writers/Texinfo.hs @@ -40,7 +40,7 @@ import Data.Ord ( comparing ) import Data.Char ( chr, ord ) import Control.Monad.State import Text.Pandoc.Pretty -import Network.URI ( isAbsoluteURI, unEscapeString ) +import Network.URI ( isURI, unEscapeString ) import System.FilePath data WriterState = @@ -448,7 +448,7 @@ inlineToTexinfo (Image alternate (source, _)) = do where ext = drop 1 $ takeExtension source' base = dropExtension source' - source' = if isAbsoluteURI source + source' = if isURI source then source else unEscapeString source -- cgit v1.2.3 From 6e1c24da8e9f4715e03fd1ff9ee64528936d8bf3 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Thu, 17 Oct 2013 13:23:38 -0700 Subject: LaTeX writer: Add link anchors for code blocks with identifiers. Closes #1025. --- src/Text/Pandoc/Writers/LaTeX.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index dbfa57137..8f52b11ca 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -329,17 +329,23 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do | writerListings opts -> listingsCodeBlock | writerHighlight opts && not (null classes) -> highlightedCodeBlock | otherwise -> rawCodeBlock - where lhsCodeBlock = do + where ref = text identifier + linkAnchor = if null identifier + then empty + else "\\hyperdef{}" <> braces ref <> + braces ("\\label" <> braces ref) + lhsCodeBlock = do modify $ \s -> s{ stLHS = True } - return $ flush ("\\begin{code}" $$ text str $$ "\\end{code}") $$ cr + return $ flush (linkAnchor $$ "\\begin{code}" $$ text str $$ + "\\end{code}") $$ cr rawCodeBlock = do st <- get env <- if stInNote st then modify (\s -> s{ stVerbInNote = True }) >> return "Verbatim" else return "verbatim" - return $ flush (text ("\\begin{" ++ env ++ "}") $$ text str $$ - text ("\\end{" ++ env ++ "}")) <> cr + return $ flush (linkAnchor $$ text ("\\begin{" ++ env ++ "}") $$ + text str $$ text ("\\end{" ++ env ++ "}")) <> cr listingsCodeBlock = do st <- get let params = if writerListings (stOptions st) @@ -367,7 +373,7 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of Nothing -> rawCodeBlock Just h -> modify (\st -> st{ stHighlighting = True }) >> - return (flush $ text h) + return (flush $ linkAnchor $$ text h) blockToLaTeX (RawBlock f x) | f == Format "latex" || f == Format "tex" = return $ text x -- cgit v1.2.3 From 1f29f4678e0a1b1272704e5ddafa0bee45e5e426 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 17 Oct 2013 22:06:39 -0700 Subject: LaTeX writer: Specially escape non-ascii characters in labels. Otherwise we can get compile errors and other bugs when compiled with pdflatex. Closes #1007. Thanks to begemotv2718 for the fix. --- src/Text/Pandoc/Writers/LaTeX.hs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 8f52b11ca..20a6ac9a9 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -39,7 +39,7 @@ import Text.Printf ( printf ) import Network.URI ( isURI, unEscapeString ) import Data.List ( (\\), isSuffixOf, isInfixOf, isPrefixOf, intercalate, intersperse ) -import Data.Char ( toLower, isPunctuation ) +import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord ) import Control.Applicative ((<|>)) import Control.Monad.State import Text.Pandoc.Pretty @@ -222,6 +222,13 @@ stringToLaTeX ctx (x:xs) = do '\x2013' | ligatures -> "--" ++ rest _ -> x : rest +toLabel :: String -> String +toLabel [] = "" +toLabel (x:xs) + | (isLetter x || isDigit x) && isAscii x = x:toLabel xs + | elem x "-+=:;." = x:toLabel xs + | otherwise = "ux" ++ printf "%x" (ord x) ++ toLabel xs + -- | Puts contents into LaTeX command. inCmd :: String -> Doc -> Doc inCmd cmd contents = char '\\' <> text cmd <> braces contents @@ -329,7 +336,7 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do | writerListings opts -> listingsCodeBlock | writerHighlight opts && not (null classes) -> highlightedCodeBlock | otherwise -> rawCodeBlock - where ref = text identifier + where ref = text $ toLabel identifier linkAnchor = if null identifier then empty else "\\hyperdef{}" <> braces ref <> @@ -361,7 +368,7 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do (key,attr) <- keyvalAttr ] ++ (if identifier == "" then [] - else [ "label=" ++ identifier ]) + else [ "label=" ++ toLabel identifier ]) else [] printParams @@ -537,13 +544,13 @@ sectionHeader unnumbered ref level lst = do let refLabel x = (if ref `elem` internalLinks then text "\\hyperdef" <> braces empty - <> braces (text ref) + <> braces (text $ toLabel ref) <> braces x else x) let headerWith x y r = refLabel $ text x <> y <> if null r then empty - else text "\\label" <> braces (text r) + else text "\\label" <> braces (text $ toLabel r) let sectionType = case level' of 0 | writerBeamer opts -> "part" | otherwise -> "chapter" @@ -664,7 +671,8 @@ inlineToLaTeX Space = return space inlineToLaTeX (Link txt ('#':ident, _)) = do contents <- inlineListToLaTeX txt ident' <- stringToLaTeX URLString ident - return $ text "\\hyperref" <> brackets (text ident') <> braces contents + return $ text "\\hyperref" <> brackets (text $ toLabel ident') <> + braces contents inlineToLaTeX (Link txt (src, _)) = case txt of [Str x] | x == src -> -- autolink -- cgit v1.2.3 From 1ce875a010e1471e06338a20c82781036d476776 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sun, 20 Oct 2013 09:56:50 -0700 Subject: Fixed '. . .' (pause) on HTML slide formats. Closes #1029. The old version caused a pause to be inserted before the first material on a slide. This has been fixed. --- src/Text/Pandoc/Writers/HTML.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 22f5b8074..8a71c3a2e 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -286,9 +286,8 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen then filter isSec elements else if slide then case splitBy isPause elements of - [] -> [] - [x] -> x - xs -> concatMap inDiv xs + [] -> [] + (x:xs) -> x ++ concatMap inDiv xs else elements let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts] let classes' = ["titleslide" | titleSlide] ++ ["slide" | slide] ++ -- cgit v1.2.3 From e63aafd62004e3424da46de75c78ba4dc7562af4 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 21 Oct 2013 17:33:42 -0700 Subject: Fix definition lists with internal links in terms (closes #1032). This fix puts braces around a term that contains an internal link, to avoid problems with square brackets. --- src/Text/Pandoc/Writers/LaTeX.hs | 9 ++++++++- tests/Tests/Writers/LaTeX.hs | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 20a6ac9a9..72b0bde6d 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -513,8 +513,15 @@ listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) . defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc defListItemToLaTeX (term, defs) = do term' <- inlineListToLaTeX term + -- put braces around term if it contains an internal link, + -- since otherwise we get bad bracket interactions: \item[\hyperref[..] + let isInternalLink (Link _ ('#':_,_)) = True + isInternalLink _ = False + let term'' = if any isInternalLink term + then braces term' + else term' def' <- liftM vsep $ mapM blockListToLaTeX defs - return $ "\\item" <> brackets term' $$ def' + return $ "\\item" <> brackets term'' $$ def' -- | Craft the section header, inserting the secton reference, if supplied. sectionHeader :: Bool -- True for unnumbered diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index 5f702a85d..8a9519e2e 100644 --- a/tests/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs @@ -39,6 +39,11 @@ tests = [ testGroup "code blocks" , test latexListing "no identifier" $ codeBlock "hi" =?> ("\\begin{lstlisting}\nhi\n\\end{lstlisting}" :: String) ] + , testGroup "definition lists" + [ "with internal link" =: definitionList [(link "#go" "" (str "testing"), + [plain (text "hi there")])] =?> + "\\begin{description}\n\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item[{\\hyperref[go]{testing}}]\nhi there\n\\end{description}" + ] , testGroup "math" [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?> "$\\sigma|_{\\{x\\}}$" -- cgit v1.2.3 From ac7714ca398eaf25dd512754c1cb9aee297ff3d1 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sat, 26 Oct 2013 18:22:59 -0700 Subject: Text.Pandoc.Writer.Shared: fixed bug in tagWithAttrs. A space was omitted before key-value attributes, leading to invalid HTML. --- src/Text/Pandoc/Writers/Shared.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 89923822c..9cb08803c 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -134,7 +134,6 @@ tagWithAttrs tag (ident,classes,kvs) = hsep ,if null classes then empty else "class=" <> doubleQuotes (text (unwords classes)) - ] - <> hsep (map (\(k,v) -> text k <> "=" <> + ,hsep (map (\(k,v) -> text k <> "=" <> doubleQuotes (text (escapeStringForXML v))) kvs) - <> ">" + ] <> ">" -- cgit v1.2.3 From 0d95c15e8316eb28128bdd4c9c2f98e29f13f564 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 1 Nov 2013 14:27:22 -0700 Subject: TexMath: Export readTeXMath', which attends to display/inline. Deprecate readTeXMath, and use readTeXMath' in all the writers. Require texmath >= 0.6.5. --- pandoc.cabal | 2 +- src/Text/Pandoc/Readers/TeXMath.hs | 24 +++++++++++++++++++----- src/Text/Pandoc/Writers/Docbook.hs | 4 ++-- src/Text/Pandoc/Writers/Docx.hs | 2 +- src/Text/Pandoc/Writers/HTML.hs | 4 ++-- src/Text/Pandoc/Writers/Man.hs | 5 +++-- src/Text/Pandoc/Writers/Markdown.hs | 6 +++--- src/Text/Pandoc/Writers/OpenDocument.hs | 2 +- src/Text/Pandoc/Writers/RTF.hs | 2 +- tests/writer.docbook | 2 +- tests/writer.html | 2 +- tests/writer.man | 2 +- tests/writer.opendocument | 2 +- tests/writer.rtf | 2 +- 14 files changed, 38 insertions(+), 23 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.cabal b/pandoc.cabal index 6f51bc110..7e7081900 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -215,7 +215,7 @@ Library old-locale >= 1 && < 1.1, time >= 1.2 && < 1.5, HTTP >= 4000.0.5 && < 4000.3, - texmath >= 0.6.4 && < 0.7, + texmath >= 0.6.5 && < 0.7, xml >= 1.3.12 && < 1.4, random >= 1 && < 1.1, extensible-exceptions >= 0.1 && < 0.2, diff --git a/src/Text/Pandoc/Readers/TeXMath.hs b/src/Text/Pandoc/Readers/TeXMath.hs index 1f7088f72..6bd617f7e 100644 --- a/src/Text/Pandoc/Readers/TeXMath.hs +++ b/src/Text/Pandoc/Readers/TeXMath.hs @@ -27,16 +27,30 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of TeX math to a list of 'Pandoc' inline elements. -} -module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where +module Text.Pandoc.Readers.TeXMath ( readTeXMath, readTeXMath' ) where import Text.Pandoc.Definition import Text.TeXMath -- | Converts a raw TeX math formula to a list of 'Pandoc' inlines. --- Defaults to raw formula between @$@ characters if entire formula +-- Defaults to raw formula between @$@ or @$$@ characters if entire formula -- can't be converted. +readTeXMath' :: MathType + -> String -- ^ String to parse (assumes @'\n'@ line endings) + -> [Inline] +readTeXMath' mt inp = case texMathToPandoc dt inp of + Left _ -> [Str (delim ++ inp ++ delim)] + Right res -> res + where (dt, delim) = case mt of + DisplayMath -> (DisplayBlock, "$$") + InlineMath -> (DisplayInline, "$") + +{-# DEPRECATED readTeXMath "Use readTeXMath' from Text.Pandoc.JSON instead" #-} +-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines. +-- Defaults to raw formula between @$@ characters if entire formula +-- can't be converted. (This is provided for backwards compatibility; +-- it is better to use @readTeXMath'@, which properly distinguishes +-- between display and inline math.) readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings) -> [Inline] -readTeXMath inp = case texMathToPandoc DisplayInline inp of - Left _ -> [Str ("$" ++ inp ++ "$")] - Right res -> res +readTeXMath = readTeXMath' InlineMath diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 7c03c07dc..dad83d7bb 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -281,8 +281,8 @@ inlineToDocbook opts (Math t str) $ fixNS $ removeAttr r Left _ -> inlinesToDocbook opts - $ readTeXMath str - | otherwise = inlinesToDocbook opts $ readTeXMath str + $ readTeXMath' t str + | otherwise = inlinesToDocbook opts $ readTeXMath' t str where (dt, tagtype) = case t of InlineMath -> (DisplayInline,"inlineequation") DisplayMath -> (DisplayBlock,"informalequation") diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 1214e7f8b..0fdea0a7a 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -669,7 +669,7 @@ inlineToOpenXML opts (Math mathType str) = do else DisplayInline case texMathToOMML displayType str of Right r -> return [r] - Left _ -> inlinesToOpenXML opts (readTeXMath str) + Left _ -> inlinesToOpenXML opts (readTeXMath' mathType str) inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst inlineToOpenXML opts (Code attrs str) = withTextProp (rStyle "VerbatimChar") diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 8a71c3a2e..c1cca291b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -685,14 +685,14 @@ inlineToHtml opts inline = Right r -> return $ preEscapedString $ ppcElement conf r Left _ -> inlineListToHtml opts - (readTeXMath str) >>= return . + (readTeXMath' t str) >>= return . (H.span ! A.class_ "math") MathJax _ -> return $ H.span ! A.class_ "math" $ toHtml $ case t of InlineMath -> "\\(" ++ str ++ "\\)" DisplayMath -> "\\[" ++ str ++ "\\]" PlainMath -> do - x <- inlineListToHtml opts (readTeXMath str) + x <- inlineListToHtml opts (readTeXMath' t str) let m = H.span ! A.class_ "math" $ x let brtag = if writerHtml5 opts then H5.br else H.br return $ case t of diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index 642a002d6..b31cc2b70 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -330,9 +330,10 @@ inlineToMan opts (Cite _ lst) = inlineToMan _ (Code _ str) = return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]" inlineToMan _ (Str str) = return $ text $ escapeString str -inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str +inlineToMan opts (Math InlineMath str) = + inlineListToMan opts $ readTeXMath' InlineMath str inlineToMan opts (Math DisplayMath str) = do - contents <- inlineListToMan opts $ readTeXMath str + contents <- inlineListToMan opts $ readTeXMath' DisplayMath str return $ cr <> text ".RS" $$ contents $$ text ".RE" inlineToMan _ (RawInline f str) | f == Format "man" = return $ text str diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 33cb110b5..56be709d8 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -45,7 +45,7 @@ import Text.Pandoc.Pretty import Control.Monad.State import qualified Data.Set as Set import Text.Pandoc.Writers.HTML (writeHtmlString) -import Text.Pandoc.Readers.TeXMath (readTeXMath) +import Text.Pandoc.Readers.TeXMath (readTeXMath') import Text.HTML.TagSoup (renderTags, parseTags, isTagText, Tag(..)) import Network.URI (isURI) import Data.Default @@ -697,7 +697,7 @@ inlineToMarkdown opts (Math InlineMath str) return $ "\\(" <> text str <> "\\)" | isEnabled Ext_tex_math_double_backslash opts = return $ "\\\\(" <> text str <> "\\\\)" - | otherwise = inlineListToMarkdown opts $ readTeXMath str + | otherwise = inlineListToMarkdown opts $ readTeXMath' InlineMath str inlineToMarkdown opts (Math DisplayMath str) | isEnabled Ext_tex_math_dollars opts = return $ "$$" <> text str <> "$$" @@ -706,7 +706,7 @@ inlineToMarkdown opts (Math DisplayMath str) | isEnabled Ext_tex_math_double_backslash opts = return $ "\\\\[" <> text str <> "\\\\]" | otherwise = (\x -> cr <> x <> cr) `fmap` - inlineListToMarkdown opts (readTeXMath str) + inlineListToMarkdown opts (readTeXMath' DisplayMath str) inlineToMarkdown opts (RawInline f str) | f == "html" || f == "markdown" || (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) = diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 206be7133..b38d250aa 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -374,7 +374,7 @@ inlineToOpenDocument o ils | SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l | Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s - | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s) + | Math t s <- ils = inlinesToOpenDocument o (readTeXMath' t s) | Cite _ l <- ils = inlinesToOpenDocument o l | RawInline f s <- ils = if f == "opendocument" || f == "html" then withTextStyle Pre $ inTextStyle $ preformatted s diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index cb5fb3232..fb935fa6a 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -324,7 +324,7 @@ inlineToRTF (Quoted DoubleQuote lst) = "\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\"" inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}" inlineToRTF (Str str) = stringToRTF str -inlineToRTF (Math _ str) = inlineListToRTF $ readTeXMath str +inlineToRTF (Math t str) = inlineListToRTF $ readTeXMath' t str inlineToRTF (Cite _ lst) = inlineListToRTF lst inlineToRTF (RawInline f str) | f == Format "rtf" = str diff --git a/tests/writer.docbook b/tests/writer.docbook index e427d8ffc..1d4da4842 100644 --- a/tests/writer.docbook +++ b/tests/writer.docbook @@ -1084,7 +1084,7 @@ These should not be escaped: \$ \\ \> \[ \{ <listitem> <para> Here’s some display math: - $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$ + $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ </para> </listitem> <listitem> diff --git a/tests/writer.html b/tests/writer.html index e8e619f44..e0d1a3b25 100644 --- a/tests/writer.html +++ b/tests/writer.html @@ -439,7 +439,7 @@ Blah <li><span class="math"><em>α</em> ∧ <em>ω</em></span></li> <li><span class="math">223</span></li> <li><span class="math"><em>p</em></span>-Tree</li> -<li>Here’s some display math: <br /><span class="math">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span><br /></li> +<li>Here’s some display math: <br /><span class="math">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span><br /></li> <li>Here’s one that has a line break in it: <span class="math"><em>α</em> + <em>ω</em> × <em>x</em><sup>2</sup></span>.</li> </ul> <p>These shouldn’t be math:</p> diff --git a/tests/writer.man b/tests/writer.man index 54baaf791..aab588f9c 100644 --- a/tests/writer.man +++ b/tests/writer.man @@ -572,7 +572,7 @@ Ellipses\&...and\&...and\&.... .IP \[bu] 2 Here's some display math: .RS -$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)\-f(x)}{h}$ +$$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)\-f(x)}{h}$$ .RE .IP \[bu] 2 Here's one that has a line break in it: diff --git a/tests/writer.opendocument b/tests/writer.opendocument index d5eec1b60..b3888e34d 100644 --- a/tests/writer.opendocument +++ b/tests/writer.opendocument @@ -1418,7 +1418,7 @@ five.</text:p> </text:list-item> <text:list-item> <text:p text:style-name="P51">Here’s some display math: - $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</text:p> + $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</text:p> </text:list-item> <text:list-item> <text:p text:style-name="P51">Here’s one that has a line break in it: diff --git a/tests/writer.rtf b/tests/writer.rtf index 42c13d8c7..954d95cc4 100644 --- a/tests/writer.rtf +++ b/tests/writer.rtf @@ -269,7 +269,7 @@ quoted link {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i \u945?}\u8197?\u8743?\u8197?{\i \u969?}\par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab 223\par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i p}-Tree\par} -{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's some display math: $\\frac\{d\}\{dx\}f(x)=\\lim_\{h\\to 0\}\\frac\{f(x+h)-f(x)\}\{h\}$\par} +{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's some display math: $$\\frac\{d\}\{dx\}f(x)=\\lim_\{h\\to 0\}\\frac\{f(x+h)-f(x)\}\{h\}$$\par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's one that has a line break in it: {\i \u945?}\u8197?+\u8197?{\i \u969?}\u8197?\u215?\u8197?{\i x}{\super 2}.\sa180\par} {\pard \ql \f0 \sa180 \li0 \fi0 These shouldn\u8217't be math:\par} {\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab To get the famous equation, write {\f1 $e = mc^2$}.\par} -- cgit v1.2.3 From 6b24b1afca306c9149c285b60ed36f04fae2ece2 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Wed, 6 Nov 2013 09:25:50 -0800 Subject: Don't print `<span>` tags in 'plain' output. --- src/Text/Pandoc/Writers/Markdown.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 56be709d8..eefcd547a 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -642,8 +642,11 @@ escapeSpaces x = x -- | Convert Pandoc inline element to markdown. inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc inlineToMarkdown opts (Span attrs ils) = do + st <- get contents <- inlineListToMarkdown opts ils - return $ tagWithAttrs "span" attrs <> contents <> text "</span>" + return $ if stPlain st + then contents + else tagWithAttrs "span" attrs <> contents <> text "</span>" inlineToMarkdown opts (Emph lst) = do contents <- inlineListToMarkdown opts lst return $ "*" <> contents <> "*" -- cgit v1.2.3 From 5b99112f229db1fcbe82943678f9f55c1ead8f11 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Wed, 6 Nov 2013 19:18:24 -0800 Subject: Docx writer: Fix URL for core-properties in `_rels/.rels`. Partially addresses #1046. --- src/Text/Pandoc/Writers/Docx.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 0fdea0a7a..f1276c831 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -247,7 +247,7 @@ writeDocx opts doc@(Pandoc meta _) = do ,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties") ,("Target","docProps/app.xml")] , [("Id","rId3") - ,("Type","http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties") + ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties") ,("Target","docProps/core.xml")] ] let relsEntry = toEntry relsPath epochtime $ renderXml rels -- cgit v1.2.3 From 2efd0951d3d560a159f92df4730e2cee26978698 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 7 Nov 2013 08:46:52 -0800 Subject: Docx writer: fixed core metadata. - Don't create empty date nodes if no date given. - Don't create multiple dc:creator nodes; instead separate by semicolons. Closes #1046. --- src/Text/Pandoc/Writers/Docx.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index f1276c831..5d1647844 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -231,10 +231,11 @@ writeDocx opts doc@(Pandoc meta _) = do ,("xmlns:dcmitype","http://purl.org/dc/dcmitype/") ,("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")] $ mknode "dc:title" [] (stringify $ docTitle meta) - : mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] - (maybe "" id $ normalizeDate $ stringify $ docDate meta) - : mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] () -- put current time here - : map (mknode "dc:creator" [] . stringify) (docAuthors meta) + : mknode "dc:creator" [] (intercalate "; " (map stringify $ docAuthors meta)) + : maybe [] + (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] $ x + , mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] $ x + ]) (normalizeDate $ stringify $ docDate meta) let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps let relsPath = "_rels/.rels" -- cgit v1.2.3 From b4441c940dc76d1a64636ef88287b38306ebccb4 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 12 Nov 2013 18:48:06 -0800 Subject: HTML/EPUB footnotes: Put `<sup>` tag inside `<a>` tags. This allows better control of formatting, since the `<a>` tags have a distinguishing class. Closes #1049. --- src/Text/Pandoc/Writers/HTML.hs | 8 ++++---- tests/writer.html | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index c1cca291b..424843539 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -757,11 +757,11 @@ inlineToHtml opts inline = writerIdentifierPrefix opts ++ "fn" ++ ref) ! A.class_ "footnoteRef" ! prefixedId opts ("fnref" ++ ref) + $ H.sup $ toHtml ref - let link' = case writerEpubVersion opts of - Just EPUB3 -> link ! customAttribute "epub:type" "noteref" - _ -> link - return $ H.sup $ link' + return $ case writerEpubVersion opts of + Just EPUB3 -> link ! customAttribute "epub:type" "noteref" + _ -> link (Cite cits il)-> do contents <- inlineListToHtml opts il let citationIds = unwords $ map citationId cits let result = H.span ! A.class_ "citation" $ contents diff --git a/tests/writer.html b/tests/writer.html index e0d1a3b25..d00b8ca66 100644 --- a/tests/writer.html +++ b/tests/writer.html @@ -544,12 +544,12 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>'); <p>Here is a movie <img src="movie.jpg" alt="movie" /> icon.</p> <hr /> <h1 id="footnotes">Footnotes</h1> -<p>Here is a footnote reference,<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> and another.<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<sup><a href="#fn3" class="footnoteRef" id="fnref3">3</a></sup></p> +<p>Here is a footnote reference,<a href="#fn1" class="footnoteRef" id="fnref1"><sup>1</sup></a> and another.<a href="#fn2" class="footnoteRef" id="fnref2"><sup>2</sup></a> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a href="#fn3" class="footnoteRef" id="fnref3"><sup>3</sup></a></p> <blockquote> -<p>Notes can go in quotes.<sup><a href="#fn4" class="footnoteRef" id="fnref4">4</a></sup></p> +<p>Notes can go in quotes.<a href="#fn4" class="footnoteRef" id="fnref4"><sup>4</sup></a></p> </blockquote> <ol style="list-style-type: decimal"> -<li>And in list items.<sup><a href="#fn5" class="footnoteRef" id="fnref5">5</a></sup></li> +<li>And in list items.<a href="#fn5" class="footnoteRef" id="fnref5"><sup>5</sup></a></li> </ol> <p>This paragraph should not be part of the note, as it is not indented.</p> <div class="footnotes"> -- cgit v1.2.3 From 892ba2dd163cbba598cbd86814a594008aae9f27 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sat, 16 Nov 2013 14:09:09 -0800 Subject: LaTeX writer: Properly escape pdftitle, pdfauthor. Closes #1059. --- src/Text/Pandoc/Writers/LaTeX.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 72b0bde6d..7ff64cf74 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -126,14 +126,16 @@ pandocToLaTeX options (Pandoc meta blocks) = do (biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader let main = render colwidth $ vsep body st <- get + titleMeta <- stringToLaTeX TextString $ stringify $ docTitle meta + authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta let context = defField "toc" (writerTableOfContents options) $ defField "toc-depth" (show (writerTOCDepth options - if writerChapters options then 1 else 0)) $ defField "body" main $ - defField "title-meta" (stringify $ docTitle meta) $ - defField "author-meta" (intercalate "; " $ map stringify $ docAuthors meta) $ + defField "title-meta" titleMeta $ + defField "author-meta" (intercalate "; " authorsMeta) $ defField "documentclass" (if writerBeamer options then ("beamer" :: String) else if writerChapters options -- cgit v1.2.3 From 9b0378b939f46183fc152b1a49a69f3007de295a Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 16 Nov 2013 22:49:15 -0800 Subject: OpenDocument: Skip raw HTML. Previously it was erroneously included as verbatim text. Closes #1035. --- src/Text/Pandoc/Writers/OpenDocument.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index b38d250aa..565f5f869 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -376,8 +376,8 @@ inlineToOpenDocument o ils | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s | Math t s <- ils = inlinesToOpenDocument o (readTeXMath' t s) | Cite _ l <- ils = inlinesToOpenDocument o l - | RawInline f s <- ils = if f == "opendocument" || f == "html" - then withTextStyle Pre $ inTextStyle $ preformatted s + | RawInline f s <- ils = if f == "opendocument" + then return $ preformatted s else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l | Image _ (s,t) <- ils = return $ mkImg s t -- cgit v1.2.3 From d07dc971da0123149e751dff987cf9df1a55b75d Mon Sep 17 00:00:00 2001 From: "Shaun Attfield (shaun@victor)" <heurist+git@gmail.com> Date: Mon, 18 Nov 2013 11:53:13 +0200 Subject: Epub Writer: Add cover reference to guide element Fixes an issue with calibre http://calibre-ebook.com/ putting the cover at the end of the book if the spine has linear="no". Apparently this is best practice for other converters as well. http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.6 --- src/Text/Pandoc/Writers/EPUB.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index ac0e7610c..ca69a0fd4 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -260,8 +260,10 @@ writeEPUB opts doc@(Pandoc meta _) = do else "no")] $ ()) : map chapterRefNode chapterEntries) , unode "guide" $ - unode "reference" ! - [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ () + [ unode "reference" ! + [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ () ] + ++ [ unode "reference" ! + [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () ] ] let contentsEntry = mkEntry "content.opf" contentsData -- cgit v1.2.3 From 5b27480e54f4ecfc145bde133f1f51865d9b12a0 Mon Sep 17 00:00:00 2001 From: "Shaun Attfield (shaun@victor)" <heurist+git@gmail.com> Date: Tue, 19 Nov 2013 08:20:27 +0200 Subject: Epub Writer: Add cover reference to guide element (v2) Avoiding an unnecessary list concatenation. Fixes an issue with calibre http://calibre-ebook.com/ putting the cover at the end of the book if the spine has linear="no". Apparently this is best practice for other converters as well. http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.6 --- src/Text/Pandoc/Writers/EPUB.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index ca69a0fd4..be8de7073 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -260,10 +260,11 @@ writeEPUB opts doc@(Pandoc meta _) = do else "no")] $ ()) : map chapterRefNode chapterEntries) , unode "guide" $ - [ unode "reference" ! - [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ () ] - ++ [ unode "reference" ! - [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () ] + [ unode "reference" ! + [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ () + , unode "reference" ! + [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () + ] ] let contentsEntry = mkEntry "content.opf" contentsData -- cgit v1.2.3 From c226a57eaa7f1e9d4782c7ea3b56e72251a6487a Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 19 Nov 2013 12:01:52 -0800 Subject: Docbook writer: Hierarchicalize block content in metadata. Previously headers just disappeared from block-level metadata when it was used in templates. Now we apply the 'hierarchicalize' transformation. Note that a block headed by a level-2 header will turn into a `<sect1>` element. --- src/Text/Pandoc/Writers/Docbook.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index dad83d7bb..02d875be3 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -85,8 +85,9 @@ writeDocbook opts (Pandoc meta blocks) = auths' = map (authorToDocbook opts) $ docAuthors meta meta' = B.setMeta "author" auths' meta Just metadata = metaToJSON opts - (Just . render colwidth . blocksToDocbook opts) - (Just . render colwidth . inlinesToDocbook opts) + (Just . render colwidth . (vcat . + (map (elementToDocbook opts' startLvl)) . hierarchicalize)) + (Just . render colwidth . inlinesToDocbook opts') meta' main = render' $ vcat (map (elementToDocbook opts' startLvl) elements) context = defField "body" main -- cgit v1.2.3 From 3d453f096cfa12e231c5a4d4c8e468378e20e5e8 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 19 Nov 2013 13:16:31 -0800 Subject: Docx writer: Use mime type info returned by fetchItem. --- src/Text/Pandoc/Writers/Docx.hs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 5d1647844..b9c198a78 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -55,8 +55,8 @@ import Data.Unique (hashUnique, newUnique) import System.Random (randomRIO) import Text.Printf (printf) import qualified Control.Exception as E -import System.FilePath (takeExtension) -import Text.Pandoc.MIME (getMimeType) +import Text.Pandoc.MIME (getMimeType, extensionFromMimeType) +import Control.Applicative ((<|>)) data WriterState = WriterState{ stTextProperties :: [Element] @@ -737,7 +737,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..." -- emit alt text inlinesToOpenXML opts alt - Right (img, _) -> do + Right (img, mt) -> do ident <- ("rId"++) `fmap` getUniqueId let size = imageSize img let (xpt,ypt) = maybe (120,120) sizeInPoints size @@ -776,19 +776,21 @@ inlineToOpenXML opts (Image alt (src, tit)) = do , mknode "wp:effectExtent" [("b","0"),("l","0"),("r","0"),("t","0")] () , mknode "wp:docPr" [("descr",tit),("id","1"),("name","Picture")] () , graphic ] - let imgext = case imageType img of - Just Png -> ".png" - Just Jpeg -> ".jpeg" - Just Gif -> ".gif" - Just Pdf -> ".pdf" - Just Eps -> ".eps" - Nothing -> takeExtension src + let imgext = case mt >>= extensionFromMimeType of + Just x -> '.':x + Nothing -> case imageType img of + Just Png -> ".png" + Just Jpeg -> ".jpeg" + Just Gif -> ".gif" + Just Pdf -> ".pdf" + Just Eps -> ".eps" + Nothing -> "" if null imgext then -- without an extension there is no rule for content type inlinesToOpenXML opts alt -- return alt to avoid corrupted docx else do let imgpath = "media/" ++ ident ++ imgext - let mbMimeType = getMimeType imgpath + let mbMimeType = mt <|> getMimeType imgpath -- insert mime type to use in constructing [Content_Types].xml modify $ \st -> st{ stImages = M.insert src (ident, imgpath, mbMimeType, imgElt, img) -- cgit v1.2.3 From 526762bf222dbab199f6ff90c925fe18535c698f Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 22 Nov 2013 19:51:07 -0800 Subject: ConTeXt writer: Use setupcaption to separate style from content. Instead of adding 'nunumber' every time we place a figure... Closes #1067. --- data/templates | 2 +- src/Text/Pandoc/Writers/ConTeXt.hs | 2 +- tests/writer.context | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/data/templates b/data/templates index 4bdebc73b..8cadd4f20 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 4bdebc73b0b2025cf01704e7e564088c34d8f86c +Subproject commit 8cadd4f2044c0c25842eeb5a2370a6e3384f4bd4 diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 0379f8b0a..179d9bc5b 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -130,7 +130,7 @@ blockToConTeXt (Plain lst) = inlineListToConTeXt lst -- title beginning with fig: indicates that the image is a figure blockToConTeXt (Para [Image txt (src,'f':'i':'g':':':_)]) = do capt <- inlineListToConTeXt txt - return $ blankline $$ "\\placefigure[here,nonumber]" <> braces capt <> + return $ blankline $$ "\\placefigure[here]" <> braces capt <> braces ("\\externalfigure" <> brackets (text src)) <> blankline blockToConTeXt (Para lst) = do contents <- inlineListToConTeXt lst diff --git a/tests/writer.context b/tests/writer.context index 114d00b3c..fb95f5615 100644 --- a/tests/writer.context +++ b/tests/writer.context @@ -30,6 +30,8 @@ \setupitemize[autointro] % prevent orphan list intro \setupitemize[indentnext=no] +\setupcaption[figure][number=no] % don't number figures + \setupthinrules[width=15em] % width of horizontal rules \setupdelimitedtext @@ -842,7 +844,7 @@ or here: <http://example.com/> From \quotation{Voyage dans la Lune} by Georges Melies (1902): -\placefigure[here,nonumber]{lalune}{\externalfigure[lalune.jpg]} +\placefigure[here]{lalune}{\externalfigure[lalune.jpg]} Here is a movie {\externalfigure[movie.jpg]} icon. -- cgit v1.2.3 From 4321a09b7fa5b52e72aef4fa637392d7da4eb808 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 22 Nov 2013 23:36:19 -0800 Subject: EPUB writer: Ensure that same identifier is used throughout. If dc:identifier is given in metadata, we use that; otherwise we use a random uuid. Closes #1044. --- src/Text/Pandoc/Writers/EPUB.hs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index be8de7073..98f043cd8 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -198,7 +198,12 @@ writeEPUB opts doc@(Pandoc meta _) = do let lang = case lookup "lang" (writerVariables opts') of Just x -> x Nothing -> localeLang - uuid <- getRandomUUID + let userNodes = onlyElems $ parseXML $ writerEpubMetadata opts' + let mbIdent = findElement (QName "identifier" Nothing (Just "dc")) + $ unode "dummy" ! [] $ userNodes + uuid <- case mbIdent of + Just id' -> return $ trim $ strContent id' + Nothing -> fmap show getRandomUUID let chapterNode ent = unode "item" ! ([("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), @@ -230,7 +235,7 @@ writeEPUB opts doc@(Pandoc meta _) = do EPUB3 -> "3.0") ,("xmlns","http://www.idpf.org/2007/opf") ,("unique-identifier","BookId")] $ - [ metadataElement version (writerEpubMetadata opts') + [ metadataElement version userNodes uuid lang plainTitle plainAuthors plainDate currentTime mbCoverImage , unode "manifest" $ [ unode "item" ! [("id","ncx"), ("href","toc.ncx") @@ -311,7 +316,7 @@ writeEPUB opts doc@(Pandoc meta _) = do ,("xmlns","http://www.daisy.org/z3986/2005/ncx/")] $ [ unode "head" $ [ unode "meta" ! [("name","dtb:uid") - ,("content", show uuid)] $ () + ,("content", uuid)] $ () , unode "meta" ! [("name","dtb:depth") ,("content", "1")] $ () , unode "meta" ! [("name","dtb:totalPageCount") @@ -384,13 +389,12 @@ writeEPUB opts doc@(Pandoc meta _) = do (picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries ++ fontEntries)) return $ fromArchive archive -metadataElement :: EPUBVersion -> String -> UUID -> String -> String -> [String] +metadataElement :: EPUBVersion -> [Element] -> String -> String -> String -> [String] -> String -> UTCTime -> Maybe a -> Element -metadataElement version metadataXML uuid lang title authors date currentTime mbCoverImage = - let userNodes = parseXML metadataXML - elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/") +metadataElement version userNodes uuid lang title authors date currentTime mbCoverImage = + let elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/") ,("xmlns:opf","http://www.idpf.org/2007/opf")] $ - filter isMetadataElement $ onlyElems userNodes + filter isMetadataElement userNodes dublinElements = ["contributor","coverage","creator","date", "description","format","identifier","language","publisher", "relation","rights","source","subject","title","type"] @@ -401,7 +405,7 @@ metadataElement version metadataXML uuid lang title authors date currentTime mbC contains e n = not (null (findElements (QName n Nothing (Just "dc")) e)) newNodes = [ unode "dc:title" title | not (elt `contains` "title") ] ++ [ unode "dc:language" lang | not (elt `contains` "language") ] ++ - [ unode "dc:identifier" ! [("id","BookId")] $ show uuid | + [ unode "dc:identifier" ! [("id","BookId")] $ uuid | not (elt `contains` "identifier") ] ++ [ unode "dc:creator" ! [("opf:role","aut") | version == EPUB2] $ a | a <- authors, not (elt `contains` "creator") ] ++ -- cgit v1.2.3 From 56277bacea73818a7541b60987e5bc877782baab Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 22 Nov 2013 23:40:46 -0800 Subject: EPUB writer: Don't include node for cover.xhtml if no cover! --- src/Text/Pandoc/Writers/EPUB.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 98f043cd8..ef4c7be23 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -267,8 +267,9 @@ writeEPUB opts doc@(Pandoc meta _) = do , unode "guide" $ [ unode "reference" ! [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ () - , unode "reference" ! - [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () + ] ++ + [ unode "reference" ! + [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | mbCoverImage /= Nothing ] ] let contentsEntry = mkEntry "content.opf" contentsData -- cgit v1.2.3 From c1ff65e5ef0b5b8d78149cf666cda1de4a0e4fdb Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 23 Nov 2013 14:24:33 -0800 Subject: HTML writer: Handle csl flipflopping spans (csl-no-emph, etc.) --- src/Text/Pandoc/Writers/HTML.hs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 424843539..641652276 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -613,8 +613,22 @@ inlineToHtml opts inline = (Str str) -> return $ strToHtml str (Space) -> return $ strToHtml " " (LineBreak) -> return $ if writerHtml5 opts then H5.br else H.br - (Span attr ils) -> inlineListToHtml opts ils >>= - return . addAttrs opts attr . H.span + (Span (id',classes,kvs) ils) + -> inlineListToHtml opts ils >>= + return . addAttrs opts attr' . H.span + where attr' = (id',classes',kvs') + classes' = filter (`notElem` ["csl-no-emph", + "csl-no-strong", + "csl-no-smallcaps"]) classes + kvs' = if null styles + then kvs + else (("style", concat styles) : kvs) + styles = ["font-style:normal;" + | "csl-no-emph" `elem` classes] + ++ ["font-weight:normal;" + | "csl-no-strong" `elem` classes] + ++ ["font-variant:normal;" + | "csl-no-smallcaps" `elem` classes] (Emph lst) -> inlineListToHtml opts lst >>= return . H.em (Strong lst) -> inlineListToHtml opts lst >>= return . H.strong (Code attr str) -> case hlCode of -- cgit v1.2.3 From b82ef0e29a652b7e1629b6e2e5f56140ed08e633 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 23 Nov 2013 14:41:22 -0800 Subject: LaTeX writer: Handle csl flipflopping spans (csl-no-emph, etc.) --- src/Text/Pandoc/Writers/LaTeX.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 7ff64cf74..f3cbcf19f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -602,7 +602,16 @@ isQuoted _ = False -- | Convert inline element to LaTeX inlineToLaTeX :: Inline -- ^ Inline to convert -> State WriterState Doc -inlineToLaTeX (Span _ ils) = inlineListToLaTeX ils >>= return . braces +inlineToLaTeX (Span (_,classes,_) ils) = do + let noEmph = "csl-no-emph" `elem` classes + let noStrong = "csl-no-strong" `elem` classes + let noSmallCaps = "csl-no-smallcaps" `elem` classes + ((if noEmph then inCmd "textup" else id) . + (if noStrong then inCmd "textnormal" else id) . + (if noSmallCaps then inCmd "textnormal" else id) . + (if not (noEmph || noStrong || noSmallCaps) + then braces + else id)) `fmap` inlineListToLaTeX ils inlineToLaTeX (Emph lst) = inlineListToLaTeX lst >>= return . inCmd "emph" inlineToLaTeX (Strong lst) = -- cgit v1.2.3 From e1a9a61774cce807c6db2fff7b8609b2d9dbc678 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 23 Nov 2013 14:52:14 -0800 Subject: Docx writer: Implemented csl flipflopping spans. --- src/Text/Pandoc/Writers/Docx.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index b9c198a78..5c7341b69 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -638,7 +638,12 @@ formattedString str = do inlineToOpenXML :: WriterOptions -> Inline -> WS [Element] inlineToOpenXML _ (Str str) = formattedString str inlineToOpenXML opts Space = inlineToOpenXML opts (Str " ") -inlineToOpenXML opts (Span _ ils) = inlinesToOpenXML opts ils +inlineToOpenXML opts (Span (_,classes,_) ils) = do + let off x = withTextProp (mknode x [("w:val","0")] ()) + ((if "csl-no-emph" `elem` classes then off "w:i" else id) . + (if "csl-no-strong" `elem` classes then off "w:b" else id) . + (if "csl-no-smallcaps" `elem` classes then off "w:smallCaps" else id)) + $ inlinesToOpenXML opts ils inlineToOpenXML opts (Strong lst) = withTextProp (mknode "w:b" [] ()) $ inlinesToOpenXML opts lst inlineToOpenXML opts (Emph lst) = -- cgit v1.2.3 From 659596876b74a2ce99ec5f7253962b27ca091354 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 29 Nov 2013 18:01:07 -0800 Subject: EPUB writer: Improved metadata handling. * Metadata may now be included in YAML blocks in a markdown document. For example, --- title: - type: main text: My Book - type: subtitle text: An investigation of metadata creator: - role: author text: John Smith - role: editor text: Sarah Jones identifier: - scheme: DOI text: doi:10.234234.234/33 publisher: My Press rights: (c) 2007 John Smith, CC BY-NC ... * Metadata may still be provided using `--epub-metadata`; it will be merged with the metadata in YAML blocks. * meta tags are used instead of opf attributes for EPUB3. --- src/Text/Pandoc/Writers/EPUB.hs | 642 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 591 insertions(+), 51 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index ef4c7be23..4f1de5df0 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE PatternGuards, CPP #-} +{-# LANGUAGE PatternGuards, CPP, ScopedTypeVariables #-} {- Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu> @@ -30,7 +30,8 @@ Conversion of 'Pandoc' documents to EPUB. -} module Text.Pandoc.Writers.EPUB ( writeEPUB ) where import Data.IORef -import Data.Maybe ( fromMaybe, isNothing ) +import qualified Data.Map as M +import Data.Maybe ( fromMaybe ) import Data.List ( isInfixOf, intercalate ) import System.Environment ( getEnv ) import Text.Printf (printf) @@ -40,6 +41,7 @@ import qualified Data.ByteString.Lazy.Char8 as B8 import Text.Pandoc.UTF8 ( fromStringLazy, toString ) import Text.Pandoc.SelfContained ( makeSelfContained ) import Codec.Archive.Zip +import Control.Applicative ((<$>)) import Data.Time.Clock.POSIX import Data.Time import System.Locale @@ -70,6 +72,216 @@ import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -- in filenames, chapter0003.xhtml. data Chapter = Chapter (Maybe [Int]) [Block] +data EPUBMetadata = EPUBMetadata{ + epubIdentifier :: [Identifier] + , epubTitle :: [Title] + , epubDate :: String + , epubLanguage :: String + , epubCreator :: [Creator] + , epubContributor :: [Creator] + , epubSubject :: [String] + , epubDescription :: Maybe String + , epubType :: Maybe String + , epubFormat :: Maybe String + , epubPublisher :: Maybe String + , epubSource :: Maybe String + , epubRelation :: Maybe String + , epubCoverage :: Maybe String + , epubRights :: Maybe String + , epubCoverImage :: Maybe String + } deriving Show + +data Creator = Creator{ + creatorText :: String + , creatorRole :: Maybe String + , creatorFileAs :: Maybe String + } deriving Show + +data Identifier = Identifier{ + identifierText :: String + , identifierScheme :: Maybe String + } deriving Show + +data Title = Title{ + titleText :: String + , titleFileAs :: Maybe String + , titleType :: Maybe String + } deriving Show + +dcName :: String -> QName +dcName n = QName n Nothing (Just "dc") + +dcNode :: Node t => String -> t -> Element +dcNode = node . dcName + +opfName :: String -> QName +opfName n = QName n Nothing (Just "opf") + +plainify :: [Inline] -> String +plainify t = + trimr $ writePlain def{ writerStandalone = False } $ Pandoc nullMeta [Plain t] + +getEPUBMetadata :: WriterOptions -> Meta -> IO EPUBMetadata +getEPUBMetadata opts meta = do + let md = metadataFromMeta opts meta + let elts = onlyElems $ parseXML $ writerEpubMetadata opts + let md' = foldr addMetadataFromXML md elts + let addIdentifier m = + if null (epubIdentifier m) + then do + randomId <- fmap show getRandomUUID + return $ m{ epubIdentifier = [Identifier randomId Nothing] } + else return m + let addLanguage m = + if null (epubLanguage m) + then case lookup "lang" (writerVariables opts) of + Just x -> return m{ epubLanguage = x } + Nothing -> do + localeLang <- catch (liftM + (map (\c -> if c == '_' then '-' else c) . + takeWhile (/='.')) $ getEnv "LANG") + (\e -> let _ = (e :: SomeException) in return "en-US") + return m{ epubLanguage = localeLang } + else return m + let fixDate m = + if null (epubDate m) + then do + currentTime <- getCurrentTime + return $ m{ epubDate = showDateTimeISO8601 currentTime } + else return m + let addAuthor m = + if any (\c -> creatorRole c == Just "aut") $ epubCreator m + then return m + else do + let authors' = map plainify $ docAuthors meta + let toAuthor name = Creator{ creatorText = name + , creatorRole = Just "aut" + , creatorFileAs = Nothing } + return $ m{ epubCreator = map toAuthor authors' ++ epubCreator m } + addIdentifier md' >>= fixDate >>= addAuthor >>= addLanguage + +addMetadataFromXML :: Element -> EPUBMetadata -> EPUBMetadata +addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md + | name == "identifier" = md{ epubIdentifier = + Identifier{ identifierText = strContent e + , identifierScheme = lookupAttr (opfName "scheme") attrs + } : epubIdentifier md } + | name == "title" = md{ epubTitle = + Title{ titleText = strContent e + , titleFileAs = getAttr "file-as" + , titleType = getAttr "type" + } : epubTitle md } + | name == "date" = md{ epubDate = maybe "" id $ normalizeDate $ strContent e } + | name == "language" = md{ epubLanguage = strContent e } + | name == "creator" = md{ epubCreator = + Creator{ creatorText = strContent e + , creatorRole = getAttr "role" + , creatorFileAs = getAttr "file-as" + } : epubCreator md } + | name == "contributor" = md{ epubContributor = + Creator { creatorText = strContent e + , creatorRole = getAttr "role" + , creatorFileAs = getAttr "file-as" + } : epubContributor md } + | name == "subject" = md{ epubSubject = strContent e : epubSubject md } + | name == "description" = md { epubDescription = Just $ strContent e } + | name == "type" = md { epubType = Just $ strContent e } + | name == "format" = md { epubFormat = Just $ strContent e } + | name == "type" = md { epubType = Just $ strContent e } + | name == "publisher" = md { epubPublisher = Just $ strContent e } + | name == "source" = md { epubSource = Just $ strContent e } + | name == "relation" = md { epubRelation = Just $ strContent e } + | name == "coverage" = md { epubCoverage = Just $ strContent e } + | name == "rights" = md { epubRights = Just $ strContent e } + | otherwise = md + where getAttr n = lookupAttr (opfName n) attrs +addMetadataFromXML _ md = md + +metaValueToString :: MetaValue -> String +metaValueToString (MetaString s) = s +metaValueToString (MetaInlines ils) = plainify ils +metaValueToString (MetaBlocks bs) = plainify $ query (:[]) bs +metaValueToString (MetaBool b) = show b +metaValueToString _ = "" + +getList :: String -> Meta -> (MetaValue -> a) -> [a] +getList s meta handleMetaValue = + case lookupMeta s meta of + Just (MetaList xs) -> map handleMetaValue xs + Just mv -> [handleMetaValue mv] + Nothing -> [] + +getIdentifier :: Meta -> [Identifier] +getIdentifier meta = getList "identifier" meta handleMetaValue + where handleMetaValue (MetaMap m) = + Identifier{ identifierText = maybe "" metaValueToString + $ M.lookup "text" m + , identifierScheme = metaValueToString <$> + M.lookup "scheme" m } + handleMetaValue mv = Identifier (metaValueToString mv) Nothing + +getTitle :: Meta -> [Title] +getTitle meta = getList "title" meta handleMetaValue + where handleMetaValue (MetaMap m) = + Title{ titleText = maybe "" metaValueToString $ M.lookup "text" m + , titleFileAs = metaValueToString <$> M.lookup "file-as" m + , titleType = metaValueToString <$> M.lookup "type" m } + handleMetaValue mv = Title (metaValueToString mv) Nothing Nothing + +getCreator :: String -> Meta -> [Creator] +getCreator s meta = getList s meta handleMetaValue + where handleMetaValue (MetaMap m) = + Creator{ creatorText = maybe "" metaValueToString $ M.lookup "text" m + , creatorFileAs = metaValueToString <$> M.lookup "file-as" m + , creatorRole = metaValueToString <$> M.lookup "role" m } + handleMetaValue mv = Creator (metaValueToString mv) Nothing Nothing + +simpleList :: String -> Meta -> [String] +simpleList s meta = + case lookupMeta s meta of + Just (MetaList xs) -> map metaValueToString xs + Just x -> [metaValueToString x] + Nothing -> [] + +metadataFromMeta :: WriterOptions -> Meta -> EPUBMetadata +metadataFromMeta opts meta = EPUBMetadata{ + epubIdentifier = identifiers + , epubTitle = titles + , epubDate = date + , epubLanguage = language + , epubCreator = creators + , epubContributor = contributors + , epubSubject = subjects + , epubDescription = description + , epubType = epubtype + , epubFormat = format + , epubPublisher = publisher + , epubSource = source + , epubRelation = relation + , epubCoverage = coverage + , epubRights = rights + , epubCoverImage = coverImage + } + where identifiers = getIdentifier meta + titles = getTitle meta + date = maybe "" id $ + (metaValueToString <$> lookupMeta "date" meta) >>= normalizeDate + language = maybe "" metaValueToString $ + lookupMeta "language" meta `mplus` lookupMeta "lang" meta + creators = getCreator "creator" meta + contributors = getCreator "contributor" meta + subjects = simpleList "subject" meta + description = metaValueToString <$> lookupMeta "description" meta + epubtype = metaValueToString <$> lookupMeta "type" meta + format = metaValueToString <$> lookupMeta "format" meta + publisher = metaValueToString <$> lookupMeta "publisher" meta + source = metaValueToString <$> lookupMeta "source" meta + relation = metaValueToString <$> lookupMeta "relation" meta + coverage = metaValueToString <$> lookupMeta "coverage" meta + rights = metaValueToString <$> lookupMeta "rights" meta + coverImage = fmap (const "cover-image") $ + lookup "epub-cover-image" $ writerVariables opts + -- | Produce an EPUB file from a Pandoc document. writeEPUB :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert @@ -192,18 +404,6 @@ writeEPUB opts doc@(Pandoc meta _) = do let containsMathML ent = "<math" `isInfixOf` (B8.unpack $ fromEntry ent) -- contents.opf - localeLang <- catch (liftM (map (\c -> if c == '_' then '-' else c) . - takeWhile (/='.')) $ getEnv "LANG") - (\e -> let _ = (e :: SomeException) in return "en-US") - let lang = case lookup "lang" (writerVariables opts') of - Just x -> x - Nothing -> localeLang - let userNodes = onlyElems $ parseXML $ writerEpubMetadata opts' - let mbIdent = findElement (QName "identifier" Nothing (Just "dc")) - $ unode "dummy" ! [] $ userNodes - uuid <- case mbIdent of - Just id' -> return $ trim $ strContent id' - Nothing -> fmap show getRandomUUID let chapterNode ent = unode "item" ! ([("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), @@ -221,22 +421,23 @@ writeEPUB opts doc@(Pandoc meta _) = do [("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", maybe "" id $ getMimeType $ eRelativePath ent)] $ () - let plainify t = trimr $ - writePlain opts'{ writerStandalone = False } $ - Pandoc meta [Plain t] - let plainTitle = plainify $ docTitle meta - let plainAuthors = map plainify $ docAuthors meta + metadata <- getEPUBMetadata opts' meta + let plainTitle = case docTitle meta of + [] -> case epubTitle metadata of + [] -> "UNTITLED" + (x:_) -> titleText x + x -> plainify x + let uuid = case epubIdentifier metadata of + (x:_) -> identifierText x -- use first identifier as UUID + [] -> error "epubIdentifier is null" -- shouldn't happen currentTime <- getCurrentTime - let plainDate = maybe (showDateTimeISO8601 currentTime) id - $ normalizeDate $ stringify $ docDate meta let contentsData = fromStringLazy $ ppTopElement $ unode "package" ! [("version", case version of EPUB2 -> "2.0" EPUB3 -> "3.0") ,("xmlns","http://www.idpf.org/2007/opf") - ,("unique-identifier","BookId")] $ - [ metadataElement version userNodes - uuid lang plainTitle plainAuthors plainDate currentTime mbCoverImage + ,("unique-identifier","epub-id-1")] $ + [ metadataElement version metadata currentTime , unode "manifest" $ [ unode "item" ! [("id","ncx"), ("href","toc.ncx") ,("media-type","application/x-dtbncx+xml")] $ () @@ -266,7 +467,8 @@ writeEPUB opts doc@(Pandoc meta _) = do map chapterRefNode chapterEntries) , unode "guide" $ [ unode "reference" ! - [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ () + [("type","toc"),("title",plainTitle), + ("href","nav.xhtml")] $ () ] ++ [ unode "reference" ! [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | mbCoverImage /= Nothing @@ -390,32 +592,96 @@ writeEPUB opts doc@(Pandoc meta _) = do (picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries ++ fontEntries)) return $ fromArchive archive -metadataElement :: EPUBVersion -> [Element] -> String -> String -> String -> [String] - -> String -> UTCTime -> Maybe a -> Element -metadataElement version userNodes uuid lang title authors date currentTime mbCoverImage = - let elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/") - ,("xmlns:opf","http://www.idpf.org/2007/opf")] $ - filter isMetadataElement userNodes - dublinElements = ["contributor","coverage","creator","date", - "description","format","identifier","language","publisher", - "relation","rights","source","subject","title","type"] - isMetadataElement e = (qPrefix (elName e) == Just "dc" && - qName (elName e) `elem` dublinElements) || - (qPrefix (elName e) == Nothing && - qName (elName e) `elem` ["link","meta"]) - contains e n = not (null (findElements (QName n Nothing (Just "dc")) e)) - newNodes = [ unode "dc:title" title | not (elt `contains` "title") ] ++ - [ unode "dc:language" lang | not (elt `contains` "language") ] ++ - [ unode "dc:identifier" ! [("id","BookId")] $ uuid | - not (elt `contains` "identifier") ] ++ - [ unode "dc:creator" ! [("opf:role","aut") | version == EPUB2] - $ a | a <- authors, not (elt `contains` "creator") ] ++ - [ unode "dc:date" date | not (elt `contains` "date") ] ++ - [ unode "meta" ! [("property", "dcterms:modified")] $ - (showDateTimeISO8601 currentTime) | version == EPUB3] ++ - [ unode "meta" ! [("name","cover"), ("content","cover-image")] $ () | - not (isNothing mbCoverImage) ] - in elt{ elContent = elContent elt ++ map Elem newNodes } +metadataElement :: EPUBVersion -> EPUBMetadata -> UTCTime -> Element +metadataElement version md currentTime = + unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/") + ,("xmlns:opf","http://www.idpf.org/2007/opf")] $ mdNodes + where mdNodes = identifierNodes ++ titleNodes ++ dateNodes ++ languageNodes + ++ creatorNodes ++ contributorNodes ++ subjectNodes + ++ descriptionNodes ++ typeNodes ++ formatNodes + ++ publisherNodes ++ sourceNodes ++ relationNodes + ++ coverageNodes ++ rightsNodes ++ coverImageNodes + ++ modifiedNodes + withIds base f = concat . zipWith f (map (\x -> base ++ ('-' : show x)) + ([1..] :: [Int])) + identifierNodes = withIds "epub-id" toIdentifierNode $ + epubIdentifier md + titleNodes = withIds "epub-title" toTitleNode $ epubTitle md + dateNodes = dcTag' "date" $ epubDate md + languageNodes = [dcTag "language" $ epubLanguage md] + creatorNodes = withIds "epub-creator" (toCreatorNode "creator") $ + epubCreator md + contributorNodes = withIds "epub-contributor" + (toCreatorNode "contributor") $ epubContributor md + subjectNodes = map (dcTag "subject") $ epubSubject md + descriptionNodes = maybe [] (dcTag' "description") $ epubDescription md + typeNodes = maybe [] (dcTag' "type") $ epubType md + formatNodes = maybe [] (dcTag' "format") $ epubFormat md + publisherNodes = maybe [] (dcTag' "publisher") $ epubPublisher md + sourceNodes = maybe [] (dcTag' "source") $ epubSource md + relationNodes = maybe [] (dcTag' "relation") $ epubRelation md + coverageNodes = maybe [] (dcTag' "coverage") $ epubCoverage md + rightsNodes = maybe [] (dcTag' "rights") $ epubRights md + coverImageNodes = maybe [] + (\ci -> [unode "meta" ! [("name","cover"), ("content",ci)] $ ()]) + $ epubCoverImage md + modifiedNodes = [ unode "meta" ! [("property", "dcterms:modified")] $ + (showDateTimeISO8601 currentTime) | version == EPUB3 ] + dcTag n s = unode ("dc:" ++ n) s + dcTag' n s = [dcTag n s] + toIdentifierNode id' (Identifier txt scheme) + | version == EPUB2 = [dcNode "identifier" ! + ([("id",id')] ++ maybe [] (\x -> [("opf:scheme", x)]) scheme) $ + txt] + | otherwise = [dcNode "identifier" ! [("id",id')] $ txt] ++ + maybe [] (\x -> [unode "meta" ! + [("refines",'#':id'),("property","identifier-type"), + ("scheme","onix:codelist5")] $ x]) + (schemeToOnix `fmap` scheme) + toCreatorNode s id' creator + | version == EPUB2 = [dcNode s ! + ([("id",id')] ++ + maybe [] (\x -> [("opf:file-as",x)]) (creatorFileAs creator) ++ + maybe [] (\x -> [("opf:role",x)]) + (creatorRole creator >>= toRelator)) $ creatorText creator] + | otherwise = [dcNode s ! [("id",id')] $ creatorText creator] ++ + maybe [] (\x -> [unode "meta" ! + [("refines",'#':id'),("property","file-as")] $ x]) + (creatorFileAs creator) ++ + maybe [] (\x -> [unode "meta" ! + [("refines",'#':id'),("property","role"), + ("scheme","marc:relators")] $ x]) + (creatorRole creator >>= toRelator) + toTitleNode id' title + | version == EPUB2 = [dcNode "title" ! + ([("id",id')] ++ + maybe [] (\x -> [("opf:file-as",x)]) (titleFileAs title) ++ + maybe [] (\x -> [("opf:title-type",x)]) (titleType title)) $ + titleText title] + | otherwise = [dcNode "title" ! [("id",id')] $ titleText title] + ++ + maybe [] (\x -> [unode "meta" ! + [("refines",'#':id'),("property","file-as")] $ x]) + (titleFileAs title) ++ + maybe [] (\x -> [unode "meta" ! + [("refines",'#':id'),("property","title-type")] $ x]) + (titleType title) + schemeToOnix "ISBN-10" = "02" + schemeToOnix "GTIN-13" = "03" + schemeToOnix "UPC" = "04" + schemeToOnix "ISMN-10" = "05" + schemeToOnix "DOI" = "06" + schemeToOnix "LCCN" = "13" + schemeToOnix "GTIN-14" = "14" + schemeToOnix "ISBN-13" = "15" + schemeToOnix "Legal deposit number" = "17" + schemeToOnix "URN" = "22" + schemeToOnix "OCLC" = "23" + schemeToOnix "ISMN-13" = "25" + schemeToOnix "ISBN-A" = "26" + schemeToOnix "JP" = "27" + schemeToOnix "OLCC" = "28" + schemeToOnix _ = "01" showDateTimeISO8601 :: UTCTime -> String showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ" @@ -527,3 +793,277 @@ replaceRefs refTable = walk replaceOneRef Just url -> Link lab (url,tit) Nothing -> x replaceOneRef x = x + +toRelator :: String -> Maybe String +toRelator x + | x `elem` relators = Just x + | otherwise = lookup (map toLower x) relatorMap + +relators :: [String] +relators = map snd relatorMap + +relatorMap :: [(String, String)] +relatorMap = + [("abridger", "abr") + ,("actor", "act") + ,("adapter", "adp") + ,("addressee", "rcp") + ,("analyst", "anl") + ,("animator", "anm") + ,("annotator", "ann") + ,("appellant", "apl") + ,("appellee", "ape") + ,("applicant", "app") + ,("architect", "arc") + ,("arranger", "arr") + ,("art copyist", "acp") + ,("art director", "adi") + ,("artist", "art") + ,("artistic director", "ard") + ,("assignee", "asg") + ,("associated name", "asn") + ,("attributed name", "att") + ,("auctioneer", "auc") + ,("author", "aut") + ,("author in quotations or text abstracts", "aqt") + ,("author of afterword, colophon, etc.", "aft") + ,("author of dialog", "aud") + ,("author of introduction, etc.", "aui") + ,("autographer", "ato") + ,("bibliographic antecedent", "ant") + ,("binder", "bnd") + ,("binding designer", "bdd") + ,("blurb writer", "blw") + ,("book designer", "bkd") + ,("book producer", "bkp") + ,("bookjacket designer", "bjd") + ,("bookplate designer", "bpd") + ,("bookseller", "bsl") + ,("braille embosser", "brl") + ,("broadcaster", "brd") + ,("calligrapher", "cll") + ,("cartographer", "ctg") + ,("caster", "cas") + ,("censor", "cns") + ,("choreographer", "chr") + ,("cinematographer", "cng") + ,("client", "cli") + ,("collection registrar", "cor") + ,("collector", "col") + ,("collotyper", "clt") + ,("colorist", "clr") + ,("commentator", "cmm") + ,("commentator for written text", "cwt") + ,("compiler", "com") + ,("complainant", "cpl") + ,("complainant-appellant", "cpt") + ,("complainant-appellee", "cpe") + ,("composer", "cmp") + ,("compositor", "cmt") + ,("conceptor", "ccp") + ,("conductor", "cnd") + ,("conservator", "con") + ,("consultant", "csl") + ,("consultant to a project", "csp") + ,("contestant", "cos") + ,("contestant-appellant", "cot") + ,("contestant-appellee", "coe") + ,("contestee", "cts") + ,("contestee-appellant", "ctt") + ,("contestee-appellee", "cte") + ,("contractor", "ctr") + ,("contributor", "ctb") + ,("copyright claimant", "cpc") + ,("copyright holder", "cph") + ,("corrector", "crr") + ,("correspondent", "crp") + ,("costume designer", "cst") + ,("court governed", "cou") + ,("court reporter", "crt") + ,("cover designer", "cov") + ,("creator", "cre") + ,("curator", "cur") + ,("dancer", "dnc") + ,("data contributor", "dtc") + ,("data manager", "dtm") + ,("dedicatee", "dte") + ,("dedicator", "dto") + ,("defendant", "dfd") + ,("defendant-appellant", "dft") + ,("defendant-appellee", "dfe") + ,("degree granting institution", "dgg") + ,("delineator", "dln") + ,("depicted", "dpc") + ,("depositor", "dpt") + ,("designer", "dsr") + ,("director", "drt") + ,("dissertant", "dis") + ,("distribution place", "dbp") + ,("distributor", "dst") + ,("donor", "dnr") + ,("draftsman", "drm") + ,("dubious author", "dub") + ,("editor", "edt") + ,("editor of compilation", "edc") + ,("editor of moving image work", "edm") + ,("electrician", "elg") + ,("electrotyper", "elt") + ,("enacting jurisdiction", "enj") + ,("engineer", "eng") + ,("engraver", "egr") + ,("etcher", "etr") + ,("event place", "evp") + ,("expert", "exp") + ,("facsimilist", "fac") + ,("field director", "fld") + ,("film director", "fmd") + ,("film distributor", "fds") + ,("film editor", "flm") + ,("film producer", "fmp") + ,("filmmaker", "fmk") + ,("first party", "fpy") + ,("forger", "frg") + ,("former owner", "fmo") + ,("funder", "fnd") + ,("geographic information specialist", "gis") + ,("honoree", "hnr") + ,("host", "hst") + ,("host institution", "his") + ,("illuminator", "ilu") + ,("illustrator", "ill") + ,("inscriber", "ins") + ,("instrumentalist", "itr") + ,("interviewee", "ive") + ,("interviewer", "ivr") + ,("inventor", "inv") + ,("issuing body", "isb") + ,("judge", "jud") + ,("jurisdiction governed", "jug") + ,("laboratory", "lbr") + ,("laboratory director", "ldr") + ,("landscape architect", "lsa") + ,("lead", "led") + ,("lender", "len") + ,("libelant", "lil") + ,("libelant-appellant", "lit") + ,("libelant-appellee", "lie") + ,("libelee", "lel") + ,("libelee-appellant", "let") + ,("libelee-appellee", "lee") + ,("librettist", "lbt") + ,("licensee", "lse") + ,("licensor", "lso") + ,("lighting designer", "lgd") + ,("lithographer", "ltg") + ,("lyricist", "lyr") + ,("manufacture place", "mfp") + ,("manufacturer", "mfr") + ,("marbler", "mrb") + ,("markup editor", "mrk") + ,("metadata contact", "mdc") + ,("metal-engraver", "mte") + ,("moderator", "mod") + ,("monitor", "mon") + ,("music copyist", "mcp") + ,("musical director", "msd") + ,("musician", "mus") + ,("narrator", "nrt") + ,("onscreen presenter", "osp") + ,("opponent", "opn") + ,("organizer of meeting", "orm") + ,("originator", "org") + ,("other", "oth") + ,("owner", "own") + ,("panelist", "pan") + ,("papermaker", "ppm") + ,("patent applicant", "pta") + ,("patent holder", "pth") + ,("patron", "pat") + ,("performer", "prf") + ,("permitting agency", "pma") + ,("photographer", "pht") + ,("plaintiff", "ptf") + ,("plaintiff-appellant", "ptt") + ,("plaintiff-appellee", "pte") + ,("platemaker", "plt") + ,("praeses", "pra") + ,("presenter", "pre") + ,("printer", "prt") + ,("printer of plates", "pop") + ,("printmaker", "prm") + ,("process contact", "prc") + ,("producer", "pro") + ,("production company", "prn") + ,("production designer", "prs") + ,("production manager", "pmn") + ,("production personnel", "prd") + ,("production place", "prp") + ,("programmer", "prg") + ,("project director", "pdr") + ,("proofreader", "pfr") + ,("provider", "prv") + ,("publication place", "pup") + ,("publisher", "pbl") + ,("publishing director", "pbd") + ,("puppeteer", "ppt") + ,("radio director", "rdd") + ,("radio producer", "rpc") + ,("recording engineer", "rce") + ,("recordist", "rcd") + ,("redaktor", "red") + ,("renderer", "ren") + ,("reporter", "rpt") + ,("repository", "rps") + ,("research team head", "rth") + ,("research team member", "rtm") + ,("researcher", "res") + ,("respondent", "rsp") + ,("respondent-appellant", "rst") + ,("respondent-appellee", "rse") + ,("responsible party", "rpy") + ,("restager", "rsg") + ,("restorationist", "rsr") + ,("reviewer", "rev") + ,("rubricator", "rbr") + ,("scenarist", "sce") + ,("scientific advisor", "sad") + ,("screenwriter", "aus") + ,("scribe", "scr") + ,("sculptor", "scl") + ,("second party", "spy") + ,("secretary", "sec") + ,("seller", "sll") + ,("set designer", "std") + ,("setting", "stg") + ,("signer", "sgn") + ,("singer", "sng") + ,("sound designer", "sds") + ,("speaker", "spk") + ,("sponsor", "spn") + ,("stage director", "sgd") + ,("stage manager", "stm") + ,("standards body", "stn") + ,("stereotyper", "str") + ,("storyteller", "stl") + ,("supporting host", "sht") + ,("surveyor", "srv") + ,("teacher", "tch") + ,("technical director", "tcd") + ,("television director", "tld") + ,("television producer", "tlp") + ,("thesis advisor", "ths") + ,("transcriber", "trc") + ,("translator", "trl") + ,("type designer", "tyd") + ,("typographer", "tyg") + ,("university place", "uvp") + ,("videographer", "vdg") + ,("witness", "wit") + ,("wood engraver", "wde") + ,("woodcutter", "wdc") + ,("writer of accompanying material", "wam") + ,("writer of added commentary", "wac") + ,("writer of added lyrics", "wal") + ,("writer of added text", "wat") + ] + -- cgit v1.2.3 From 96b678d823b544e3da7dd8531615c52de6164cb8 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 15:17:38 -0800 Subject: Allow specification of epub-cover-image in YAML metadata. --- README | 6 +++++- src/Text/Pandoc/Writers/EPUB.hs | 17 ++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 3afbe8b0b..35194769b 100644 --- a/README +++ b/README @@ -541,7 +541,9 @@ Options affecting specific writers `--epub-cover-image=`*FILE* : Use the specified image as the EPUB cover. It is recommended - that the image be less than 1000px in width and height. + that the image be less than 1000px in width and height. Note that + in a markdown source document you can also specify `epub-cover-image` + in a YAML metadata block (see [EPUB Metadata], below). `--epub-metadata=`*FILE* : Look in the specified XML file for metadata for the EPUB. @@ -2818,6 +2820,8 @@ The following fields are recognized: ~ A string value. `rights` ~ A string value. +`epub-cover-image` + ~ A string value (path to cover image). Literate Haskell support ======================== diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 4f1de5df0..a3b01848e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -279,8 +279,7 @@ metadataFromMeta opts meta = EPUBMetadata{ relation = metaValueToString <$> lookupMeta "relation" meta coverage = metaValueToString <$> lookupMeta "coverage" meta rights = metaValueToString <$> lookupMeta "rights" meta - coverImage = fmap (const "cover-image") $ - lookup "epub-cover-image" $ writerVariables opts + coverImage = lookup "epub-cover-image" (writerVariables opts) -- | Produce an EPUB file from a Pandoc document. writeEPUB :: WriterOptions -- ^ Writer options @@ -305,11 +304,11 @@ writeEPUB opts doc@(Pandoc meta _) = do then MathML Nothing else writerHTMLMathMethod opts , writerWrapText = False } - let mbCoverImage = lookup "epub-cover-image" vars + metadata <- getEPUBMetadata opts' meta -- cover page (cpgEntry, cpicEntry) <- - case mbCoverImage of + case epubCoverImage metadata of Nothing -> return ([],[]) Just img -> do let coverImage = "cover-image" ++ takeExtension img @@ -421,7 +420,6 @@ writeEPUB opts doc@(Pandoc meta _) = do [("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", maybe "" id $ getMimeType $ eRelativePath ent)] $ () - metadata <- getEPUBMetadata opts' meta let plainTitle = case docTitle meta of [] -> case epubTitle metadata of [] -> "UNTITLED" @@ -452,7 +450,7 @@ writeEPUB opts doc@(Pandoc meta _) = do map pictureNode (cpicEntry ++ picEntries) ++ map fontNode fontEntries , unode "spine" ! [("toc","ncx")] $ - case mbCoverImage of + case epubCoverImage metadata of Nothing -> [] Just _ -> [ unode "itemref" ! [("idref", "cover"),("linear","no")] $ () ] @@ -471,7 +469,7 @@ writeEPUB opts doc@(Pandoc meta _) = do ("href","nav.xhtml")] $ () ] ++ [ unode "reference" ! - [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | mbCoverImage /= Nothing + [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | epubCoverImage metadata /= Nothing ] ] let contentsEntry = mkEntry "content.opf" contentsData @@ -526,7 +524,7 @@ writeEPUB opts doc@(Pandoc meta _) = do ,("content", "0")] $ () , unode "meta" ! [("name","dtb:maxPageNumber") ,("content", "0")] $ () - ] ++ case mbCoverImage of + ] ++ case epubCoverImage metadata of Nothing -> [] Just _ -> [unode "meta" ! [("name","cover"), ("content","cover-image")] $ ()] @@ -623,7 +621,8 @@ metadataElement version md currentTime = coverageNodes = maybe [] (dcTag' "coverage") $ epubCoverage md rightsNodes = maybe [] (dcTag' "rights") $ epubRights md coverImageNodes = maybe [] - (\ci -> [unode "meta" ! [("name","cover"), ("content",ci)] $ ()]) + (const $ [unode "meta" ! [("name","cover"), + ("content","cover-image")] $ ()]) $ epubCoverImage md modifiedNodes = [ unode "meta" ! [("property", "dcterms:modified")] $ (showDateTimeISO8601 currentTime) | version == EPUB3 ] -- cgit v1.2.3 From 17ef39d1577a7c844f8747294f0e7a0486c1edaa Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 15:25:28 -0800 Subject: Fixed `cover-image` in EPUB YAML metadata. --- README | 4 ++-- src/Text/Pandoc/Writers/EPUB.hs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 35194769b..2a5ecc6ad 100644 --- a/README +++ b/README @@ -542,7 +542,7 @@ Options affecting specific writers `--epub-cover-image=`*FILE* : Use the specified image as the EPUB cover. It is recommended that the image be less than 1000px in width and height. Note that - in a markdown source document you can also specify `epub-cover-image` + in a markdown source document you can also specify `cover-image` in a YAML metadata block (see [EPUB Metadata], below). `--epub-metadata=`*FILE* @@ -2820,7 +2820,7 @@ The following fields are recognized: ~ A string value. `rights` ~ A string value. -`epub-cover-image` +`cover-image` ~ A string value (path to cover image). Literate Haskell support diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index a3b01848e..9745db5a0 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -279,7 +279,8 @@ metadataFromMeta opts meta = EPUBMetadata{ relation = metaValueToString <$> lookupMeta "relation" meta coverage = metaValueToString <$> lookupMeta "coverage" meta rights = metaValueToString <$> lookupMeta "rights" meta - coverImage = lookup "epub-cover-image" (writerVariables opts) + coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus` + (metaValueToString <$> lookupMeta "cover-image" meta) -- | Produce an EPUB file from a Pandoc document. writeEPUB :: WriterOptions -- ^ Writer options -- cgit v1.2.3 From bb0f299165de22e119675aa6ceed0192a80c78e8 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 16:16:35 -0800 Subject: ConTeXt writer: Don't hardcode figure/table placement. Instead, let this be set in the template, using `\setupfloat`. Thanks to Aditya Mahajan for the suggestion. --- data/templates | 2 +- src/Text/Pandoc/Writers/ConTeXt.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/data/templates b/data/templates index 8cadd4f20..713a8f63d 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 8cadd4f2044c0c25842eeb5a2370a6e3384f4bd4 +Subproject commit 713a8f63d5589ab9313869e47b03cf7f49e00e98 diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 179d9bc5b..3095cf508 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -130,7 +130,7 @@ blockToConTeXt (Plain lst) = inlineListToConTeXt lst -- title beginning with fig: indicates that the image is a figure blockToConTeXt (Para [Image txt (src,'f':'i':'g':':':_)]) = do capt <- inlineListToConTeXt txt - return $ blankline $$ "\\placefigure[here]" <> braces capt <> + return $ blankline $$ "\\placefigure" <> braces capt <> braces ("\\externalfigure" <> brackets (text src)) <> blankline blockToConTeXt (Para lst) = do contents <- inlineListToConTeXt lst @@ -205,9 +205,9 @@ blockToConTeXt (Table caption aligns widths heads rows) = do else liftM ($$ "\\HL") $ tableRowToConTeXt heads captionText <- inlineListToConTeXt caption rows' <- mapM tableRowToConTeXt rows - return $ "\\placetable" <> brackets ("here" <> if null caption - then ",none" - else "") + return $ "\\placetable" <> (if null caption + then brackets "none" + else empty) <> braces captionText $$ "\\starttable" <> brackets (text colDescriptors) $$ "\\HL" $$ headers $$ -- cgit v1.2.3 From 7aa4d519686af1416eaf3b380f8584ab89569c41 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 17:00:58 -0800 Subject: ODT writer: Add `draw:name` attribute to `draw:frame` elements. This is reported to be necessary to avoid an error from recent versions of Libre Office when files contain more than one image. Closes #1069. Thanks to wmanley for reporting and diagnosing the problem. --- src/Text/Pandoc/Writers/OpenDocument.hs | 10 ++++++++-- tests/writer.opendocument | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 565f5f869..4ddfd7166 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -64,6 +64,7 @@ data WriterState = , stInDefinition :: Bool , stTight :: Bool , stFirstPara :: Bool + , stImageId :: Int } defaultWriterState :: WriterState @@ -78,6 +79,7 @@ defaultWriterState = , stInDefinition = False , stTight = False , stFirstPara = False + , stImageId = 1 } when :: Bool -> Doc -> Doc @@ -380,7 +382,7 @@ inlineToOpenDocument o ils then return $ preformatted s else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l - | Image _ (s,t) <- ils = return $ mkImg s t + | Image _ (s,t) <- ils = mkImg s t | Note l <- ils = mkNote l | otherwise = return empty where @@ -389,7 +391,11 @@ inlineToOpenDocument o ils , ("xlink:href" , s ) , ("office:name", t ) ] . inSpanTags "Definition" - mkImg s t = inTags False "draw:frame" (attrsFromTitle t) $ + mkImg s t = do + id' <- gets stImageId + modify (\st -> st{ stImageId = id' + 1 }) + return $ inTags False "draw:frame" + (("draw:name", "img" ++ show id'):attrsFromTitle t) $ selfClosingTag "draw:image" [ ("xlink:href" , s ) , ("xlink:type" , "simple") , ("xlink:show" , "embed" ) diff --git a/tests/writer.opendocument b/tests/writer.opendocument index b3888e34d..81c793a62 100644 --- a/tests/writer.opendocument +++ b/tests/writer.opendocument @@ -1576,9 +1576,9 @@ link in pointy braces</text:span></text:a>.</text:p> <text:h text:style-name="Heading_20_1" text:outline-level="1">Images</text:h> <text:p text:style-name="First_20_paragraph">From “Voyage dans la Lune” by Georges Melies (1902):</text:p> -<text:p text:style-name="Text_20_body"><draw:frame><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p> +<text:p text:style-name="Text_20_body"><draw:frame draw:name="img1"><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p> <text:p text:style-name="Text_20_body">Here is a movie -<draw:frame><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame> +<draw:frame draw:name="img2"><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame> icon.</text:p> <text:p text:style-name="Horizontal_20_Line" /> <text:h text:style-name="Heading_20_1" text:outline-level="1">Footnotes</text:h> -- cgit v1.2.3 From 7f09c1834da9f87e7715f5c9dc52f4b730da8f3f Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 17:59:28 -0800 Subject: Markdown writer: Fix rendering of tight sublists. E.g. - foo - bar - baz Previously a spurious blank line was included before the last item. Closes #1050. --- src/Text/Pandoc/Writers/Markdown.hs | 9 ++++++++- tests/Tests/Writers/Markdown.hs | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index eefcd547a..60d474263 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -555,7 +555,14 @@ bulletListItemToMarkdown opts items = do contents <- blockListToMarkdown opts items let sps = replicate (writerTabStop opts - 2) ' ' let start = text ('-' : ' ' : sps) - return $ hang (writerTabStop opts) start $ contents <> cr + -- remove trailing blank line if it is a tight list + let contents' = case reverse items of + (BulletList xs:_) | isTightList xs -> + chomp contents <> cr + (OrderedList _ xs:_) | isTightList xs -> + chomp contents <> cr + _ -> contents + return $ hang (writerTabStop opts) start $ contents' <> cr -- | Convert ordered list item (a list of blocks) to markdown. orderedListItemToMarkdown :: WriterOptions -- ^ options diff --git a/tests/Tests/Writers/Markdown.hs b/tests/Tests/Writers/Markdown.hs index 99b85dfb7..c2a8f5903 100644 --- a/tests/Tests/Writers/Markdown.hs +++ b/tests/Tests/Writers/Markdown.hs @@ -31,4 +31,8 @@ tests :: [Test] tests = [ "indented code after list" =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test") =?> "1. one\n\n two\n\n<!-- -->\n\n test" + , "list with tight sublist" + =: bulletList [ plain "foo" <> bulletList [ plain "bar" ], + plain "baz" ] + =?> "- foo\n - bar\n- baz\n" ] -- cgit v1.2.3 From 37569f30ed35a45b4765e9cd6c408cd167dd3452 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 19:33:02 -0800 Subject: EPUB writer: Add properties attribute to cover-image item for EPUB v3. --- src/Text/Pandoc/Writers/EPUB.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 9745db5a0..6e1a391af 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -448,7 +448,12 @@ writeEPUB opts doc@(Pandoc meta _) = do [("properties","nav") | epub3 ]) $ () ] ++ map chapterNode (cpgEntry ++ (tpEntry : chapterEntries)) ++ - map pictureNode (cpicEntry ++ picEntries) ++ + (case cpicEntry of + [] -> [] + (x:_) -> [add_attrs + [Attr (unqual "properties") "cover-image" | epub3] + (pictureNode x)]) ++ + map pictureNode picEntries ++ map fontNode fontEntries , unode "spine" ! [("toc","ncx")] $ case epubCoverImage metadata of -- cgit v1.2.3 From a7067ab22b0ce297ccc5271fca59b9f9e787195e Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 19:43:24 -0800 Subject: EPUB writer: Simplify imageTypeOf using getMimeType. --- src/Text/Pandoc/Writers/EPUB.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 6e1a391af..7be7eb368 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -736,15 +736,9 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity . unEntity (x:xs) = x : unEntity xs imageTypeOf :: FilePath -> Maybe String -imageTypeOf x = case drop 1 (map toLower (takeExtension x)) of - "jpg" -> Just "image/jpeg" - "jpeg" -> Just "image/jpeg" - "jfif" -> Just "image/jpeg" - "png" -> Just "image/png" - "gif" -> Just "image/gif" - "svg" -> Just "image/svg+xml" - _ -> Nothing - +imageTypeOf x = case getMimeType x of + Just y@('i':'m':'a':'g':'e':_) -> Just y + _ -> Nothing data IdentState = IdentState{ chapterNumber :: Int, -- cgit v1.2.3 From 0e158d8d8dc277f19d1f7d2686c2672f08410f82 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sat, 30 Nov 2013 20:20:18 -0800 Subject: EPUB writer: Insert "svg" property as needed in opf (EPUB 3). --- src/Text/Pandoc/Writers/EPUB.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 7be7eb368..b23f43a6e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -401,15 +401,21 @@ writeEPUB opts doc@(Pandoc meta _) = do let chapterEntries = zipWith chapToEntry [1..] chapters -- incredibly inefficient (TODO): - let containsMathML ent = "<math" `isInfixOf` (B8.unpack $ fromEntry ent) + let containsMathML ent = epub3 && + "<math" `isInfixOf` (B8.unpack $ fromEntry ent) + let containsSVG ent = epub3 && + "<svg" `isInfixOf` (B8.unpack $ fromEntry ent) + let props ent = ["mathml" | containsMathML ent] ++ ["svg" | containsSVG ent] -- contents.opf let chapterNode ent = unode "item" ! ([("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", "application/xhtml+xml")] - ++ [("properties","mathml") | epub3 && - containsMathML ent]) $ () + ++ case props ent of + [] -> [] + xs -> [("properties", unwords xs)]) + $ () let chapterRefNode ent = unode "itemref" ! [("idref", takeBaseName $ eRelativePath ent)] $ () let pictureNode ent = unode "item" ! -- cgit v1.2.3 From 1f6238f3ba1999988fbb2b25b091171451647d4e Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sun, 1 Dec 2013 10:16:56 -0800 Subject: EPUB writer: Allow partial dates: YYYY, YYYY-MM. Improves on #1074, since now we don't default to January 1. --- src/Text/Pandoc/Writers/EPUB.hs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index b23f43a6e..59c90b16d 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -56,7 +56,7 @@ import Text.XML.Light hiding (ppTopElement) import Text.Pandoc.UUID import Text.Pandoc.Writers.HTML import Text.Pandoc.Writers.Markdown ( writePlain ) -import Data.Char ( toLower ) +import Data.Char ( toLower, isDigit ) import Network.URI ( unEscapeString ) import Text.Pandoc.MIME (getMimeType) #if MIN_VERSION_base(4,6,0) @@ -171,7 +171,8 @@ addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md , titleFileAs = getAttr "file-as" , titleType = getAttr "type" } : epubTitle md } - | name == "date" = md{ epubDate = maybe "" id $ normalizeDate $ strContent e } + | name == "date" = md{ epubDate = maybe "" id $ normalizeDate' + $ strContent e } | name == "language" = md{ epubLanguage = strContent e } | name == "creator" = md{ epubCreator = Creator{ creatorText = strContent e @@ -265,7 +266,7 @@ metadataFromMeta opts meta = EPUBMetadata{ where identifiers = getIdentifier meta titles = getTitle meta date = maybe "" id $ - (metaValueToString <$> lookupMeta "date" meta) >>= normalizeDate + (metaValueToString <$> lookupMeta "date" meta) >>= normalizeDate' language = maybe "" metaValueToString $ lookupMeta "language" meta `mplus` lookupMeta "lang" meta creators = getCreator "creator" meta @@ -799,6 +800,16 @@ replaceRefs refTable = walk replaceOneRef Nothing -> x replaceOneRef x = x +-- Variant of normalizeDate that allows partial dates: YYYY, YYYY-MM +normalizeDate' :: String -> Maybe String +normalizeDate' xs = + let xs' = trim xs in + case xs' of + [y1,y2,y3,y4] | all isDigit [y1,y2,y3,y4] -> Just xs' -- YYYY + [y1,y2,y3,y4,'-',m1,m2] | all isDigit [y1,y2,y3,y4,m1,m2] -- YYYY-MM + -> Just xs' + _ -> normalizeDate xs' + toRelator :: String -> Maybe String toRelator x | x `elem` relators = Just x -- cgit v1.2.3 From bd96f2bdcce55bfe5a7b753d29b3f4a45986f211 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 3 Dec 2013 10:32:03 -0800 Subject: EPUB writer: Allow 'stylesheet' in metadata. The value is a path to the stylesheet. --- README | 2 ++ src/Text/Pandoc/Writers/EPUB.hs | 33 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 2a5ecc6ad..11cbf189f 100644 --- a/README +++ b/README @@ -2822,6 +2822,8 @@ The following fields are recognized: ~ A string value. `cover-image` ~ A string value (path to cover image). +`stylesheet` + ~ A string value (path to CSS stylesheet). Literate Haskell support ======================== diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 59c90b16d..32b0c3c32 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -38,7 +38,7 @@ import Text.Printf (printf) import System.FilePath ( (</>), takeBaseName, takeExtension, takeFileName ) import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy.Char8 as B8 -import Text.Pandoc.UTF8 ( fromStringLazy, toString ) +import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.SelfContained ( makeSelfContained ) import Codec.Archive.Zip import Control.Applicative ((<$>)) @@ -89,8 +89,13 @@ data EPUBMetadata = EPUBMetadata{ , epubCoverage :: Maybe String , epubRights :: Maybe String , epubCoverImage :: Maybe String + , epubStylesheet :: Maybe Stylesheet } deriving Show +data Stylesheet = StylesheetPath FilePath + | StylesheetContents String + deriving Show + data Creator = Creator{ creatorText :: String , creatorRole :: Maybe String @@ -262,6 +267,7 @@ metadataFromMeta opts meta = EPUBMetadata{ , epubCoverage = coverage , epubRights = rights , epubCoverImage = coverImage + , epubStylesheet = stylesheet } where identifiers = getIdentifier meta titles = getTitle meta @@ -282,6 +288,10 @@ metadataFromMeta opts meta = EPUBMetadata{ rights = metaValueToString <$> lookupMeta "rights" meta coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus` (metaValueToString <$> lookupMeta "cover-image" meta) + stylesheet = (StylesheetContents <$> + lookup "epub-stylesheet" (writerVariables opts)) `mplus` + ((StylesheetPath . metaValueToString) <$> + lookupMeta "stylesheet" meta) -- | Produce an EPUB file from a Pandoc document. writeEPUB :: WriterOptions -- ^ Writer options @@ -437,7 +447,7 @@ writeEPUB opts doc@(Pandoc meta _) = do (x:_) -> identifierText x -- use first identifier as UUID [] -> error "epubIdentifier is null" -- shouldn't happen currentTime <- getCurrentTime - let contentsData = fromStringLazy $ ppTopElement $ + let contentsData = UTF8.fromStringLazy $ ppTopElement $ unode "package" ! [("version", case version of EPUB2 -> "2.0" EPUB3 -> "3.0") @@ -525,7 +535,7 @@ writeEPUB opts doc@(Pandoc meta _) = do [ unode "navLabel" $ unode "text" (plainify $ docTitle meta) , unode "content" ! [("src","title_page.xhtml")] $ () ] - let tocData = fromStringLazy $ ppTopElement $ + let tocData = UTF8.fromStringLazy $ ppTopElement $ unode "ncx" ! [("version","2005-1") ,("xmlns","http://www.daisy.org/z3986/2005/ncx/")] $ [ unode "head" $ @@ -557,7 +567,7 @@ writeEPUB opts doc@(Pandoc meta _) = do (_:_) -> [unode "ol" ! [("class","toc")] $ subs] let navtag = if epub3 then "nav" else "div" - let navData = fromStringLazy $ ppTopElement $ + let navData = UTF8.fromStringLazy $ ppTopElement $ unode "html" ! [("xmlns","http://www.w3.org/1999/xhtml") ,("xmlns:epub","http://www.idpf.org/2007/ops")] $ [ unode "head" $ @@ -571,10 +581,10 @@ writeEPUB opts doc@(Pandoc meta _) = do let navEntry = mkEntry "nav.xhtml" navData -- mimetype - let mimetypeEntry = mkEntry "mimetype" $ fromStringLazy "application/epub+zip" + let mimetypeEntry = mkEntry "mimetype" $ UTF8.fromStringLazy "application/epub+zip" -- container.xml - let containerData = fromStringLazy $ ppTopElement $ + let containerData = UTF8.fromStringLazy $ ppTopElement $ unode "container" ! [("version","1.0") ,("xmlns","urn:oasis:names:tc:opendocument:xmlns:container")] $ unode "rootfiles" $ @@ -583,18 +593,19 @@ writeEPUB opts doc@(Pandoc meta _) = do let containerEntry = mkEntry "META-INF/container.xml" containerData -- com.apple.ibooks.display-options.xml - let apple = fromStringLazy $ ppTopElement $ + let apple = UTF8.fromStringLazy $ ppTopElement $ unode "display_options" $ unode "platform" ! [("name","*")] $ unode "option" ! [("name","specified-fonts")] $ "true" let appleEntry = mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple -- stylesheet - stylesheet <- case writerEpubStylesheet opts of - Just s -> return s - Nothing -> toString `fmap` + stylesheet <- case epubStylesheet metadata of + Just (StylesheetPath fp) -> UTF8.readFile fp + Just (StylesheetContents s) -> return s + Nothing -> UTF8.toString `fmap` readDataFile (writerUserDataDir opts) "epub.css" - let stylesheetEntry = mkEntry "stylesheet.css" $ fromStringLazy stylesheet + let stylesheetEntry = mkEntry "stylesheet.css" $ UTF8.fromStringLazy stylesheet -- construct archive let archive = foldr addEntryToArchive emptyArchive -- cgit v1.2.3 From fdaeec0c48d742489ddf0ec0c0261ca9c53f989b Mon Sep 17 00:00:00 2001 From: Jose Luis Duran <jlduran@gmail.com> Date: Mon, 2 Dec 2013 09:55:58 +0000 Subject: Add booktabs package for LaTeX tables [ci skip] --- README | 2 +- data/templates | 2 +- src/Text/Pandoc/Writers/LaTeX.hs | 10 ++--- tests/tables.latex | 90 ++++++++++++++++++++-------------------- 4 files changed, 52 insertions(+), 52 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 2a5ecc6ad..3ba1e364e 100644 --- a/README +++ b/README @@ -108,7 +108,7 @@ to PDF: Production of a PDF requires that a LaTeX engine be installed (see `--latex-engine`, below), and assumes that the following LaTeX packages are available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the -`--listings` option is used), `fancyvrb`, `longtable`, `url`, +`--listings` option is used), `fancyvrb`, `longtable`, `booktabs`, `url`, `graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set), `fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra` and `xunicode` (if `xelatex` is used). diff --git a/data/templates b/data/templates index 713a8f63d..f643a076d 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 713a8f63d5589ab9313869e47b03cf7f49e00e98 +Subproject commit f643a076d8c2b0b21391fd6aa1dedb2dd84c7e63 diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index f3cbcf19f..a2e0b016f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -453,12 +453,12 @@ blockToLaTeX (Header level (id',classes,_) lst) = blockToLaTeX (Table caption aligns widths heads rows) = do headers <- if all null heads then return empty - else ($$ "\\hline\\noalign{\\medskip}") `fmap` + else ($$ "\\midrule\\endhead") `fmap` (tableRowToLaTeX True aligns widths) heads captionText <- inlineListToLaTeX caption let capt = if isEmpty captionText then empty - else text "\\noalign{\\medskip}" + else text "\\addlinespace" $$ text "\\caption" <> braces captionText rows' <- mapM (tableRowToLaTeX False aligns widths) rows let colDescriptors = text $ concat $ map toColDescriptor aligns @@ -466,10 +466,10 @@ blockToLaTeX (Table caption aligns widths heads rows) = do return $ "\\begin{longtable}[c]" <> braces ("@{}" <> colDescriptors <> "@{}") -- the @{} removes extra space at beginning and end - $$ "\\hline\\noalign{\\medskip}" + $$ "\\toprule\\addlinespace" $$ headers $$ vcat rows' - $$ "\\hline" + $$ "\\bottomrule" $$ capt $$ "\\end{longtable}" @@ -506,7 +506,7 @@ tableRowToLaTeX header aligns widths cols = do (w * scaleFactor))) <> (halign a <> cr <> c <> cr) <> "\\end{minipage}" let cells = zipWith3 toCell widths aligns renderedCells - return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}" + return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace" listItemToLaTeX :: [Block] -> State WriterState Doc listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) . diff --git a/tests/tables.latex b/tests/tables.latex index c27e10461..1a87c4f71 100644 --- a/tests/tables.latex +++ b/tests/tables.latex @@ -1,59 +1,59 @@ Simple table with caption: \begin{longtable}[c]{@{}rlcl@{}} -\hline\noalign{\medskip} +\toprule\addlinespace Right & Left & Center & Default -\\\noalign{\medskip} -\hline\noalign{\medskip} +\\\addlinespace +\midrule\endhead 12 & 12 & 12 & 12 -\\\noalign{\medskip} +\\\addlinespace 123 & 123 & 123 & 123 -\\\noalign{\medskip} +\\\addlinespace 1 & 1 & 1 & 1 -\\\noalign{\medskip} -\hline -\noalign{\medskip} +\\\addlinespace +\bottomrule +\addlinespace \caption{Demonstration of simple table syntax.} \end{longtable} Simple table without caption: \begin{longtable}[c]{@{}rlcl@{}} -\hline\noalign{\medskip} +\toprule\addlinespace Right & Left & Center & Default -\\\noalign{\medskip} -\hline\noalign{\medskip} +\\\addlinespace +\midrule\endhead 12 & 12 & 12 & 12 -\\\noalign{\medskip} +\\\addlinespace 123 & 123 & 123 & 123 -\\\noalign{\medskip} +\\\addlinespace 1 & 1 & 1 & 1 -\\\noalign{\medskip} -\hline +\\\addlinespace +\bottomrule \end{longtable} Simple table indented two spaces: \begin{longtable}[c]{@{}rlcl@{}} -\hline\noalign{\medskip} +\toprule\addlinespace Right & Left & Center & Default -\\\noalign{\medskip} -\hline\noalign{\medskip} +\\\addlinespace +\midrule\endhead 12 & 12 & 12 & 12 -\\\noalign{\medskip} +\\\addlinespace 123 & 123 & 123 & 123 -\\\noalign{\medskip} +\\\addlinespace 1 & 1 & 1 & 1 -\\\noalign{\medskip} -\hline -\noalign{\medskip} +\\\addlinespace +\bottomrule +\addlinespace \caption{Demonstration of simple table syntax.} \end{longtable} Multiline table with caption: \begin{longtable}[c]{@{}clrl@{}} -\hline\noalign{\medskip} +\toprule\addlinespace \begin{minipage}[b]{0.13\columnwidth}\centering Centered Header \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright @@ -63,8 +63,8 @@ Right Aligned \end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright Default aligned \end{minipage} -\\\noalign{\medskip} -\hline\noalign{\medskip} +\\\addlinespace +\midrule\endhead \begin{minipage}[t]{0.13\columnwidth}\centering First \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright @@ -74,7 +74,7 @@ row \end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Example of a row that spans multiple lines. \end{minipage} -\\\noalign{\medskip} +\\\addlinespace \begin{minipage}[t]{0.13\columnwidth}\centering Second \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright @@ -84,16 +84,16 @@ row \end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Here's another one. Note the blank line between rows. \end{minipage} -\\\noalign{\medskip} -\hline -\noalign{\medskip} +\\\addlinespace +\bottomrule +\addlinespace \caption{Here's the caption. It may span multiple lines.} \end{longtable} Multiline table without caption: \begin{longtable}[c]{@{}clrl@{}} -\hline\noalign{\medskip} +\toprule\addlinespace \begin{minipage}[b]{0.13\columnwidth}\centering Centered Header \end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright @@ -103,8 +103,8 @@ Right Aligned \end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright Default aligned \end{minipage} -\\\noalign{\medskip} -\hline\noalign{\medskip} +\\\addlinespace +\midrule\endhead \begin{minipage}[t]{0.13\columnwidth}\centering First \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright @@ -114,7 +114,7 @@ row \end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Example of a row that spans multiple lines. \end{minipage} -\\\noalign{\medskip} +\\\addlinespace \begin{minipage}[t]{0.13\columnwidth}\centering Second \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright @@ -124,27 +124,27 @@ row \end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Here's another one. Note the blank line between rows. \end{minipage} -\\\noalign{\medskip} -\hline +\\\addlinespace +\bottomrule \end{longtable} Table without column headers: \begin{longtable}[c]{@{}rlcr@{}} -\hline\noalign{\medskip} +\toprule\addlinespace 12 & 12 & 12 & 12 -\\\noalign{\medskip} +\\\addlinespace 123 & 123 & 123 & 123 -\\\noalign{\medskip} +\\\addlinespace 1 & 1 & 1 & 1 -\\\noalign{\medskip} -\hline +\\\addlinespace +\bottomrule \end{longtable} Multiline table without column headers: \begin{longtable}[c]{@{}clrl@{}} -\hline\noalign{\medskip} +\toprule\addlinespace \begin{minipage}[t]{0.13\columnwidth}\centering First \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright @@ -154,7 +154,7 @@ row \end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Example of a row that spans multiple lines. \end{minipage} -\\\noalign{\medskip} +\\\addlinespace \begin{minipage}[t]{0.13\columnwidth}\centering Second \end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright @@ -164,6 +164,6 @@ row \end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright Here's another one. Note the blank line between rows. \end{minipage} -\\\noalign{\medskip} -\hline +\\\addlinespace +\bottomrule \end{longtable} -- cgit v1.2.3 From f9662957704ebfe83d7764dd64151d37c476c0b0 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Mon, 9 Dec 2013 20:31:47 -0800 Subject: Don't use tilde code blocks with braced attributes in gfm output. A consequence of this change is that the backtick form will be preferred in general if both are enabled. I think that is good, as it is much more widespread than the tilde form. Closes #1084. --- src/Text/Pandoc/Writers/Markdown.hs | 18 +++++++++--------- tests/lhs-test.markdown | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 60d474263..c0b189b75 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -381,13 +381,11 @@ blockToMarkdown opts (CodeBlock (_,classes,_) str) isEnabled Ext_literate_haskell opts = return $ prefixed "> " (text str) <> blankline blockToMarkdown opts (CodeBlock attribs str) = return $ - case attribs of - x | x /= nullAttr && isEnabled Ext_fenced_code_blocks opts -> - tildes <> " " <> attrs <> cr <> text str <> - cr <> tildes <> blankline - (_,(cls:_),_) | isEnabled Ext_backtick_code_blocks opts -> - backticks <> " " <> text cls <> cr <> text str <> - cr <> backticks <> blankline + case attribs == nullAttr of + False | isEnabled Ext_backtick_code_blocks opts -> + backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline + | isEnabled Ext_fenced_code_blocks opts -> + tildes <> attrs <> cr <> text str <> cr <> tildes <> blankline _ -> nest (writerTabStop opts) (text str) <> blankline where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of [] -> "~~~~" @@ -396,8 +394,10 @@ blockToMarkdown opts (CodeBlock attribs str) = return $ | otherwise -> replicate (n+1) '~' backticks = text "```" attrs = if isEnabled Ext_fenced_code_attributes opts - then nowrap $ attrsToMarkdown attribs - else empty + then nowrap $ " " <> attrsToMarkdown attribs + else case attribs of + (_,[cls],_) -> " " <> text cls + _ -> empty blockToMarkdown opts (BlockQuote blocks) = do st <- get -- if we're writing literate haskell, put a space before the bird tracks diff --git a/tests/lhs-test.markdown b/tests/lhs-test.markdown index 47ec920d3..75a253bf4 100644 --- a/tests/lhs-test.markdown +++ b/tests/lhs-test.markdown @@ -4,11 +4,11 @@ lhs test `unsplit` is an arrow that takes a pair of values and combines them to return a single value: -~~~~ {.sourceCode .literate .haskell} +``` {.sourceCode .literate .haskell} unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d unsplit = arr . uncurry -- arr (\op (x,y) -> x `op` y) -~~~~ +``` `(***)` combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the -- cgit v1.2.3 From ca3c292f30c04bd24287d554f08a7911c808a4e2 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Fri, 13 Dec 2013 11:10:04 -0800 Subject: EPUB writer: Fixed bug with `--epub-stylesheet`. Now the contents of `writerEpubStylesheet` (set by `--epub-stylesheet`) should again work, and take precedence over a stylesheet specified in the metadata. --- src/Text/Pandoc/Writers/EPUB.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 32b0c3c32..36ead0b8f 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -288,8 +288,7 @@ metadataFromMeta opts meta = EPUBMetadata{ rights = metaValueToString <$> lookupMeta "rights" meta coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus` (metaValueToString <$> lookupMeta "cover-image" meta) - stylesheet = (StylesheetContents <$> - lookup "epub-stylesheet" (writerVariables opts)) `mplus` + stylesheet = (StylesheetContents <$> writerEpubStylesheet opts) `mplus` ((StylesheetPath . metaValueToString) <$> lookupMeta "stylesheet" meta) -- cgit v1.2.3 From a3f6f2827c9acb0e68ac533745b3f4dc8836ee24 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Tue, 17 Dec 2013 20:10:09 -0800 Subject: LaTeX writer: Factored out function for table cell creation. --- src/Text/Pandoc/Writers/LaTeX.hs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index a2e0b016f..b7beacd91 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -490,24 +490,28 @@ tableRowToLaTeX :: Bool -> [[Block]] -> State WriterState Doc tableRowToLaTeX header aligns widths cols = do - renderedCells <- mapM blockListToLaTeX cols - let valign = text $ if header then "[b]" else "[t]" - let halign x = case x of - AlignLeft -> "\\raggedright" - AlignRight -> "\\raggedleft" - AlignCenter -> "\\centering" - AlignDefault -> "\\raggedright" -- scale factor compensates for extra space between columns -- so the whole table isn't larger than columnwidth let scaleFactor = 0.97 ** fromIntegral (length aligns) - let toCell 0 _ c = c - toCell w a c = "\\begin{minipage}" <> valign <> - braces (text (printf "%.2f\\columnwidth" - (w * scaleFactor))) <> - (halign a <> cr <> c <> cr) <> "\\end{minipage}" - let cells = zipWith3 toCell widths aligns renderedCells + let widths' = map (scaleFactor *) widths + cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace" +tableCellToLaTeX :: Bool -> (Double, Alignment, [Block]) + -> State WriterState Doc +tableCellToLaTeX _ (0, _, blocks) = blockListToLaTeX blocks +tableCellToLaTeX header (width, align, blocks) = do + cellContents <- blockListToLaTeX blocks + let valign = text $ if header then "[b]" else "[t]" + let halign = case align of + AlignLeft -> "\\raggedright" + AlignRight -> "\\raggedleft" + AlignCenter -> "\\centering" + AlignDefault -> "\\raggedright" + return $ "\\begin{minipage}" <> valign <> + braces (text (printf "%.2f\\columnwidth" width)) <> + (halign <> cr <> cellContents <> cr) <> "\\end{minipage}" + listItemToLaTeX :: [Block] -> State WriterState Doc listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) . (nest 2) -- cgit v1.2.3 From 8053ba2123699fd89900b2a9c5656a72d3a2fe85 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Tue, 17 Dec 2013 20:53:59 -0800 Subject: LaTeX writer: Better treatment of footnotes in tables. Notes now appear in the regular sequence, rather than in the table cell. (This was a regression in 1.10.) --- src/Text/Pandoc/Writers/LaTeX.hs | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index b7beacd91..7612be100 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -50,6 +50,8 @@ import Text.Pandoc.Highlighting (highlight, styleToLaTeX, data WriterState = WriterState { stInNote :: Bool -- true if we're in a note + , stInMinipage :: Bool -- true if in minipage + , stNotes :: [Doc] -- notes in a minipage , stOLLevel :: Int -- level of ordered list nesting , stOptions :: WriterOptions -- writer options, so they don't have to be parameter , stVerbInNote :: Bool -- true if document has verbatim text in note @@ -70,7 +72,7 @@ data WriterState = writeLaTeX :: WriterOptions -> Pandoc -> String writeLaTeX options document = evalState (pandocToLaTeX options document) $ - WriterState { stInNote = False, + WriterState { stInNote = False, stInMinipage = False, stNotes = [], stOLLevel = 1, stOptions = options, stVerbInNote = False, stTable = False, stStrikeout = False, @@ -501,16 +503,31 @@ tableCellToLaTeX :: Bool -> (Double, Alignment, [Block]) -> State WriterState Doc tableCellToLaTeX _ (0, _, blocks) = blockListToLaTeX blocks tableCellToLaTeX header (width, align, blocks) = do + modify $ \st -> st{ stInMinipage = True, stNotes = [] } cellContents <- blockListToLaTeX blocks + notes <- gets stNotes + modify $ \st -> st{ stInMinipage = False, stNotes = [] } let valign = text $ if header then "[b]" else "[t]" let halign = case align of AlignLeft -> "\\raggedright" AlignRight -> "\\raggedleft" AlignCenter -> "\\centering" AlignDefault -> "\\raggedright" - return $ "\\begin{minipage}" <> valign <> - braces (text (printf "%.2f\\columnwidth" width)) <> - (halign <> cr <> cellContents <> cr) <> "\\end{minipage}" + return $ ("\\begin{minipage}" <> valign <> + braces (text (printf "%.2f\\columnwidth" width)) <> + (halign <> cr <> cellContents <> cr) <> "\\end{minipage}") + $$ case notes of + [] -> empty + ns -> (case length ns of + n | n > 1 -> "\\addtocounter" <> + braces "footnote" <> + braces (text $ show $ 1 - n) + | otherwise -> empty) + $$ + vcat (intersperse + ("\\addtocounter" <> braces "footnote" <> braces "1") + $ map (\x -> "\\footnotetext" <> braces x) + $ reverse ns) listItemToLaTeX :: [Block] -> State WriterState Doc listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) . @@ -713,14 +730,20 @@ inlineToLaTeX (Image _ (source, _)) = do source'' <- stringToLaTeX URLString source' return $ "\\includegraphics" <> braces (text source'') inlineToLaTeX (Note contents) = do + inMinipage <- gets stInMinipage modify (\s -> s{stInNote = True}) contents' <- blockListToLaTeX contents modify (\s -> s {stInNote = False}) let optnl = case reverse contents of (CodeBlock _ _ : _) -> cr _ -> empty - return $ "\\footnote" <> braces (nest 2 contents' <> optnl) - -- note: a \n before } needed when note ends with a Verbatim environment + let noteContents = nest 2 contents' <> optnl + modify $ \st -> st{ stNotes = noteContents : stNotes st } + return $ + if inMinipage + then "\\footnotemark{}" + -- note: a \n before } needed when note ends with a Verbatim environment + else "\\footnote" <> braces noteContents citationsToNatbib :: [Citation] -> State WriterState Doc citationsToNatbib (one:[]) -- cgit v1.2.3 From 1ed2c467c9442934c060257f6e191a5a3d6c1e38 Mon Sep 17 00:00:00 2001 From: Henry de Valence <hdevalence@hdevalence.ca> Date: Thu, 19 Dec 2013 17:06:27 -0500 Subject: HLint: Use all Replace `and . map` with `all`. --- src/Text/Pandoc/Shared.hs | 2 +- src/Text/Pandoc/Writers/LaTeX.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index ce71881e6..cd2f7e24d 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -532,7 +532,7 @@ headerShift n = walk shift -- | Detect if a list is tight. isTightList :: [[Block]] -> Bool -isTightList = and . map firstIsPlain +isTightList = all firstIsPlain where firstIsPlain (Plain _ : _) = True firstIsPlain _ = False diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 7612be100..47b769c48 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -443,7 +443,7 @@ blockToLaTeX (DefinitionList lst) = do incremental <- gets stIncremental let inc = if incremental then "[<+->]" else "" items <- mapM defListItemToLaTeX lst - let spacing = if and $ map isTightList (map snd lst) + let spacing = if all isTightList (map snd lst) then text "\\itemsep1pt\\parskip0pt\\parsep0pt" else empty return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$ @@ -764,9 +764,9 @@ citationsToNatbib cits | noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits = citeCommand "citep" p s ks where - noPrefix = and . map (null . citationPrefix) - noSuffix = and . map (null . citationSuffix) - ismode m = and . map (((==) m) . citationMode) + noPrefix = all (null . citationPrefix) + noSuffix = all (null . citationSuffix) + ismode m = all (((==) m) . citationMode) p = citationPrefix $ head $ cits s = citationSuffix $ last $ cits ks = intercalate ", " $ map citationId cits -- cgit v1.2.3 From 0c5e7cf8cb4fe6959d7e89880e8925afe6625414 Mon Sep 17 00:00:00 2001 From: Henry de Valence <hdevalence@hdevalence.ca> Date: Thu, 19 Dec 2013 20:19:24 -0500 Subject: HLint: use `elem` and `notElem` Replaces long conditional chains with calls to `elem` and `notElem`. --- pandoc.hs | 2 +- src/Text/Pandoc/Parsing.hs | 4 ++-- src/Text/Pandoc/Readers/LaTeX.hs | 5 ++--- src/Text/Pandoc/Readers/Markdown.hs | 8 ++++---- src/Text/Pandoc/Shared.hs | 12 ++++-------- src/Text/Pandoc/Writers/Markdown.hs | 11 ++++++----- src/Text/Pandoc/Writers/Org.hs | 2 +- 7 files changed, 20 insertions(+), 24 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.hs b/pandoc.hs index cada3347d..ccd3e57fb 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -656,7 +656,7 @@ options = (ReqArg (\arg opt -> do let b = takeBaseName arg - if (b == "pdflatex" || b == "lualatex" || b == "xelatex") + if b `elem` ["pdflatex", "lualatex", "xelatex"] then return opt { optLaTeXEngine = arg } else err 45 "latex-engine must be pdflatex, lualatex, or xelatex.") "PROGRAM") diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index e15854333..2f21e1253 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -271,7 +271,7 @@ spaceChar = satisfy $ \c -> c == ' ' || c == '\t' -- | Parses a nonspace, nonnewline character. nonspaceChar :: Parser [Char] st Char -nonspaceChar = satisfy $ \x -> x /= '\t' && x /= '\n' && x /= ' ' && x /= '\r' +nonspaceChar = satisfy $ flip notElem ['\t', '\n', ' ', '\r'] -- | Skips zero or more spaces or tabs. skipSpaces :: Parser [Char] st () @@ -1062,7 +1062,7 @@ doubleQuoteStart :: Parser [Char] ParserState () doubleQuoteStart = do failIfInQuoteContext InDoubleQuote try $ do charOrRef "\"\8220\147" - notFollowedBy (satisfy (\c -> c == ' ' || c == '\t' || c == '\n')) + notFollowedBy . satisfy $ flip elem [' ', '\t', '\n'] doubleQuoteEnd :: Parser [Char] st () doubleQuoteEnd = do diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 0020a8f26..51271edc5 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -874,9 +874,8 @@ verbatimEnv = do (_,r) <- withRaw $ do controlSeq "begin" name <- braced - guard $ name == "verbatim" || name == "Verbatim" || - name == "lstlisting" || name == "minted" || - name == "alltt" + guard $ name `elem` ["verbatim", "Verbatim", "lstlisting", + "minted", "alltt"] verbEnv name rest <- getInput return (r,rest) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index b2e88d47e..f483ab059 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -789,8 +789,8 @@ listItem start = try $ do orderedList :: MarkdownParser (F Blocks) orderedList = try $ do (start, style, delim) <- lookAhead anyOrderedListStart - unless ((style == DefaultStyle || style == Decimal || style == Example) && - (delim == DefaultDelim || delim == Period)) $ + unless (style `elem` [DefaultStyle, Decimal, Example] && + delim `elem` [DefaultDelim, Period]) $ guardEnabled Ext_fancy_lists when (style == Example) $ guardEnabled Ext_example_lists items <- fmap sequence $ many1 $ listItem @@ -925,8 +925,8 @@ strictHtmlBlock = htmlInBalanced (not . isInlineTag) rawVerbatimBlock :: MarkdownParser String rawVerbatimBlock = try $ do - (TagOpen tag _, open) <- htmlTag (tagOpen (\t -> - t == "pre" || t == "style" || t == "script") + (TagOpen tag _, open) <- htmlTag (tagOpen (flip elem + ["pre", "style", "script"]) (const True)) contents <- manyTill anyChar (htmlTag (~== TagClose tag)) return $ open ++ contents ++ renderTags [TagClose tag] diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index cd2f7e24d..3446f4343 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -564,14 +564,10 @@ makeMeta title authors date = -- | Render HTML tags. renderTags' :: [Tag String] -> String renderTags' = renderTagsOptions - renderOptions{ optMinimize = \x -> - let y = map toLower x - in y == "hr" || y == "br" || - y == "img" || y == "meta" || - y == "link" - , optRawTag = \x -> - let y = map toLower x - in y == "script" || y == "style" } + renderOptions{ optMinimize = matchTags ["hr", "br", "img", + "meta", "link"] + , optRawTag = matchTags ["script", "style"] } + where matchTags = \tags -> flip elem tags . map toLower -- -- File handling diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index c0b189b75..278e5cc9d 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -338,7 +338,7 @@ blockToMarkdown opts (RawBlock f str) else return $ if isEnabled Ext_markdown_attribute opts then text (addMarkdownAttribute str) <> text "\n" else text str <> text "\n" - | f == "latex" || f == "tex" || f == "markdown" = do + | f `elem` ["latex", "tex", "markdown"] = do st <- get if stPlain st then return empty @@ -628,10 +628,11 @@ getReference label (src, tit) = do Nothing -> do let label' = case find ((== label) . fst) (stRefs st) of Just _ -> -- label is used; generate numerical label - case find (\n -> not (any (== [Str (show n)]) - (map fst (stRefs st)))) [1..(10000 :: Integer)] of - Just x -> [Str (show x)] - Nothing -> error "no unique label" + case find (\n -> notElem [Str (show n)] + (map fst (stRefs st))) + [1..(10000 :: Integer)] of + Just x -> [Str (show x)] + Nothing -> error "no unique label" Nothing -> label modify (\s -> s{ stRefs = (label', (src,tit)) : stRefs st }) return label' diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index 51083f52b..d318c5f6a 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -129,7 +129,7 @@ blockToOrg (Para inlines) = do blockToOrg (RawBlock "html" str) = return $ blankline $$ "#+BEGIN_HTML" $$ nest 2 (text str) $$ "#+END_HTML" $$ blankline -blockToOrg (RawBlock f str) | f == "org" || f == "latex" || f == "tex" = +blockToOrg (RawBlock f str) | f `elem` ["org", "latex", "tex"] = return $ text str blockToOrg (RawBlock _ _) = return empty blockToOrg HorizontalRule = return $ blankline $$ "--------------" $$ blankline -- cgit v1.2.3 From c35f5ba42df094cef5f69a191315385a0a1e12b0 Mon Sep 17 00:00:00 2001 From: Henry de Valence <hdevalence@hdevalence.ca> Date: Thu, 19 Dec 2013 20:28:53 -0500 Subject: HLint: Remove lambdas. --- src/Text/Pandoc/Writers/Shared.hs | 3 +-- tests/Tests/Walk.hs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 9cb08803c..33091ea94 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -65,8 +65,7 @@ metaToJSON opts blockWriter inlineWriter (Meta metamap) renderedMap <- Traversable.mapM (metaValueToJSON blockWriter inlineWriter) metamap - return $ M.foldWithKey (\key val obj -> defField key val obj) - baseContext renderedMap + return $ M.foldWithKey defField baseContext renderedMap | otherwise = return (Object H.empty) metaValueToJSON :: Monad m diff --git a/tests/Tests/Walk.hs b/tests/Tests/Walk.hs index f6aa1beae..34350e28a 100644 --- a/tests/Tests/Walk.hs +++ b/tests/Tests/Walk.hs @@ -21,11 +21,11 @@ tests = [ testGroup "Walk" p_walk :: (Typeable a, Walkable a Pandoc) => (a -> a) -> Pandoc -> Bool -p_walk f = (\(d :: Pandoc) -> everywhere (mkT f) d == walk f d) +p_walk f d = everywhere (mkT f) d == walk f d p_query :: (Eq a, Typeable a1, Monoid a, Walkable a1 Pandoc) => (a1 -> a) -> Pandoc -> Bool -p_query f = (\(d :: Pandoc) -> everything mappend (mempty `mkQ` f) d == query f d) +p_query f d = everything mappend (mempty `mkQ` f) d == query f d inlineTrans :: Inline -> Inline inlineTrans (Str xs) = Str $ map toUpper xs -- cgit v1.2.3 From f6d151889c8fff303be8ee8a4f9be67a04de9210 Mon Sep 17 00:00:00 2001 From: Henry de Valence <hdevalence@hdevalence.ca> Date: Thu, 19 Dec 2013 20:43:25 -0500 Subject: HLint: redundant parens Remove parens enclosing a single element. --- pandoc.hs | 6 ++---- src/Text/Pandoc/Readers/Markdown.hs | 2 +- src/Text/Pandoc/Readers/Textile.hs | 2 +- src/Text/Pandoc/Writers/HTML.hs | 2 +- src/Text/Pandoc/Writers/MediaWiki.hs | 2 +- src/Text/Pandoc/Writers/Textile.hs | 2 +- tests/Tests/Readers/LaTeX.hs | 2 +- tests/Tests/Readers/Markdown.hs | 4 ++-- 8 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.hs b/pandoc.hs index ccd3e57fb..574c89771 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -1034,12 +1034,10 @@ main = do variables' <- case mathMethod of LaTeXMathML Nothing -> do - s <- readDataFileUTF8 datadir - ("LaTeXMathML.js") + s <- readDataFileUTF8 datadir "LaTeXMathML.js" return $ ("mathml-script", s) : variables MathML Nothing -> do - s <- readDataFileUTF8 datadir - ("MathMLinHTML.js") + s <- readDataFileUTF8 datadir "MathMLinHTML.js" return $ ("mathml-script", s) : variables _ -> return variables diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index f483ab059..166c524ef 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -730,7 +730,7 @@ listStart = bulletListStart <|> (anyOrderedListStart >> return ()) listLine :: MarkdownParser String listLine = try $ do notFollowedBy' (do indentSpaces - many (spaceChar) + many spaceChar listStart) notFollowedBy' $ htmlTag (~== TagClose "div") chunks <- manyTill diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 23e07f621..93658cdea 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -594,7 +594,7 @@ surrounded border = enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try bo simpleInline :: Parser [Char] ParserState t -- ^ surrounding parser -> ([Inline] -> Inline) -- ^ Inline constructor -> Parser [Char] ParserState Inline -- ^ content parser (to be used repeatedly) -simpleInline border construct = surrounded border (inlineWithAttribute) >>= +simpleInline border construct = surrounded border inlineWithAttribute >>= return . construct . normalizeSpaces where inlineWithAttribute = (try $ optional attributes) >> inline diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 641652276..2c6435457 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -524,7 +524,7 @@ blockToHtml opts (DefinitionList lst) = do contents <- mapM (\(term, defs) -> do term' <- if null term then return mempty - else liftM (H.dt) $ inlineListToHtml opts term + else liftM H.dt $ inlineListToHtml opts term defs' <- mapM ((liftM (\x -> H.dd $ (x >> nl opts))) . blockListToHtml opts) defs return $ mconcat $ nl opts : term' : nl opts : diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index 61741a61e..83fefaa29 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -51,7 +51,7 @@ data WriterState = WriterState { writeMediaWiki :: WriterOptions -> Pandoc -> String writeMediaWiki opts document = evalState (pandocToMediaWiki opts document) - (WriterState { stNotes = False, stListLevel = [], stUseTags = False }) + WriterState { stNotes = False, stListLevel = [], stUseTags = False } -- | Return MediaWiki representation of document. pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index 7c102cc86..95aedf780 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -51,7 +51,7 @@ data WriterState = WriterState { writeTextile :: WriterOptions -> Pandoc -> String writeTextile opts document = evalState (pandocToTextile opts document) - (WriterState { stNotes = [], stListLevel = [], stUseTags = False }) + WriterState { stNotes = [], stListLevel = [], stUseTags = False } -- | Return Textile representation of document. pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String diff --git a/tests/Tests/Readers/LaTeX.hs b/tests/Tests/Readers/LaTeX.hs index c1efd1b68..8ff23ebc1 100644 --- a/tests/Tests/Readers/LaTeX.hs +++ b/tests/Tests/Readers/LaTeX.hs @@ -21,7 +21,7 @@ tests = [ testGroup "basic" [ "simple" =: "word" =?> para "word" , "space" =: - "some text" =?> para ("some text") + "some text" =?> para "some text" , "emphasized" =: "\\emph{emphasized}" =?> para (emph "emphasized") ] diff --git a/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs index b04ff9a0d..492680a35 100644 --- a/tests/Tests/Readers/Markdown.hs +++ b/tests/Tests/Readers/Markdown.hs @@ -171,13 +171,13 @@ tests = [ testGroup "inline code" , testGroup "smart punctuation" [ test markdownSmart "quote before ellipses" ("'...hi'" - =?> para (singleQuoted ("…hi"))) + =?> para (singleQuoted "…hi")) , test markdownSmart "apostrophe before emph" ("D'oh! A l'*aide*!" =?> para ("D’oh! A l’" <> emph "aide" <> "!")) , test markdownSmart "apostrophe in French" ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»" - =?> para ("À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")) + =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»") ] , testGroup "mixed emphasis and strong" [ "emph and strong emph alternating" =: -- cgit v1.2.3 From c8fc0a03748ceb4dbea502297ece89eac9d73aff Mon Sep 17 00:00:00 2001 From: Henry de Valence <hdevalence@hdevalence.ca> Date: Thu, 19 Dec 2013 20:46:11 -0500 Subject: HLint: use /= --- src/Text/Pandoc/Writers/LaTeX.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 47b769c48..1deacecb4 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -190,7 +190,7 @@ stringToLaTeX _ [] = return "" stringToLaTeX ctx (x:xs) = do opts <- gets stOptions rest <- stringToLaTeX ctx xs - let ligatures = writerTeXLigatures opts && not (ctx == CodeString) + let ligatures = writerTeXLigatures opts && (ctx /= CodeString) let isUrl = ctx == URLString when (x == '€') $ modify $ \st -> st{ stUsesEuro = True } -- cgit v1.2.3 From 3d70059a4896c66cab59832a3ed9eb8334b84a2f Mon Sep 17 00:00:00 2001 From: Henry de Valence <hdevalence@hdevalence.ca> Date: Thu, 19 Dec 2013 21:07:09 -0500 Subject: HLint: use fromMaybe Replace uses of `maybe x id` with `fromMaybe x`. --- src/Text/Pandoc/PDF.hs | 3 ++- src/Text/Pandoc/Readers/DocBook.hs | 7 ++++--- src/Text/Pandoc/Readers/HTML.hs | 4 ++-- src/Text/Pandoc/Readers/Markdown.hs | 4 ++-- src/Text/Pandoc/Readers/MediaWiki.hs | 7 ++++--- src/Text/Pandoc/Writers/Docx.hs | 6 ++++-- src/Text/Pandoc/Writers/EPUB.hs | 12 ++++++------ src/Text/Pandoc/Writers/HTML.hs | 4 ++-- src/Text/Pandoc/Writers/LaTeX.hs | 3 ++- src/Text/Pandoc/Writers/ODT.hs | 3 ++- 10 files changed, 30 insertions(+), 23 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index e8683b98f..360338f8f 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -41,6 +41,7 @@ import System.Directory import System.Environment import Control.Monad (unless) import Data.List (isInfixOf) +import Data.Maybe (fromMaybe) import qualified Data.ByteString.Base64 as B64 import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Definition @@ -87,7 +88,7 @@ handleImage' baseURL tmpdir (Image ils (src,tit)) = do res <- fetchItem baseURL src case res of Right (contents, Just mime) -> do - let ext = maybe (takeExtension src) id $ + let ext = fromMaybe (takeExtension src) $ extensionFromMimeType mime let basename = UTF8.toString $ B64.encode $ UTF8.fromString src let fname = tmpdir </> basename <.> ext diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 03c6140ac..56cb16b20 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -12,6 +12,7 @@ import Data.Char (isSpace) import Control.Monad.State import Control.Applicative ((<$>)) import Data.List (intersperse) +import Data.Maybe (fromMaybe) {- @@ -683,7 +684,7 @@ parseBlock (Elem e) = "lowerroman" -> LowerRoman "upperroman" -> UpperRoman _ -> Decimal - let start = maybe 1 id $ + let start = fromMaybe 1 $ (attrValue "override" <$> filterElement (named "listitem") e) >>= safeRead orderedListWith (start,listStyle,DefaultDelim) @@ -779,7 +780,7 @@ parseBlock (Elem e) = caption <- case filterChild isCaption e of Just t -> getInlines t Nothing -> return mempty - let e' = maybe e id $ filterChild (named "tgroup") e + let e' = fromMaybe e $ filterChild (named "tgroup") e let isColspec x = named "colspec" x || named "col" x let colspecs = case filterChild (named "colgroup") e' of Just c -> filterChildren isColspec c @@ -801,7 +802,7 @@ parseBlock (Elem e) = Just "center" -> AlignCenter _ -> AlignDefault let toWidth c = case findAttr (unqual "colwidth") c of - Just w -> maybe 0 id + Just w -> fromMaybe 0 $ safeRead $ '0': filter (\x -> (x >= '0' && x <= '9') || x == '.') w diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index e758f712f..4b44a3a21 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -207,7 +207,7 @@ pHeader = try $ do let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")] let level = read (drop 1 tagtype) contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof) - let ident = maybe "" id $ lookup "id" attr + let ident = fromMaybe "" $ lookup "id" attr let classes = maybe [] words $ lookup "class" attr let keyvals = [(k,v) | (k,v) <- attr, k /= "class", k /= "id"] return $ if bodyTitle @@ -257,7 +257,7 @@ pCol = try $ do skipMany pBlank return $ case lookup "width" attribs of Just x | not (null x) && last x == '%' -> - maybe 0.0 id $ safeRead ('0':'.':init x) + fromMaybe 0.0 $ safeRead ('0':'.':init x) _ -> 0.0 pColgroup :: TagParser [Double] diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 166c524ef..3a5d29b4e 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1722,7 +1722,7 @@ spanHtml = try $ do guardEnabled Ext_markdown_in_html_blocks (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "span" []) contents <- mconcat <$> manyTill inline (htmlTag (~== TagClose "span")) - let ident = maybe "" id $ lookup "id" attrs + let ident = fromMaybe "" $ lookup "id" attrs let classes = maybe [] words $ lookup "class" attrs let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"] return $ B.spanWith (ident, classes, keyvals) <$> contents @@ -1732,7 +1732,7 @@ divHtml = try $ do guardEnabled Ext_markdown_in_html_blocks (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "div" []) contents <- mconcat <$> manyTill block (htmlTag (~== TagClose "div")) - let ident = maybe "" id $ lookup "id" attrs + let ident = fromMaybe "" $ lookup "id" attrs let classes = maybe [] words $ lookup "class" attrs let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"] return $ B.divWith (ident, classes, keyvals) <$> contents diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index 1c074e3de..8d8ea0199 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -54,6 +54,7 @@ import Data.Sequence (viewl, ViewL(..), (<|)) import qualified Data.Foldable as F import qualified Data.Map as M import Data.Char (isDigit, isSpace) +import Data.Maybe (fromMaybe) -- | Read mediawiki from an input string and return a Pandoc document. readMediaWiki :: ReaderOptions -- ^ Reader options @@ -204,7 +205,7 @@ table = do tableStart styles <- option [] parseAttrs <* blankline let tableWidth = case lookup "width" styles of - Just w -> maybe 1.0 id $ parseWidth w + Just w -> fromMaybe 1.0 $ parseWidth w Nothing -> 1.0 caption <- option mempty tableCaption optional rowsep @@ -285,7 +286,7 @@ tableCell = try $ do Just "center" -> AlignCenter _ -> AlignDefault let width = case lookup "width" attrs of - Just xs -> maybe 0.0 id $ parseWidth xs + Just xs -> fromMaybe 0.0 $ parseWidth xs Nothing -> 0.0 return ((align, width), bs) @@ -387,7 +388,7 @@ orderedList = spaces items <- many (listItem '#' <|> li) optional (htmlTag (~== TagClose "ol")) - let start = maybe 1 id $ safeRead $ fromAttrib "start" tag + let start = fromMaybe 1 $ safeRead $ fromAttrib "start" tag return $ B.orderedListWith (start, DefaultStyle, DefaultDelim) items definitionList :: MWParser Blocks diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 5c7341b69..32ba7715a 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of 'Pandoc' documents to docx. -} module Text.Pandoc.Writers.Docx ( writeDocx ) where +import Data.Maybe (fromMaybe) import Data.List ( intercalate, groupBy ) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL @@ -130,7 +131,8 @@ writeDocx opts doc@(Pandoc meta _) = do let mkOverrideNode (part', contentType') = mknode "Override" [("PartName",part'),("ContentType",contentType')] () let mkImageOverride (_, imgpath, mbMimeType, _, _) = - mkOverrideNode ("/word/" ++ imgpath, maybe "application/octet-stream" id mbMimeType) + mkOverrideNode ("/word/" ++ imgpath, + fromMaybe "application/octet-stream" mbMimeType) let overrides = map mkOverrideNode [("/word/webSettings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml") @@ -322,7 +324,7 @@ mkNum markers marker numid = NumberMarker _ _ start -> map (\lvl -> mknode "w:lvlOverride" [("w:ilvl",show (lvl :: Int))] $ mknode "w:startOverride" [("w:val",show start)] ()) [0..6] - where absnumid = maybe 0 id $ M.lookup marker markers + where absnumid = fromMaybe 0 $ M.lookup marker markers mkAbstractNum :: (ListMarker,Int) -> IO Element mkAbstractNum (marker,numid) = do diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 36ead0b8f..4daa9609e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -176,8 +176,8 @@ addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md , titleFileAs = getAttr "file-as" , titleType = getAttr "type" } : epubTitle md } - | name == "date" = md{ epubDate = maybe "" id $ normalizeDate' - $ strContent e } + | name == "date" = md{ epubDate = fromMaybe "" $ normalizeDate' + $ strContent e } | name == "language" = md{ epubLanguage = strContent e } | name == "creator" = md{ epubCreator = Creator{ creatorText = strContent e @@ -271,7 +271,7 @@ metadataFromMeta opts meta = EPUBMetadata{ } where identifiers = getIdentifier meta titles = getTitle meta - date = maybe "" id $ + date = fromMaybe "" $ (metaValueToString <$> lookupMeta "date" meta) >>= normalizeDate' language = maybe "" metaValueToString $ lookupMeta "language" meta `mplus` lookupMeta "lang" meta @@ -297,7 +297,7 @@ writeEPUB :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString writeEPUB opts doc@(Pandoc meta _) = do - let version = maybe EPUB2 id (writerEpubVersion opts) + let version = fromMaybe EPUB2 (writerEpubVersion opts) let epub3 = version == EPUB3 epochtime <- floor `fmap` getPOSIXTime let mkEntry path content = toEntry path epochtime content @@ -401,7 +401,7 @@ writeEPUB opts doc@(Pandoc meta _) = do chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num) $ renderHtml $ writeHtml opts'{ writerNumberOffset = - maybe [] id mbnum } + fromMaybe [] mbnum } $ case bs of (Header _ _ xs : _) -> Pandoc (setMeta "title" (fromList xs) nullMeta) bs @@ -436,7 +436,7 @@ writeEPUB opts doc@(Pandoc meta _) = do let fontNode ent = unode "item" ! [("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), - ("media-type", maybe "" id $ getMimeType $ eRelativePath ent)] $ () + ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ () let plainTitle = case docTitle meta of [] -> case epubTitle metadata of [] -> "UNTITLED" diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 2c6435457..129776363 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -45,7 +45,7 @@ import Numeric ( showHex ) import Data.Char ( ord, toLower ) import Data.List ( isPrefixOf, intersperse ) import Data.String ( fromString ) -import Data.Maybe ( catMaybes ) +import Data.Maybe ( catMaybes, fromMaybe ) import Control.Monad.State import Text.Blaze.Html hiding(contents) import Text.Blaze.Internal(preEscapedString) @@ -118,7 +118,7 @@ pandocToHtml opts (Pandoc meta blocks) = do let stringifyHTML = escapeStringForXML . stringify let authsMeta = map stringifyHTML $ docAuthors meta let dateMeta = stringifyHTML $ docDate meta - let slideLevel = maybe (getSlideLevel blocks) id $ writerSlideLevel opts + let slideLevel = fromMaybe (getSlideLevel blocks) $ writerSlideLevel opts let sects = hierarchicalize $ if writerSlideVariant opts == NoSlides then blocks diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 1deacecb4..a76d6d82b 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -40,6 +40,7 @@ import Network.URI ( isURI, unEscapeString ) import Data.List ( (\\), isSuffixOf, isInfixOf, isPrefixOf, intercalate, intersperse ) import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord ) +import Data.Maybe ( fromMaybe ) import Control.Applicative ((<|>)) import Control.Monad.State import Text.Pandoc.Pretty @@ -240,7 +241,7 @@ inCmd cmd contents = char '\\' <> text cmd <> braces contents toSlides :: [Block] -> State WriterState [Block] toSlides bs = do opts <- gets stOptions - let slideLevel = maybe (getSlideLevel bs) id $ writerSlideLevel opts + let slideLevel = fromMaybe (getSlideLevel bs) $ writerSlideLevel opts let bs' = prepSlides slideLevel bs concat `fmap` (mapM (elementToBeamer slideLevel) $ hierarchicalize bs') diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index cc0a06243..25cd5ae13 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -31,6 +31,7 @@ Conversion of 'Pandoc' documents to ODT. module Text.Pandoc.Writers.ODT ( writeODT ) where import Data.IORef import Data.List ( isPrefixOf ) +import Data.Maybe ( fromMaybe ) import qualified Data.ByteString.Lazy as B import Text.Pandoc.UTF8 ( fromStringLazy ) import Codec.Archive.Zip @@ -127,7 +128,7 @@ transformPic opts entriesRef (Image lab (src,_)) = do return $ Emph lab Right (img, _) -> do let size = imageSize img - let (w,h) = maybe (0,0) id $ sizeInPoints `fmap` size + let (w,h) = fromMaybe (0,0) $ sizeInPoints `fmap` size let tit' = show w ++ "x" ++ show h entries <- readIORef entriesRef let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src -- cgit v1.2.3 From d6ec6cf9cf5731977fa0f476cabef4786edd5665 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Wed, 1 Jan 2014 09:01:05 -0800 Subject: Docx writer: Fixed problem with some modified reference docx files. Include `word/_rels/settings.xml.rels` if it exists, as well as other `rels` files besides the ones pandoc generates explicitly. --- src/Text/Pandoc/Writers/Docx.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 32ba7715a..67d202010 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -30,7 +30,7 @@ Conversion of 'Pandoc' documents to docx. -} module Text.Pandoc.Writers.Docx ( writeDocx ) where import Data.Maybe (fromMaybe) -import Data.List ( intercalate, groupBy ) +import Data.List ( intercalate, groupBy, isPrefixOf ) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 @@ -262,6 +262,11 @@ writeDocx opts doc@(Pandoc meta _) = do fontTableEntry <- entryFromArchive "word/fontTable.xml" settingsEntry <- entryFromArchive "word/settings.xml" webSettingsEntry <- entryFromArchive "word/webSettings.xml" + let miscRels = [ f | f <- filesInArchive refArchive + , "word/_rels/" `isPrefixOf` f + , f /= "word/_rels/document.xml.rels" + , f /= "word/_rels/footnotes.xml.rels" ] + miscRelEntries <- mapM entryFromArchive miscRels -- Create archive let archive = foldr addEntryToArchive emptyArchive $ @@ -269,7 +274,7 @@ writeDocx opts doc@(Pandoc meta _) = do footnoteRelEntry : numEntry : styleEntry : footnotesEntry : docPropsEntry : docPropsAppEntry : themeEntry : fontTableEntry : settingsEntry : webSettingsEntry : - imageEntries + imageEntries ++ miscRelEntries return $ fromArchive archive styleToOpenXml :: Style -> [Element] -- cgit v1.2.3 From e3d48da6271a37129ae5bdb6cb57f006de8c5bfc Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 2 Jan 2014 15:22:50 -0800 Subject: Moved fixDisplayMath from Docx writer to Writer.Shared. --- src/Text/Pandoc/Writers/Docx.hs | 27 ++------------------------- src/Text/Pandoc/Writers/Shared.hs | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 25 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 67d202010..25739f7c8 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -30,7 +30,7 @@ Conversion of 'Pandoc' documents to docx. -} module Text.Pandoc.Writers.Docx ( writeDocx ) where import Data.Maybe (fromMaybe) -import Data.List ( intercalate, groupBy, isPrefixOf ) +import Data.List ( intercalate, isPrefixOf ) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 @@ -43,6 +43,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.ImageSize import Text.Pandoc.Shared hiding (Element) +import Text.Pandoc.Writers.Shared (fixDisplayMath) import Text.Pandoc.Options import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Highlighting ( highlight ) @@ -817,27 +818,3 @@ parseXml refArchive relpath = case (findEntryByPath relpath refArchive >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of Just d -> return d Nothing -> fail $ relpath ++ " missing in reference docx" - -isDisplayMath :: Inline -> Bool -isDisplayMath (Math DisplayMath _) = True -isDisplayMath _ = False - -stripLeadingTrailingSpace :: [Inline] -> [Inline] -stripLeadingTrailingSpace = go . reverse . go . reverse - where go (Space:xs) = xs - go xs = xs - -fixDisplayMath :: Block -> Block -fixDisplayMath (Plain lst) - | any isDisplayMath lst && not (all isDisplayMath lst) = - -- chop into several paragraphs so each displaymath is its own - Div ("",["math"],[]) $ map (Plain . stripLeadingTrailingSpace) $ - groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || - not (isDisplayMath x || isDisplayMath y)) lst -fixDisplayMath (Para lst) - | any isDisplayMath lst && not (all isDisplayMath lst) = - -- chop into several paragraphs so each displaymath is its own - Div ("",["math"],[]) $ map (Para . stripLeadingTrailingSpace) $ - groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || - not (isDisplayMath x || isDisplayMath y)) lst -fixDisplayMath x = x diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 33091ea94..604aac1c9 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -34,6 +34,7 @@ module Text.Pandoc.Writers.Shared ( , setField , defField , tagWithAttrs + , fixDisplayMath ) where import Text.Pandoc.Definition @@ -46,6 +47,7 @@ import qualified Data.Map as M import qualified Data.Text as T import Data.Aeson (FromJSON(..), fromJSON, ToJSON (..), Value(Object), Result(..)) import qualified Data.Traversable as Traversable +import Data.List ( groupBy ) -- | Create JSON value for template from a 'Meta' and an association list -- of variables, specified at the command line or in the writer. @@ -136,3 +138,28 @@ tagWithAttrs tag (ident,classes,kvs) = hsep ,hsep (map (\(k,v) -> text k <> "=" <> doubleQuotes (text (escapeStringForXML v))) kvs) ] <> ">" + +isDisplayMath :: Inline -> Bool +isDisplayMath (Math DisplayMath _) = True +isDisplayMath _ = False + +stripLeadingTrailingSpace :: [Inline] -> [Inline] +stripLeadingTrailingSpace = go . reverse . go . reverse + where go (Space:xs) = xs + go xs = xs + +-- Put display math in its own block (for ODT/DOCX). +fixDisplayMath :: Block -> Block +fixDisplayMath (Plain lst) + | any isDisplayMath lst && not (all isDisplayMath lst) = + -- chop into several paragraphs so each displaymath is its own + Div ("",["math"],[]) $ map (Plain . stripLeadingTrailingSpace) $ + groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || + not (isDisplayMath x || isDisplayMath y)) lst +fixDisplayMath (Para lst) + | any isDisplayMath lst && not (all isDisplayMath lst) = + -- chop into several paragraphs so each displaymath is its own + Div ("",["math"],[]) $ map (Para . stripLeadingTrailingSpace) $ + groupBy (\x y -> (isDisplayMath x && isDisplayMath y) || + not (isDisplayMath x || isDisplayMath y)) lst +fixDisplayMath x = x -- cgit v1.2.3 From ac100f27249e4c572e687d027330ca2cc53cb1ed Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 2 Jan 2014 15:23:16 -0800 Subject: OpenDocument writer: Fixed RawInline, RawBlock so they don't escape. --- src/Text/Pandoc/Writers/OpenDocument.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 4ddfd7166..0029c3296 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -285,8 +285,12 @@ blocksToOpenDocument o b = vcat <$> mapM (blockToOpenDocument o) b -- | Convert a Pandoc block element to OpenDocument. blockToOpenDocument :: WriterOptions -> Block -> State WriterState Doc blockToOpenDocument o bs - | Plain b <- bs = inParagraphTags =<< inlinesToOpenDocument o b - | Para b <- bs = inParagraphTags =<< inlinesToOpenDocument o b + | Plain b <- bs = if null b + then return empty + else inParagraphTags =<< inlinesToOpenDocument o b + | Para b <- bs = if null b + then return empty + else inParagraphTags =<< inlinesToOpenDocument o b | Div _ xs <- bs = blocksToOpenDocument o xs | Header i _ b <- bs = setFirstPara >> (inHeaderTags i =<< inlinesToOpenDocument o b) @@ -298,8 +302,8 @@ blockToOpenDocument o bs | Table c a w h r <- bs = setFirstPara >> table c a w h r | HorizontalRule <- bs = setFirstPara >> return (selfClosingTag "text:p" [ ("text:style-name", "Horizontal_20_Line") ]) - | RawBlock f s <- bs = if f == "opendocument" - then preformatted s + | RawBlock f s <- bs = if f == Format "opendocument" + then return $ text s else return empty | Null <- bs = return empty | otherwise = return empty @@ -378,8 +382,8 @@ inlineToOpenDocument o ils | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s | Math t s <- ils = inlinesToOpenDocument o (readTeXMath' t s) | Cite _ l <- ils = inlinesToOpenDocument o l - | RawInline f s <- ils = if f == "opendocument" - then return $ preformatted s + | RawInline f s <- ils = if f == Format "opendocument" + then return $ text s else return empty | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l | Image _ (s,t) <- ils = mkImg s t -- cgit v1.2.3 From 33955fd2efd640becfddb262c4443509521cb6cc Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 2 Jan 2014 15:23:40 -0800 Subject: ODT writer: Use mathml for proper rendering of formulas. Note: LibreOffice's support for this seems a bit buggy. But it should be better than what we had before. --- src/Text/Pandoc/Writers/ODT.hs | 50 +++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 25cd5ae13..c3652d65d 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -30,8 +30,10 @@ Conversion of 'Pandoc' documents to ODT. -} module Text.Pandoc.Writers.ODT ( writeODT ) where import Data.IORef -import Data.List ( isPrefixOf ) +import Data.List ( isPrefixOf, isSuffixOf ) import Data.Maybe ( fromMaybe ) +import Text.XML.Light.Output +import Text.TeXMath import qualified Data.ByteString.Lazy as B import Text.Pandoc.UTF8 ( fromStringLazy ) import Codec.Archive.Zip @@ -41,13 +43,14 @@ import Text.Pandoc.ImageSize ( imageSize, sizeInPoints ) import Text.Pandoc.MIME ( getMimeType ) import Text.Pandoc.Definition import Text.Pandoc.Walk +import Text.Pandoc.Writers.Shared ( fixDisplayMath ) import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) import Control.Monad (liftM) import Text.Pandoc.XML import Text.Pandoc.Pretty import qualified Control.Exception as E import Data.Time.Clock.POSIX ( getPOSIXTime ) -import System.FilePath ( takeExtension ) +import System.FilePath ( takeExtension, takeDirectory ) -- | Produce an ODT file from a Pandoc document. writeODT :: WriterOptions -- ^ Writer options @@ -61,9 +64,9 @@ writeODT opts doc@(Pandoc meta _) = do Just f -> B.readFile f Nothing -> (B.fromChunks . (:[])) `fmap` readDataFile datadir "reference.odt" - -- handle pictures + -- handle formulas and pictures picEntriesRef <- newIORef ([] :: [Entry]) - doc' <- walkM (transformPic opts picEntriesRef) doc + doc' <- walkM (transformPicMath opts picEntriesRef) $ walk fixDisplayMath doc let newContents = writeOpenDocument opts{writerWrapText = False} doc' epochtime <- floor `fmap` getPOSIXTime let contentEntry = toEntry "content.xml" epochtime @@ -73,7 +76,11 @@ writeODT opts doc@(Pandoc meta _) = do $ contentEntry : picEntries -- construct META-INF/manifest.xml based on archive let toFileEntry fp = case getMimeType fp of - Nothing -> empty + Nothing -> if "Formula-" `isPrefixOf` fp && "/" `isSuffixOf` fp + then selfClosingTag "manifest:file-entry" + [("manifest:media-type","application/vnd.oasis.opendocument.formula") + ,("manifest:full-path",fp)] + else empty Just m -> selfClosingTag "manifest:file-entry" [("manifest:media-type", m) ,("manifest:full-path", fp) @@ -81,6 +88,8 @@ writeODT opts doc@(Pandoc meta _) = do ] let files = [ ent | ent <- filesInArchive archive, not ("META-INF" `isPrefixOf` ent) ] + let formulas = [ takeDirectory ent ++ "/" | ent <- filesInArchive archive, + "Formula-" `isPrefixOf` ent, takeExtension ent == ".xml" ] let manifestEntry = toEntry "META-INF/manifest.xml" epochtime $ fromStringLazy $ render Nothing $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>" @@ -92,6 +101,7 @@ writeODT opts doc@(Pandoc meta _) = do [("manifest:media-type","application/vnd.oasis.opendocument.text") ,("manifest:full-path","/")] $$ vcat ( map toFileEntry $ files ) + $$ vcat ( map toFileEntry $ formulas ) ) ) let archive' = addEntryToArchive manifestEntry archive @@ -119,8 +129,8 @@ writeODT opts doc@(Pandoc meta _) = do $ addEntryToArchive metaEntry archive' return $ fromArchive archive'' -transformPic :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline -transformPic opts entriesRef (Image lab (src,_)) = do +transformPicMath :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline +transformPicMath opts entriesRef (Image lab (src,_)) = do res <- fetchItem (writerSourceURL opts) src case res of Left (_ :: E.SomeException) -> do @@ -137,5 +147,29 @@ transformPic opts entriesRef (Image lab (src,_)) = do let entry = toEntry newsrc epochtime $ toLazy img modifyIORef entriesRef (entry:) return $ Image lab (newsrc, tit') -transformPic _ _ x = return x +transformPicMath _ entriesRef (Math t math) = do + entries <- readIORef entriesRef + let dt = if t == InlineMath then DisplayInline else DisplayBlock + case texMathToMathML dt math of + Left _ -> return $ Math t math + Right r -> do + let conf = useShortEmptyTags (const False) defaultConfigPP + let mathml = ppcTopElement conf r + epochtime <- floor `fmap` getPOSIXTime + let dirname = "Formula-" ++ show (length entries) ++ "/" + let fname = dirname ++ "content.xml" + let entry = toEntry fname epochtime (fromStringLazy mathml) + modifyIORef entriesRef (entry:) + return $ RawInline (Format "opendocument") $ render Nothing $ + inTags False "draw:frame" [("text:anchor-type", + if t == DisplayMath + then "paragraph" + else "as-char") + ,("style:vertical-pos", "middle") + ,("style:vertical-rel", "text")] $ + selfClosingTag "draw:object" [("xlink:href", dirname) + , ("xlink:type", "simple") + , ("xlink:show", "embed") + , ("xlink:actuate", "onLoad")] +transformPicMath _ _ x = return x -- cgit v1.2.3 From b2db6979fedc5f66d45596c9564a8313af90b9fa Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 2 Jan 2014 19:32:13 -0800 Subject: Use isHeaderBlock from Shared rather than defining it anew... --- src/Text/Pandoc/Writers/FB2.hs | 6 ++---- src/Text/Pandoc/Writers/Texinfo.hs | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs index adbe948be..803617f95 100644 --- a/src/Text/Pandoc/Writers/FB2.hs +++ b/src/Text/Pandoc/Writers/FB2.hs @@ -44,7 +44,7 @@ import qualified Text.XML.Light.Cursor as XC import Text.Pandoc.Definition import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def) -import Text.Pandoc.Shared (orderedListMarkers) +import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock) import Text.Pandoc.Walk -- | Data to be written at the end of the document: @@ -157,9 +157,7 @@ renderSection level (ttl, body) = do else cMapM blockToXml body return $ el "section" (title ++ content) where - hasSubsections = any isHeader - isHeader (Header _ _ _) = True - isHeader _ = False + hasSubsections = any isHeaderBlock -- | Only <p> and <empty-line> are allowed within <title> in FB2. formatTitle :: [Inline] -> [Content] diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs index d62e50880..bf3df8035 100644 --- a/src/Text/Pandoc/Writers/Texinfo.hs +++ b/src/Text/Pandoc/Writers/Texinfo.hs @@ -293,7 +293,7 @@ blockListToTexinfo (x:xs) = do case x of Header level _ _ -> do -- We need need to insert a menu for this node. - let (before, after) = break isHeader xs + let (before, after) = break isHeaderBlock xs before' <- blockListToTexinfo before let menu = if level < 4 then collectNodes (level + 1) after @@ -315,10 +315,6 @@ blockListToTexinfo (x:xs) = do xs' <- blockListToTexinfo xs return $ x' $$ xs' -isHeader :: Block -> Bool -isHeader (Header _ _ _) = True -isHeader _ = False - collectNodes :: Int -> [Block] -> [Block] collectNodes _ [] = [] collectNodes level (x:xs) = -- cgit v1.2.3 From 4e7aadb903548bb08c9132c93699071e52f61d76 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 2 Jan 2014 19:59:33 -0800 Subject: HTML writer: With --toc, headers no longer link to themselves. Closes #1081. --- src/Text/Pandoc/Writers/HTML.hs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 129776363..c8a7e802b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -475,28 +475,21 @@ blockToHtml opts (BlockQuote blocks) = else do contents <- blockListToHtml opts blocks return $ H.blockquote $ nl opts >> contents >> nl opts -blockToHtml opts (Header level (ident,_,_) lst) = do +blockToHtml opts (Header level (_,_,_) lst) = do contents <- inlineListToHtml opts lst secnum <- liftM stSecNum get let contents' = if writerNumberSections opts && not (null secnum) then (H.span ! A.class_ "header-section-number" $ toHtml $ showSecNum secnum) >> strToHtml " " >> contents else contents - let revealSlash = ['/' | writerSlideVariant opts == RevealJsSlides] - let contents'' = if writerTableOfContents opts && not (null ident) - then H.a ! A.href (toValue $ - '#' : revealSlash ++ - writerIdentifierPrefix opts ++ - ident) $ contents' - else contents' return $ case level of - 1 -> H.h1 contents'' - 2 -> H.h2 contents'' - 3 -> H.h3 contents'' - 4 -> H.h4 contents'' - 5 -> H.h5 contents'' - 6 -> H.h6 contents'' - _ -> H.p contents'' + 1 -> H.h1 contents' + 2 -> H.h2 contents' + 3 -> H.h3 contents' + 4 -> H.h4 contents' + 5 -> H.h5 contents' + 6 -> H.h6 contents' + _ -> H.p contents' blockToHtml opts (BulletList lst) = do contents <- mapM (blockListToHtml opts) lst return $ unordList opts contents -- cgit v1.2.3 From e7e76dbdd8b07b1fd80bda1599d58b7fbc7cf4bd Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Thu, 2 Jan 2014 21:10:14 -0800 Subject: RST writer: Ensure no blank line after def in definition list. Closes #992. --- src/Text/Pandoc/Writers/RST.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 1a62f7250..37bb66632 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -287,7 +287,7 @@ definitionListItemToRST (label, defs) = do label' <- inlineListToRST label contents <- liftM vcat $ mapM blockListToRST defs tabstop <- get >>= (return . writerTabStop . stOptions) - return $ label' $$ nest tabstop (contents <> cr) + return $ label' $$ nest tabstop (nestle contents <> cr) -- | Convert list of Pandoc block elements to RST. blockListToRST :: [Block] -- ^ List of block elements -- cgit v1.2.3 From 2dd6d892fa310135cece1d8e6d6bac7b538f4e76 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 6 Jan 2014 10:17:31 -0800 Subject: HTML writer: Omit footnotes from TOC entries. Otherwise we get doubled footnotes when headers have notes! --- src/Text/Pandoc/Writers/HTML.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index c8a7e802b..805bb57f1 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -749,7 +749,9 @@ inlineToHtml opts inline = else [A.title $ toValue tit]) return $ foldl (!) H5.embed attributes -- note: null title included, as in Markdown.pl - (Note contents) -> do + (Note contents) + | writerIgnoreNotes opts -> return mempty + | otherwise -> do st <- get let notes = stNotes st let number = (length notes) + 1 -- cgit v1.2.3 From ba6a26b25871a3912556f1a17330d2363b3f3db5 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 6 Jan 2014 12:12:21 -0800 Subject: EPUB writer: Avoid duplicate notes when headings contain notes. This arose because the headings are copied into the metadata "title" field, and the note gets rendered twice. We strip the note now before putting the heading in "title". --- src/Text/Pandoc/Writers/EPUB.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 4daa9609e..d2dd7da2e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -397,6 +397,10 @@ writeEPUB opts doc@(Pandoc meta _) = do let chapters = evalState (toChapters blocks'') [] + let removeNote :: Inline -> Inline + removeNote (Note _) = Str "" + removeNote x = x + let chapToEntry :: Int -> Chapter -> Entry chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num) $ renderHtml @@ -404,7 +408,9 @@ writeEPUB opts doc@(Pandoc meta _) = do fromMaybe [] mbnum } $ case bs of (Header _ _ xs : _) -> - Pandoc (setMeta "title" (fromList xs) nullMeta) bs + -- remove notes or we get doubled footnotes + Pandoc (setMeta "title" (walk removeNote $ fromList xs) + nullMeta) bs _ -> Pandoc nullMeta bs -- cgit v1.2.3 From d97b1fd14cd2b0f96fcf3bcc10cfc2540fbbe624 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 6 Jan 2014 21:51:11 -0800 Subject: EPUB writer: Strip out footnotes from toc entries. --- src/Text/Pandoc/Writers/EPUB.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index d2dd7da2e..a48300939 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -124,7 +124,12 @@ opfName n = QName n Nothing (Just "opf") plainify :: [Inline] -> String plainify t = - trimr $ writePlain def{ writerStandalone = False } $ Pandoc nullMeta [Plain t] + trimr $ writePlain def{ writerStandalone = False } + $ Pandoc nullMeta [Plain $ walk removeNote t] + +removeNote :: Inline -> Inline +removeNote (Note _) = Str "" +removeNote x = x getEPUBMetadata :: WriterOptions -> Meta -> IO EPUBMetadata getEPUBMetadata opts meta = do @@ -397,10 +402,6 @@ writeEPUB opts doc@(Pandoc meta _) = do let chapters = evalState (toChapters blocks'') [] - let removeNote :: Inline -> Inline - removeNote (Note _) = Str "" - removeNote x = x - let chapToEntry :: Int -> Chapter -> Entry chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num) $ renderHtml -- cgit v1.2.3 From 002c8ce14ca15bfbc800e9628cf09babf3d96acd Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Tue, 7 Jan 2014 09:01:32 -0800 Subject: Fixed small regression in docx writer. --- src/Text/Pandoc/Writers/Docx.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 25739f7c8..2a834c2da 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -30,7 +30,7 @@ Conversion of 'Pandoc' documents to docx. -} module Text.Pandoc.Writers.Docx ( writeDocx ) where import Data.Maybe (fromMaybe) -import Data.List ( intercalate, isPrefixOf ) +import Data.List ( intercalate, isPrefixOf, isSuffixOf ) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 @@ -265,6 +265,7 @@ writeDocx opts doc@(Pandoc meta _) = do webSettingsEntry <- entryFromArchive "word/webSettings.xml" let miscRels = [ f | f <- filesInArchive refArchive , "word/_rels/" `isPrefixOf` f + , ".xml.rels" `isSuffixOf` f , f /= "word/_rels/document.xml.rels" , f /= "word/_rels/footnotes.xml.rels" ] miscRelEntries <- mapM entryFromArchive miscRels @@ -815,6 +816,8 @@ br = mknode "w:r" [] [mknode "w:br" [("w:type","textWrapping")] () ] parseXml :: Archive -> String -> IO Element parseXml refArchive relpath = - case (findEntryByPath relpath refArchive >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of - Just d -> return d + case findEntryByPath relpath refArchive of + Just e -> case parseXMLDoc $ UTF8.toStringLazy $ fromEntry e of + Just d -> return d + Nothing -> fail $ relpath ++ " corrupt in reference docx" Nothing -> fail $ relpath ++ " missing in reference docx" -- cgit v1.2.3 From 3f0fe345f9aa69d1faf36e6a6f913013f21b3749 Mon Sep 17 00:00:00 2001 From: Vaclav Zeman <vhaisman@gmail.com> Date: Sat, 8 Feb 2014 13:40:04 +0100 Subject: Use \/ to avoid en-dash ligature instead of -{}-. This is to fix LuaLaTeX output. The -{}- sequence does not avoid the ligature with LuaLaTeX but \/ does. --- src/Text/Pandoc/Writers/LaTeX.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 72b0bde6d..dbb9b477a 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -201,7 +201,7 @@ stringToLaTeX ctx (x:xs) = do '_' | not isUrl -> "\\_" ++ rest '#' -> "\\#" ++ rest '-' -> case xs of -- prevent adjacent hyphens from forming ligatures - ('-':_) -> "-{}" ++ rest + ('-':_) -> "-\\/" ++ rest _ -> '-' : rest '~' | not isUrl -> "\\textasciitilde{}" ++ rest '^' -> "\\^{}" ++ rest -- cgit v1.2.3 From f6a020a906e5b03defa9924819b7f8cf2f626277 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Mon, 17 Feb 2014 15:18:52 -0800 Subject: HTML writer: Fixed bug with unnumbered section headings. Unnumbered section headings (with class 'unnumbered') were getting numbers. This commit fixes the bug. --- src/Text/Pandoc/Writers/HTML.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 805bb57f1..3ac2a836f 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -475,10 +475,11 @@ blockToHtml opts (BlockQuote blocks) = else do contents <- blockListToHtml opts blocks return $ H.blockquote $ nl opts >> contents >> nl opts -blockToHtml opts (Header level (_,_,_) lst) = do +blockToHtml opts (Header level (_,classes,_) lst) = do contents <- inlineListToHtml opts lst secnum <- liftM stSecNum get let contents' = if writerNumberSections opts && not (null secnum) + && "unnumbered" `notElem` classes then (H.span ! A.class_ "header-section-number" $ toHtml $ showSecNum secnum) >> strToHtml " " >> contents else contents -- cgit v1.2.3 From 80511f1b34d082742d78d9745469eb8c63592a9c Mon Sep 17 00:00:00 2001 From: mb21 <mb21@server.fake> Date: Sun, 1 Dec 2013 21:11:39 +0100 Subject: InDesign ICML Writer --- pandoc.cabal | 1 + src/Text/Pandoc.hs | 3 + src/Text/Pandoc/Writers/ICML.hs | 525 +++++++ tests/Tests/Old.hs | 2 +- tests/tables.icml | 748 ++++++++++ tests/writer.icml | 3023 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 4301 insertions(+), 1 deletion(-) create mode 100644 src/Text/Pandoc/Writers/ICML.hs create mode 100644 tests/tables.icml create mode 100644 tests/writer.icml (limited to 'src/Text/Pandoc/Writers') diff --git a/pandoc.cabal b/pandoc.cabal index a4b8ac61b..e279a2cc9 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -270,6 +270,7 @@ Library Text.Pandoc.Writers.Docbook, Text.Pandoc.Writers.OPML, Text.Pandoc.Writers.HTML, + Text.Pandoc.Writers.ICML, Text.Pandoc.Writers.LaTeX, Text.Pandoc.Writers.ConTeXt, Text.Pandoc.Writers.OpenDocument, diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 703bb876a..2c90fd09b 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -85,6 +85,7 @@ module Text.Pandoc , writeTexinfo , writeHtml , writeHtmlString + , writeICML , writeDocbook , writeOPML , writeOpenDocument @@ -133,6 +134,7 @@ import Text.Pandoc.Writers.ODT import Text.Pandoc.Writers.Docx import Text.Pandoc.Writers.EPUB import Text.Pandoc.Writers.FB2 +import Text.Pandoc.Writers.ICML import Text.Pandoc.Writers.Docbook import Text.Pandoc.Writers.OPML import Text.Pandoc.Writers.OpenDocument @@ -226,6 +228,7 @@ writers = [ ,("html" , PureStringWriter writeHtmlString) ,("html5" , PureStringWriter $ \o -> writeHtmlString o{ writerHtml5 = True }) + ,("icml" , PureStringWriter writeICML) ,("s5" , PureStringWriter $ \o -> writeHtmlString o{ writerSlideVariant = S5Slides , writerTableOfContents = False }) diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs new file mode 100644 index 000000000..19d486b25 --- /dev/null +++ b/src/Text/Pandoc/Writers/ICML.hs @@ -0,0 +1,525 @@ +{-# LANGUAGE OverloadedStrings #-} + +{- | + Module : Text.Pandoc.Writers.ICML + Copyright : Copyright (C) 2013 github.com/mb21 + License : GNU GPL, version 2 or above + + Stability : alpha + +Conversion of 'Pandoc' documents to Adobe InCopy ICML, a stand-alone XML format +which is a subset of the zipped IDML format for which the documentation is +available here: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/sdk/cs6/idml/idml-specification.pdf +InCopy is the companion word-processor to Adobe InDesign and ICML documents can be integrated +into InDesign with File -> Place. +-} +module Text.Pandoc.Writers.ICML (writeICML) where +import Text.Pandoc.Definition +import Text.Pandoc.XML +import Text.Pandoc.Writers.Shared +import Text.Pandoc.Shared (splitBy) +import Text.Pandoc.Options +import Text.Pandoc.Templates (renderTemplate') +import Text.Pandoc.Pretty +import Data.List (isPrefixOf, isInfixOf, stripPrefix) +import Data.Text as Text (breakOnAll, pack) +import Data.Monoid (mappend) +import Control.Monad.State +import qualified Data.Set as Set + +type Style = [String] +type Hyperlink = [(Int, String)] + +data WriterState = WriterState{ + blockStyles :: Set.Set String + , inlineStyles :: Set.Set String + , links :: Hyperlink + , listDepth :: Int + , maxListDepth :: Int + } + +type WS a = State WriterState a + +defaultWriterState :: WriterState +defaultWriterState = WriterState{ + blockStyles = Set.empty + , inlineStyles = Set.empty + , links = [] + , listDepth = 1 + , maxListDepth = 0 + } + +-- inline names (appear in InDesign's character styles pane) +emphName :: String +strongName :: String +strikeoutName :: String +superscriptName :: String +subscriptName :: String +smallCapsName :: String +codeName :: String +linkName :: String +emphName = "Italic" +strongName = "Bold" +strikeoutName = "Strikeout" +superscriptName = "Superscript" +subscriptName = "Subscript" +smallCapsName = "SmallCaps" +codeName = "Code" +linkName = "Link" + +-- block element names (appear in InDesign's paragraph styles pane) +paragraphName :: String +codeBlockName :: String +rawBlockName :: String +blockQuoteName :: String +orderedListName :: String +bulletListName :: String +defListTermName :: String +defListDefName :: String +headerName :: String +tableName :: String +tableHeaderName :: String +tableCaptionName :: String +alignLeftName :: String +alignRightName :: String +alignCenterName :: String +firstListItemName :: String +beginsWithName :: String +lowerRomanName :: String +upperRomanName :: String +lowerAlphaName :: String +upperAlphaName :: String +subListParName :: String +footnoteName :: String +paragraphName = "Paragraph" +codeBlockName = "CodeBlock" +rawBlockName = "Rawblock" +blockQuoteName = "Blockquote" +orderedListName = "NumList" +bulletListName = "BulList" +defListTermName = "DefListTerm" +defListDefName = "DefListDef" +headerName = "Header" +tableName = "TablePar" +tableHeaderName = "TableHeader" +tableCaptionName = "TableCaption" +alignLeftName = "LeftAlign" +alignRightName = "RightAlign" +alignCenterName = "CenterAlign" +firstListItemName = "first" +beginsWithName = "beginsWith-" +lowerRomanName = "lowerRoman" +upperRomanName = "upperRoman" +lowerAlphaName = "lowerAlpha" +upperAlphaName = "upperAlpha" +subListParName = "subParagraph" +footnoteName = "Footnote" + + +-- | Convert Pandoc document to string in ICML format. +writeICML :: WriterOptions -> Pandoc -> String +writeICML opts (Pandoc meta blocks) = + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + render' = render colwidth + renderMeta f s = Just $ render' $ fst $ runState (f opts [] s) defaultWriterState + Just metadata = metaToJSON opts + (renderMeta blocksToICML) + (renderMeta inlinesToICML) + meta + (doc, st) = runState (blocksToICML opts [] blocks) defaultWriterState + main = render' doc + context = defField "body" main + $ defField "charStyles" (render' $ charStylesToDoc st) + $ defField "parStyles" (render' $ parStylesToDoc st) + $ defField "hyperlinks" (render' $ hyperlinksToDoc $ links st) + $ metadata + in if writerStandalone opts + then renderTemplate' (writerTemplate opts) context + else main + +-- | Auxilary functions for parStylesToDoc and charStylesToDoc. +contains :: String -> (String, (String, String)) -> [(String, String)] +contains s rule = + if isInfixOf (fst rule) s + then [snd rule] + else [] + +-- | The monospaced font to use as default. +monospacedFont :: Doc +monospacedFont = inTags False "AppliedFont" [("type", "string")] $ text "Courier New" + +-- | How much to indent blockquotes etc. +defaultIndent :: Int +defaultIndent = 20 + +-- | How much to indent numbered lists before the number. +defaultListIndent :: Int +defaultListIndent = 10 + +-- other constants +lineSeparator :: String +lineSeparator = "
" + +-- | Convert a WriterState with its block styles to the ICML listing of Paragraph Styles. +parStylesToDoc :: WriterState -> Doc +parStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ blockStyles st + where + makeStyle s = + let countSubStrs sub str = length $ Text.breakOnAll (Text.pack sub) (Text.pack str) + attrs = concat $ map (contains s) $ [ + (defListTermName, ("BulletsAndNumberingListType", "BulletList")) + , (defListTermName, ("FontStyle", "Bold")) + , (tableHeaderName, ("FontStyle", "Bold")) + , (alignLeftName, ("Justification", "LeftAlign")) + , (alignRightName, ("Justification", "RightAlign")) + , (alignCenterName, ("Justification", "CenterAlign")) + , (headerName++"1", ("PointSize", "36")) + , (headerName++"2", ("PointSize", "30")) + , (headerName++"3", ("PointSize", "24")) + , (headerName++"4", ("PointSize", "18")) + , (headerName++"5", ("PointSize", "14")) + ] + -- what is the most nested list type, if any? + (isBulletList, isOrderedList) = findList $ reverse $ splitBy (==' ') s + where + findList [] = (False, False) + findList (x:xs) | x == bulletListName = (True, False) + | x == orderedListName = (False, True) + | otherwise = findList xs + nBuls = countSubStrs bulletListName s + nOrds = countSubStrs orderedListName s + attrs' = numbering ++ listType ++ indent ++ attrs + where + numbering | isOrderedList = [("NumberingExpression", "^#.^t"), ("NumberingLevel", show nOrds)] + | otherwise = [] + listType | isOrderedList && (not $ isInfixOf subListParName s) + = [("BulletsAndNumberingListType", "NumberedList")] + | isBulletList && (not $ isInfixOf subListParName s) + = [("BulletsAndNumberingListType", "BulletList")] + | otherwise = [] + indent = [("LeftIndent", show indt)] + where + nBlockQuotes = countSubStrs blockQuoteName s + nDefLists = countSubStrs defListDefName s + indt = max 0 $ defaultListIndent*(nBuls + nOrds - 1) + defaultIndent*(nBlockQuotes + nDefLists) + props = inTags True "Properties" [] $ (basedOn $$ tabList $$ numbForm) + where + font = if isInfixOf codeBlockName s + then monospacedFont + else empty + basedOn = inTags False "BasedOn" [("type", "object")] (text "$ID/NormalParagraphStyle") $$ font + tabList = if isBulletList + then inTags True "TabList" [("type","list")] $ inTags True "ListItem" [("type","record")] + $ vcat [ + inTags False "Alignment" [("type","enumeration")] $ text "LeftAlign" + , inTags False "AlignmentCharacter" [("type","string")] $ text "." + , selfClosingTag "Leader" [("type","string")] + , inTags False "Position" [("type","unit")] $ text + $ show $ defaultListIndent * (nBuls + nOrds) + ] + else empty + makeNumb name = inTags False "NumberingFormat" [("type", "string")] (text name) + numbForm | isInfixOf lowerRomanName s = makeNumb "i, ii, iii, iv..." + | isInfixOf upperRomanName s = makeNumb "I, II, III, IV..." + | isInfixOf lowerAlphaName s = makeNumb "a, b, c, d..." + | isInfixOf upperAlphaName s = makeNumb "A, B, C, D..." + | otherwise = empty + in inTags True "ParagraphStyle" ([("Self", "ParagraphStyle/"++s), ("Name", s)] ++ attrs') props + +-- | Convert a WriterState with its inline styles to the ICML listing of Character Styles. +charStylesToDoc :: WriterState -> Doc +charStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ inlineStyles st + where + makeStyle s = + let attrs = concat $ map (contains s) [ + (strikeoutName, ("StrikeThru", "true")) + , (superscriptName, ("Position", "Superscript")) + , (subscriptName, ("Position", "Subscript")) + , (smallCapsName, ("Capitalization", "SmallCaps")) + ] + attrs' | isInfixOf emphName s && isInfixOf strongName s = ("FontStyle", "Bold Italic") : attrs + | isInfixOf strongName s = ("FontStyle", "Bold") : attrs + | isInfixOf emphName s = ("FontStyle", "Italic") : attrs + | otherwise = attrs + props = inTags True "Properties" [] $ + inTags False "BasedOn" [("type", "object")] (text "$ID/NormalCharacterStyle") $$ font + where + font = + if isInfixOf codeName s + then monospacedFont + else empty + in inTags True "CharacterStyle" ([("Self", "CharacterStyle/"++s), ("Name", s)] ++ attrs') props + +-- | Convert a list of (identifier, url) pairs to the ICML listing of hyperlinks. +hyperlinksToDoc :: Hyperlink -> Doc +hyperlinksToDoc [] = empty +hyperlinksToDoc (x:xs) = hyp x $$ hyperlinksToDoc xs + where + hyp (ident, url) = hdest $$ hlink + where + hdest = selfClosingTag "HyperlinkURLDestination" + [("Self", "HyperlinkURLDestination/"++url), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")] + hlink = inTags True "Hyperlink" [("Self","uf-"++show ident), ("Name",url), + ("Source","htss-"++show ident), ("Visible","true"), ("DestinationUniqueKey","1")] + $ inTags True "Properties" [] + $ inTags False "BorderColor" [("type","enumeration")] (text "Black") + $$ (inTags False "Destination" [("type","object")] + $ text $ "HyperlinkURLDestination/"++(escapeStringForXML url)) + + +-- | Convert a list of Pandoc blocks to ICML. +blocksToICML :: WriterOptions -> Style -> [Block] -> WS Doc +blocksToICML opts style lst = vcat `fmap` mapM (blockToICML opts style) lst + +-- | Convert a Pandoc block element to ICML. +blockToICML :: WriterOptions -> Style -> Block -> WS Doc +blockToICML opts style (Plain lst) = parStyle opts style lst +blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst +blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str] +blockToICML opts style (RawBlock _ str) = parStyle opts (rawBlockName:style) $ [Str str] +blockToICML opts style (BlockQuote blocks) = blocksToICML opts (blockQuoteName:style) blocks +blockToICML opts style (OrderedList attribs lst) = listItemsToICML opts orderedListName style (Just attribs) lst +blockToICML opts style (BulletList lst) = listItemsToICML opts bulletListName style Nothing lst +blockToICML opts style (DefinitionList lst) = vcat `fmap` mapM (definitionListItemToICML opts style) lst +blockToICML opts style (Header lvl _ lst) = + let stl = (headerName ++ show lvl):style + in parStyle opts stl lst +blockToICML _ _ HorizontalRule = return empty -- we could insert a page break instead +blockToICML opts style (Table caption aligns widths headers rows) = + let style' = tableName : style + noHeader = all null headers + nrHeaders = if noHeader + then "0" + else "1" + nrRows = length rows + nrCols = if null rows + then 0 + else length $ head rows + rowsToICML [] _ = return empty + rowsToICML (col:rest) rowNr = + liftM2 ($$) (colsToICML col rowNr (0::Int)) $ rowsToICML rest (rowNr+1) + colsToICML [] _ _ = return empty + colsToICML (cell:rest) rowNr colNr = do + let stl = if rowNr == 0 && not noHeader + then tableHeaderName:style' + else style' + alig = aligns !! colNr + stl' | alig == AlignLeft = alignLeftName : stl + | alig == AlignRight = alignRightName : stl + | alig == AlignCenter = alignCenterName : stl + | otherwise = stl + c <- blocksToICML opts stl' cell + let cl = return $ inTags True "Cell" + [("Name", show colNr ++":"++ show rowNr), ("AppliedCellStyle","CellStyle/Cell")] c + liftM2 ($$) cl $ colsToICML rest rowNr (colNr+1) + in do + let tabl = if noHeader + then rows + else headers:rows + cells <- rowsToICML tabl (0::Int) + let colWidths w = if w > 0 + then [("SingleColumnWidth",show $ 500 * w)] + else [] + let tupToDoc tup = selfClosingTag "Column" $ [("Name",show $ fst tup)] ++ (colWidths $ snd tup) + let colDescs = vcat $ map tupToDoc $ zip [0..nrCols-1] widths + let tableDoc = return $ inTags True "Table" [ + ("AppliedTableStyle","TableStyle/Table") + , ("HeaderRowCount", nrHeaders) + , ("BodyRowCount", show nrRows) + , ("ColumnCount", show nrCols) + ] (colDescs $$ cells) + liftM2 ($$) tableDoc $ parStyle opts (tableCaptionName:style) caption +blockToICML opts style (Div _ lst) = blocksToICML opts style lst +blockToICML _ _ Null = return empty + +-- | Convert a list of lists of blocks to ICML list items. +listItemsToICML :: WriterOptions -> String -> Style -> Maybe ListAttributes -> [[Block]] -> WS Doc +listItemsToICML _ _ _ _ [] = return empty +listItemsToICML opts listType style attribs (first:rest) = do + st <- get + put st{ listDepth = 1 + listDepth st} + let stl = listType:style + let f = listItemToICML opts stl True attribs first + let r = map (listItemToICML opts stl False attribs) rest + docs <- sequence $ f:r + s <- get + let maxD = max (maxListDepth s) (listDepth s) + put s{ listDepth = 1, maxListDepth = maxD } + return $ vcat docs + +-- | Convert a list of blocks to ICML list items. +listItemToICML :: WriterOptions -> Style -> Bool-> Maybe ListAttributes -> [Block] -> WS Doc +listItemToICML opts style isFirst attribs item = + let makeNumbStart (Just (beginsWith, numbStl, _)) = + let doN DefaultStyle = [] + doN LowerRoman = [lowerRomanName] + doN UpperRoman = [upperRomanName] + doN LowerAlpha = [lowerAlphaName] + doN UpperAlpha = [upperAlphaName] + doN _ = [] + bw = if beginsWith > 1 + then [beginsWithName ++ show beginsWith] + else [] + in doN numbStl ++ bw + makeNumbStart Nothing = [] + stl = if isFirst + then firstListItemName:style + else style + stl' = makeNumbStart attribs ++ stl + in if length item > 1 + then do + let insertTab (Para lst) = blockToICML opts (subListParName:style) $ Para $ (Str "\t"):lst + insertTab block = blockToICML opts style block + f <- blockToICML opts stl' $ head item + r <- fmap vcat $ mapM insertTab $ tail item + return $ f $$ r + else blocksToICML opts stl' item + +definitionListItemToICML :: WriterOptions -> Style -> ([Inline],[[Block]]) -> WS Doc +definitionListItemToICML opts style (term,defs) = do + term' <- parStyle opts (defListTermName:style) term + defs' <- vcat `fmap` mapM (blocksToICML opts (defListDefName:style)) defs + return $ term' $$ defs' + + +-- | Convert a list of inline elements to ICML. +inlinesToICML :: WriterOptions -> Style -> [Inline] -> WS Doc +inlinesToICML opts style lst = vcat `fmap` mapM (inlineToICML opts style) (mergeSpaces lst) + +-- | Convert an inline element to ICML. +inlineToICML :: WriterOptions -> Style -> Inline -> WS Doc +inlineToICML _ style (Str str) = charStyle style $ text $ escapeStringForXML str +inlineToICML opts style (Emph lst) = inlinesToICML opts (emphName:style) lst +inlineToICML opts style (Strong lst) = inlinesToICML opts (strongName:style) lst +inlineToICML opts style (Strikeout lst) = inlinesToICML opts (strikeoutName:style) lst +inlineToICML opts style (Superscript lst) = inlinesToICML opts (superscriptName:style) lst +inlineToICML opts style (Subscript lst) = inlinesToICML opts (subscriptName:style) lst +inlineToICML opts style (SmallCaps lst) = inlinesToICML opts (smallCapsName:style) lst +inlineToICML opts style (Quoted SingleQuote lst) = inlinesToICML opts style $ [Str "‘"] ++ lst ++ [Str "’"] +inlineToICML opts style (Quoted DoubleQuote lst) = inlinesToICML opts style $ [Str "“"] ++ lst ++ [Str "”"] +inlineToICML opts style (Cite _ lst) = footnoteToICML opts style [Para lst] +inlineToICML _ style (Code _ str) = charStyle (codeName:style) $ text $ escapeStringForXML str +inlineToICML _ style Space = charStyle style space +inlineToICML _ style LineBreak = charStyle style $ text lineSeparator +inlineToICML _ style (Math _ str) = charStyle style $ text $ escapeStringForXML str --InDesign doesn't really do math +inlineToICML _ style (RawInline _ str) = charStyle style $ text $ escapeStringForXML str +inlineToICML opts style (Link lst (url, title)) = do + content <- inlinesToICML opts (linkName:style) lst + state $ \st -> + let ident = if null $ links st + then 1::Int + else 1 + (fst $ head $ links st) + newst = st{ links = (ident, url):(links st) } + cont = inTags True "HyperlinkTextSource" + [("Self","htss-"++show ident), ("Name",title), ("Hidden","false")] content + in (cont, newst) +inlineToICML opts style (Image alt target) = imageICML opts style alt target +inlineToICML opts style (Note lst) = footnoteToICML opts style lst +inlineToICML opts style (Span _ lst) = inlinesToICML opts style lst + +-- | Convert a list of block elements to an ICML footnote. +footnoteToICML :: WriterOptions -> Style -> [Block] -> WS Doc +footnoteToICML opts style lst = + let insertTab (Para ls) = blockToICML opts (footnoteName:style) $ Para $ (Str "\t"):ls + insertTab block = blockToICML opts (footnoteName:style) block + in do + contents <- mapM insertTab lst + let number = inTags True "ParagraphStyleRange" [] $ + inTags True "CharacterStyleRange" [] $ inTagsSimple "Content" "<?ACE 4?>" + return $ inTags True "CharacterStyleRange" + [("AppliedCharacterStyle","$ID/NormalCharacterStyle"), ("Position","Superscript")] + $ inTags True "Footnote" [] $ number $$ vcat contents + +-- | Auxiliary function to merge Space elements into the adjacent Strs. +mergeSpaces :: [Inline] -> [Inline] +mergeSpaces ((Str s):(Space:((Str s'):xs))) = mergeSpaces $ Str(s++" "++s') : xs +mergeSpaces (Space:((Str s):xs)) = mergeSpaces $ Str (" "++s) : xs +mergeSpaces ((Str s):(Space:xs)) = mergeSpaces $ Str (s++" ") : xs +mergeSpaces (x:xs) = x : (mergeSpaces xs) +mergeSpaces [] = [] + +-- | Wrap a list of inline elements in an ICML Paragraph Style +parStyle :: WriterOptions -> Style -> [Inline] -> WS Doc +parStyle opts style lst = + let slipIn x y = if null y + then x + else x ++ " > " ++ y + stlStr = foldr slipIn [] $ reverse style + stl = if null stlStr + then "" + else "ParagraphStyle/" ++ stlStr + attrs = ("AppliedParagraphStyle", stl) + attrs' = if firstListItemName `elem` style + then let ats = attrs : [("NumberingContinue", "false")] + begins = filter (isPrefixOf beginsWithName) style + in if null begins + then ats + else let i = maybe "" id $ stripPrefix beginsWithName $ head begins + in ("NumberingStartAt", i) : ats + else [attrs] + in do + content <- inlinesToICML opts [] lst + let cont = inTags True "ParagraphStyleRange" attrs' + $ mappend content $ selfClosingTag "Br" [] + state $ \st -> (cont, st{ blockStyles = Set.insert stlStr $ blockStyles st }) + +-- | Wrap a Doc in an ICML Character Style. +charStyle :: Style -> Doc -> WS Doc +charStyle style content = + let (stlStr, attrs) = styleToStrAttr style + doc = inTags True "CharacterStyleRange" attrs $ inTagsSimple "Content" $ flush content + in do + state $ \st -> + let styles = if null stlStr + then st + else st{ inlineStyles = Set.insert stlStr $ inlineStyles st } + in (doc, styles) + +-- | Transform a Style to a tuple of String (eliminating duplicates and ordered) and corresponding attribute. +styleToStrAttr :: Style -> (String, [(String, String)]) +styleToStrAttr style = + let stlStr = unwords $ Set.toAscList $ Set.fromList style + stl = if null style + then "$ID/NormalCharacterStyle" + else "CharacterStyle/" ++ stlStr + attrs = [("AppliedCharacterStyle", stl)] + in (stlStr, attrs) + +-- | Assemble an ICML Image. +imageICML :: WriterOptions -> Style -> [Inline] -> Target -> WS Doc +imageICML _ style _ (linkURI, _) = + let imgWidth = 300::Int --TODO: set width, height dynamically as in Docx.hs + imgHeight = 200::Int + scaleFact = show (1::Double) --TODO: set scaling factor so image is scaled exactly to imgWidth x imgHeight + hw = show $ imgWidth `div` 2 + hh = show $ imgHeight `div` 2 + qw = show $ imgWidth `div` 4 + qh = show $ imgHeight `div` 4 + (stlStr, attrs) = styleToStrAttr style + props = inTags True "Properties" [] $ inTags True "PathGeometry" [] + $ inTags True "GeometryPathType" [("PathOpen","false")] + $ inTags True "PathPointArray" [] + $ vcat [ + selfClosingTag "PathPointType" [("Anchor", "-"++qw++" -"++qh), + ("LeftDirection", "-"++qw++" -"++qh), ("RightDirection", "-"++qw++" -"++qh)] + , selfClosingTag "PathPointType" [("Anchor", "-"++qw++" "++qh), + ("LeftDirection", "-"++qw++" "++qh), ("RightDirection", "-"++qw++" "++qh)] + , selfClosingTag "PathPointType" [("Anchor", qw++" "++qh), + ("LeftDirection", qw++" "++qh), ("RightDirection", qw++" "++qh)] + , selfClosingTag "PathPointType" [("Anchor", qw++" -"++qh), + ("LeftDirection", qw++" -"++qh), ("RightDirection", qw++" -"++qh)] + ] + image = inTags True "Image" + [("Self","ue6"), ("ItemTransform", scaleFact++" 0 0 "++scaleFact++" -"++qw++" -"++qh)] + $ vcat [ + inTags True "Properties" [] $ inTags True "Profile" [("type","string")] $ text "$ID/Embedded" + $$ selfClosingTag "GraphicBounds" [("Left","0"), ("Top","0"), ("Right", hw), ("Bottom", hh)] + , selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", linkURI)] + ] + doc = inTags True "CharacterStyleRange" attrs + $ inTags True "Rectangle" [("Self","uec"), ("ItemTransform", "1 0 0 1 "++qw++" -"++qh)] + $ (props $$ image) + in do + state $ \st -> (doc, st{ inlineStyles = Set.insert stlStr $ inlineStyles st } ) diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index a16784889..424e1b7c5 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -135,7 +135,7 @@ tests = [ testGroup "markdown" "haddock-reader.haddock" "haddock-reader.native" ] , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f) - [ "opendocument" , "context" , "texinfo" + [ "opendocument" , "context" , "texinfo", "icml" , "man" , "plain" , "rtf", "org", "asciidoc" ] ] diff --git a/tests/tables.icml b/tests/tables.icml new file mode 100644 index 000000000..eb73af670 --- /dev/null +++ b/tests/tables.icml @@ -0,0 +1,748 @@ +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Simple table with caption:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="3" ColumnCount="4"> + <Column Name="0" /> + <Column Name="1" /> + <Column Name="2" /> + <Column Name="3" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Center</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Default</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Demonstration of simple table syntax.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Simple table without caption:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="3" ColumnCount="4"> + <Column Name="0" /> + <Column Name="1" /> + <Column Name="2" /> + <Column Name="3" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Center</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Default</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Simple table indented two spaces:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="3" ColumnCount="4"> + <Column Name="0" /> + <Column Name="1" /> + <Column Name="2" /> + <Column Name="3" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Center</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Default</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Demonstration of simple table syntax.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiline table with caption:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="2" ColumnCount="4"> + <Column Name="0" SingleColumnWidth="75.0" /> + <Column Name="1" SingleColumnWidth="68.75" /> + <Column Name="2" SingleColumnWidth="81.25" /> + <Column Name="3" SingleColumnWidth="168.75" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Centered Header</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left Aligned</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right Aligned</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Default aligned</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>row</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12.0</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Example of a row that spans multiple lines.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>row</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>5.0</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here's another one. Note the blank line between rows.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here's the caption. It may span multiple lines.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiline table without caption:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="2" ColumnCount="4"> + <Column Name="0" SingleColumnWidth="75.0" /> + <Column Name="1" SingleColumnWidth="68.75" /> + <Column Name="2" SingleColumnWidth="81.25" /> + <Column Name="3" SingleColumnWidth="168.75" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Centered Header</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left Aligned</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right Aligned</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > TableHeader > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Default aligned</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>row</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12.0</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Example of a row that spans multiple lines.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>row</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>5.0</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here's another one. Note the blank line between rows.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Table without column headers:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="0" BodyRowCount="3" ColumnCount="4"> + <Column Name="0" /> + <Column Name="1" /> + <Column Name="2" /> + <Column Name="3" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>123</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>1</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiline table without column headers:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="0" BodyRowCount="2" ColumnCount="4"> + <Column Name="0" SingleColumnWidth="75.0" /> + <Column Name="1" SingleColumnWidth="68.75" /> + <Column Name="2" SingleColumnWidth="81.25" /> + <Column Name="3" SingleColumnWidth="168.75" /> + <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>row</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>12.0</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Example of a row that spans multiple lines.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > CenterAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > LeftAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>row</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar > RightAlign"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>5.0</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> + <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell"> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here's another one. Note the blank line between rows.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Cell> +</Table> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption"> + <Br /> +</ParagraphStyleRange> diff --git a/tests/writer.icml b/tests/writer.icml new file mode 100644 index 000000000..ef6ddcf64 --- /dev/null +++ b/tests/writer.icml @@ -0,0 +1,3023 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<?aid style="50" type="snippet" readerVersion="6.0" featureSet="513" product="8.0(370)" ?> +<?aid SnippetType="InCopyInterchange"?> +<Document DOMVersion="8.0" Self="pandoc_doc"> + <RootCharacterStyleGroup Self="pandoc_character_styles"> + <CharacterStyle Self="$ID/NormalCharacterStyle" Name="Default" /> + <CharacterStyle Self="CharacterStyle/" Name=""> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Bold" Name="Bold" FontStyle="Bold"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Bold Italic" Name="Bold Italic" FontStyle="Bold Italic"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Code" Name="Code"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + <AppliedFont type="string">Courier New</AppliedFont> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Italic" Name="Italic" FontStyle="Italic"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Italic Link" Name="Italic Link" FontStyle="Italic"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Italic Strikeout" Name="Italic Strikeout" FontStyle="Italic" StrikeThru="true"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Italic Superscript" Name="Italic Superscript" FontStyle="Italic" Position="Superscript"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Link" Name="Link"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Strikeout" Name="Strikeout" StrikeThru="true"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Subscript" Name="Subscript" Position="Subscript"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + <CharacterStyle Self="CharacterStyle/Superscript" Name="Superscript" Position="Superscript"> + <Properties> + <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn> + </Properties> + </CharacterStyle> + </RootCharacterStyleGroup> + <RootParagraphStyleGroup Self="pandoc_paragraph_styles"> + <ParagraphStyle Self="$ID/NormalParagraphStyle" Name="$ID/NormalParagraphStyle" + SpaceBefore="6" SpaceAfter="6"> <!-- paragraph spacing --> + <Properties> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string"></Leader> + <Position type="unit">10</Position> <!-- first tab stop --> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/" Name="" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Blockquote > Blockquote > Paragraph" Name="Blockquote > Blockquote > Paragraph" LeftIndent="30"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Blockquote > CodeBlock" Name="Blockquote > CodeBlock" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <AppliedFont type="string">Courier New</AppliedFont> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Blockquote > NumList" Name="Blockquote > NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Blockquote > NumList > first" Name="Blockquote > NumList > first" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Blockquote > Paragraph" Name="Blockquote > Paragraph" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList" Name="BulList" BulletsAndNumberingListType="BulletList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">10</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > BulList > BulList > first" Name="BulList > BulList > BulList > first" BulletsAndNumberingListType="BulletList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">30</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > BulList > Paragraph" Name="BulList > BulList > Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">20</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > BulList > first" Name="BulList > BulList > first" BulletsAndNumberingListType="BulletList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">20</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > BulList > first > Paragraph" Name="BulList > BulList > first > Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">20</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > Paragraph" Name="BulList > Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">10</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > first" Name="BulList > first" BulletsAndNumberingListType="BulletList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">10</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/BulList > first > Paragraph" Name="BulList > first > Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">10</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/CodeBlock" Name="CodeBlock" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <AppliedFont type="string">Courier New</AppliedFont> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListDef" Name="DefListDef" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListDef > Blockquote > Paragraph" Name="DefListDef > Blockquote > Paragraph" LeftIndent="30"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListDef > CodeBlock" Name="DefListDef > CodeBlock" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <AppliedFont type="string">Courier New</AppliedFont> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListDef > NumList" Name="DefListDef > NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListDef > NumList > first" Name="DefListDef > NumList > first" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListDef > Paragraph" Name="DefListDef > Paragraph" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/DefListTerm" Name="DefListTerm" LeftIndent="0" BulletsAndNumberingListType="BulletList" FontStyle="Bold"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Footnote > CodeBlock" Name="Footnote > CodeBlock" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <AppliedFont type="string">Courier New</AppliedFont> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Footnote > Paragraph" Name="Footnote > Paragraph" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Header1" Name="Header1" LeftIndent="0" PointSize="36"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Header2" Name="Header2" LeftIndent="0" PointSize="30"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Header3" Name="Header3" LeftIndent="0" PointSize="24"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Header4" Name="Header4" LeftIndent="0" PointSize="18"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Header5" Name="Header5" LeftIndent="0" PointSize="14"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList" Name="NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > BulList" Name="NumList > BulList" BulletsAndNumberingListType="BulletList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">20</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > BulList > first" Name="NumList > BulList > first" BulletsAndNumberingListType="BulletList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <TabList type="list"> + <ListItem type="record"> + <Alignment type="enumeration">LeftAlign</Alignment> + <AlignmentCharacter type="string">.</AlignmentCharacter> + <Leader type="string" /> + <Position type="unit">20</Position> + </ListItem> + </TabList> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > NumList > NumList > first > beginsWith-3 > lowerAlpha" Name="NumList > NumList > NumList > NumList > first > beginsWith-3 > lowerAlpha" NumberingExpression="^#.^t" NumberingLevel="4" BulletsAndNumberingListType="NumberedList" LeftIndent="30"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">a, b, c, d...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > NumList > first > beginsWith-6" Name="NumList > NumList > NumList > first > beginsWith-6" NumberingExpression="^#.^t" NumberingLevel="3" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > NumList > first > upperAlpha" Name="NumList > NumList > NumList > first > upperAlpha" NumberingExpression="^#.^t" NumberingLevel="3" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">A, B, C, D...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > NumList > upperAlpha" Name="NumList > NumList > NumList > upperAlpha" NumberingExpression="^#.^t" NumberingLevel="3" BulletsAndNumberingListType="NumberedList" LeftIndent="20"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">A, B, C, D...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > beginsWith-4 > lowerRoman" Name="NumList > NumList > beginsWith-4 > lowerRoman" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">i, ii, iii, iv...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > first" Name="NumList > NumList > first" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > first > beginsWith-4 > lowerRoman" Name="NumList > NumList > first > beginsWith-4 > lowerRoman" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">i, ii, iii, iv...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > NumList > first > upperRoman" Name="NumList > NumList > first > upperRoman" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">I, II, III, IV...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > Paragraph" Name="NumList > Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > beginsWith-2 > Paragraph" Name="NumList > beginsWith-2 > Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > first" Name="NumList > first" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > first > Paragraph" Name="NumList > first > Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > first > beginsWith-2" Name="NumList > first > beginsWith-2" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > first > upperAlpha" Name="NumList > first > upperAlpha" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + <NumberingFormat type="string">A, B, C, D...</NumberingFormat> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/NumList > subParagraph > Paragraph" Name="NumList > subParagraph > Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Paragraph" Name="Paragraph" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + <ParagraphStyle Self="ParagraphStyle/Rawblock" Name="Rawblock" LeftIndent="0"> + <Properties> + <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn> + </Properties> + </ParagraphStyle> + </RootParagraphStyleGroup> + <RootTableStyleGroup Self="pandoc_table_styles"> + <TableStyle Self="TableStyle/Table" Name="Table" /> + </RootTableStyleGroup> + <RootCellStyleGroup Self="pandoc_cell_styles"> + <CellStyle Self="CellStyle/Cell" AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]" Name="Cell" /> + </RootCellStyleGroup> + <Story Self="pandoc_story" + TrackChanges="false" + StoryTitle="" + AppliedTOCStyle="n" + AppliedNamedGrid="n" > + <StoryPreference OpticalMarginAlignment="true" OpticalMarginSize="12" /> + +<!-- body needs to be non-indented, otherwise code blocks are indented too far --> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Headers</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 2 with an </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-1" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>embedded link</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header3"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 3 with </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>emphasis</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header4"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 4</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header5"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 5</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 2 with </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>emphasis</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header3"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>with no blank line</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Level 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>with no blank line</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Paragraphs</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s a regular paragraph.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s one with a bullet. * criminey.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>There should be a hard line break</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>
</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>here.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Block Quotes</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>E-mail style:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is a block quote. It is pretty short.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Code in a block quote:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>sub status { + print "working"; +}</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>A list:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>item one</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>item two</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Nested block quotes:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>nested</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>nested</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This should not be a block quote: 2 > 1.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>And a following paragraph.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Code Blocks</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Code:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>---- (should be four hyphens) + +sub status { + print "working"; +} + +this code block is indented by one tab</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>And:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> this code block is indented by two tabs + +These should not be escaped: \$ \\ \> \[ \{</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Lists</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Unordered</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Asterisks tight:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>asterisk 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>asterisk 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>asterisk 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Asterisks loose:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>asterisk 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>asterisk 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>asterisk 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Pluses tight:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Pluses loose:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minuses tight:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minuses loose:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus 1</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Ordered</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tight:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Third</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>and:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>One</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Two</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Three</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Loose using tabs:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Third</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>and using spaces:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>One</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Two</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Three</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiple paragraphs:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Item 1, graf one.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > subParagraph > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Item 2.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Item 3.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Nested</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tab</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tab</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > BulList > BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tab</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s another:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Fee</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Fie</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foe</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Third</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Same thing but with paragraphs:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>First</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Second:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Fee</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Fie</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foe</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Third</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tabs and spaces</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>this is a list item indented with tabs</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>this is a list item indented with spaces</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > BulList > first > Paragraph" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>this is an example list item indented with tabs</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > BulList > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>this is an example list item indented with spaces</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Fancy list markers</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange NumberingStartAt="2" AppliedParagraphStyle="ParagraphStyle/NumList > first > beginsWith-2" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>begins with 2</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > beginsWith-2 > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>and now 3</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > subParagraph > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>with a continuation</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange NumberingStartAt="4" AppliedParagraphStyle="ParagraphStyle/NumList > NumList > first > beginsWith-4 > lowerRoman" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>sublist with roman numerals, starting with 4</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > NumList > beginsWith-4 > lowerRoman"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>more items</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > NumList > NumList > first > upperAlpha" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>a subsublist</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > NumList > NumList > upperAlpha"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>a subsublist</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Nesting:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first > upperAlpha" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Upper Alpha</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > NumList > first > upperRoman" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Upper Roman.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange NumberingStartAt="6" AppliedParagraphStyle="ParagraphStyle/NumList > NumList > NumList > first > beginsWith-6" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Decimal start with 6</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange NumberingStartAt="3" AppliedParagraphStyle="ParagraphStyle/NumList > NumList > NumList > NumList > first > beginsWith-3 > lowerAlpha" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Lower alpha with paren</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Autonumbering:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Autonumber.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>More.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Nested.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Should not be a list item:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>M.A. 2007</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>B. Williams</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Definition Lists</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tight using spaces:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>banana</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>yellow fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Tight using tabs:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>banana</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>yellow fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Loose:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>banana</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>yellow fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiple blocks with italics:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>contains seeds, crisp, pleasant to taste</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>{ orange code block }</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange block quote</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiple definitions, tight:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>computer</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>bank</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiple definitions, loose:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>computer</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>bank</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Blank line after term, indented marker, alternate markers:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>apple</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>red fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>computer</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>orange fruit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>sublist</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef > NumList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>sublist</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>HTML Blocks</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Simple block on one line:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>foo</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>And nested without indentation:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>foo</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>bar</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Interpreted markdown in a table:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><table> +<tr> +<td></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>emphasized</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content></td> +<td></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>And this is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold"> + <Content>strong</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content></td> +</tr> +</table> + +<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script> + </Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s a simple block:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>foo</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This should be a code block, though:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><div> + foo +</div></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>As should this:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><div>foo</div></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Now, nested:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle=""> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>foo</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This should just be an HTML comment:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><!-- Comment --> + </Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Multiline:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><!-- +Blah +Blah +--> + +<!-- + This is another comment. +--> + </Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Code block:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><!-- Comment --></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Just plain comment, with trailing spaces on the line:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><!-- foo --> + </Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Code:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><hr /></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Hr’s:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content><hr> + +<hr /> + +<hr /> + +<hr> + +<hr /> + +<hr /> + +<hr class="foo" id="bar" /> + +<hr class="foo" id="bar" /> + +<hr class="foo" id="bar"> + </Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Inline Markup</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>emphasized</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, and so </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>is this</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold"> + <Content>strong</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, and so </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold"> + <Content>is this</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>An </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-2" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic Link"> + <Content>emphasized link</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic"> + <Content>This is strong and em.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>So is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic"> + <Content>this</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> word.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic"> + <Content>This is strong and em.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>So is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic"> + <Content>this</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> word.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is code: </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>></Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>$</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>\</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>\$</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content><html></Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Strikeout"> + <Content>This is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic Strikeout"> + <Content>strikeout</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Strikeout"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Superscripts: a</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Superscript"> + <Content>bc</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>d a</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic Superscript"> + <Content>hello</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> a</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Superscript"> + <Content>hello there</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Subscripts: H</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Subscript"> + <Content>2</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>O, H</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Subscript"> + <Content>23</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>O, H</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Subscript"> + <Content>many of them</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>O.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Smart quotes, ellipses, dashes</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>“</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Hello,</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>”</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> said the spider. </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>“</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Shelob</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> is my name.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>”</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>A</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>B</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>, and </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>C</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> are letters.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Oak,</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>elm,</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> and </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>beech</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> are names of trees. So is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>pine.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>He said, </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>“</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>I want to go.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>”</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> Were you alive in the 70’s?</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here is some quoted </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>‘</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>code</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>’</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> and a </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>“</Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-3" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>quoted link</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>”</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Some dashes: one—two — three—four — five.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Dashes between numbers: 5–7, 255–66, 1987–1999.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Ellipses…and…and….</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>LaTeX</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>\cite[22-23]{smith.1899}</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>2+2=4</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>x \in y</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>\alpha \wedge \omega</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>223</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>p</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>-Tree</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s some display math: </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s one that has a line break in it: </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>\alpha + \omega \times x^2</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>These shouldn’t be math:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>To get the famous equation, write </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>$e = mc^2$</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>$22,000 is a </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>lot</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> of money. So is $34,000. (It worked if </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>“</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>lot</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>”</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> is emphasized.)</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Shoes ($20) and socks ($5).</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Escaped </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>$</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>: $73 </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>this should be emphasized</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> 23$.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s a LaTeX table:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>\begin{tabular}{|l|l|}\hline +Animal & Number \\ \hline +Dog & 2 \\ +Cat & 1 \\ \hline +\end{tabular}</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Special Characters</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here is some unicode:</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>I hat: Î</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>o umlaut: ö</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>section: §</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>set membership: ∈</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>copyright: ©</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>AT&T has an ampersand in their name.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>AT&T is another way to write it.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This & that.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>4 < 5.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>6 > 5.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Backslash: \</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Backtick: `</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Asterisk: *</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Underscore: _</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left brace: {</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right brace: }</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left bracket: [</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right bracket: ]</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Left paren: (</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Right paren: )</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Greater-than: ></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Hash: #</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Period: .</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Bang: !</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Plus: +</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Minus: -</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Links</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Explicit</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Just a </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-4" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>URL</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-5" Name="title" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>URL and title</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-6" Name="title preceded by two spaces" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>URL and title</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-7" Name="title preceded by a tab" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>URL and title</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-8" Name="title with "quotes" in it" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>URL and title</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-9" Name="title with single quotes" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>URL and title</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-10" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>with_underscore</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-11" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>Email link</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-12" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>Empty</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Reference</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foo </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-13" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>bar</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foo </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-14" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>bar</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foo </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-15" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>bar</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>With </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-16" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>embedded [brackets]</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <HyperlinkTextSource Self="htss-17" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>b</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> by itself should be a link.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Indented </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-18" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>once</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Indented </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-19" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>twice</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Indented </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-20" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>thrice</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This should [not][] be a link.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>[not]: /url</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foo </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-21" Name="Title with "quotes" inside" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>bar</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Foo </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-22" Name="Title with "quote" inside" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>biz</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>With ampersands</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s a </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-23" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>link with an ampersand in the URL</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s a link with an amersand in the link text: </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-24" Name="AT&T" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>AT&T</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s an </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-25" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>inline link</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s an </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-26" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>inline link in pointy braces</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Autolinks</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>With an ampersand: </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-27" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>http://example.com/?foo=1&bar=2</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>In a list?</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <HyperlinkTextSource Self="htss-28" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>http://example.com/</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>It should.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>An e-mail address: </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-29" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>nobody@nowhere.net</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Blockquoted: </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-30" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>http://example.com/</Content> + </CharacterStyleRange> + </HyperlinkTextSource><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Auto-links should not occur here: </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content><http://example.com/></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>or here: <http://example.com/></Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Images</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>From </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>“</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Voyage dans la Lune</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>”</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> by Georges Melies (1902):</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Rectangle Self="uec" ItemTransform="1 0 0 1 75 -50"> + <Properties> + <PathGeometry> + <GeometryPathType PathOpen="false"> + <PathPointArray> + <PathPointType Anchor="-75 -50" LeftDirection="-75 -50" RightDirection="-75 -50" /> + <PathPointType Anchor="-75 50" LeftDirection="-75 50" RightDirection="-75 50" /> + <PathPointType Anchor="75 50" LeftDirection="75 50" RightDirection="75 50" /> + <PathPointType Anchor="75 -50" LeftDirection="75 -50" RightDirection="75 -50" /> + </PathPointArray> + </GeometryPathType> + </PathGeometry> + </Properties> + <Image Self="ue6" ItemTransform="1.0 0 0 1.0 -75 -50"> + <Properties> + <Profile type="string"> + $ID/Embedded + <GraphicBounds Left="0" Top="0" Right="150" Bottom="100" /> + </Profile> + </Properties> + <Link Self="ueb" LinkResourceURI="lalune.jpg" /> + </Image> + </Rectangle> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here is a movie </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Rectangle Self="uec" ItemTransform="1 0 0 1 75 -50"> + <Properties> + <PathGeometry> + <GeometryPathType PathOpen="false"> + <PathPointArray> + <PathPointType Anchor="-75 -50" LeftDirection="-75 -50" RightDirection="-75 -50" /> + <PathPointType Anchor="-75 50" LeftDirection="-75 50" RightDirection="-75 50" /> + <PathPointType Anchor="75 50" LeftDirection="75 50" RightDirection="75 50" /> + <PathPointType Anchor="75 -50" LeftDirection="75 -50" RightDirection="75 -50" /> + </PathPointArray> + </GeometryPathType> + </PathGeometry> + </Properties> + <Image Self="ue6" ItemTransform="1.0 0 0 1.0 -75 -50"> + <Properties> + <Profile type="string"> + $ID/Embedded + <GraphicBounds Left="0" Top="0" Right="150" Bottom="100" /> + </Profile> + </Properties> + <Link Self="ueb" LinkResourceURI="movie.jpg" /> + </Image> + </Rectangle> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> icon.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Footnotes</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here is a footnote reference,</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript"> + <Footnote> + <ParagraphStyleRange> + <CharacterStyleRange> + <Content><?ACE 4?></Content> + </CharacterStyleRange> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Footnote> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> and another.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript"> + <Footnote> + <ParagraphStyleRange> + <CharacterStyleRange> + <Content><?ACE 4?></Content> + </CharacterStyleRange> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Here’s the long note. This one contains multiple blocks.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > CodeBlock"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> { <code> }</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Footnote> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> This should </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>not</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> be a footnote reference, because it contains a space.[^my note] Here is an inline note.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript"> + <Footnote> + <ParagraphStyleRange> + <CharacterStyleRange> + <Content><?ACE 4?></Content> + </CharacterStyleRange> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This is </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic"> + <Content>easier</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> to type. Inline notes may contain </Content> + </CharacterStyleRange> + <HyperlinkTextSource Self="htss-31" Name="" Hidden="false"> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link"> + <Content>links</Content> + </CharacterStyleRange> + </HyperlinkTextSource> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> and </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code"> + <Content>]</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> verbatim characters, as well as [bracketed text].</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Footnote> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>Notes can go in quotes.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript"> + <Footnote> + <ParagraphStyleRange> + <CharacterStyleRange> + <Content><?ACE 4?></Content> + </CharacterStyleRange> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>In quote.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Footnote> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList > first" NumberingContinue="false"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>And in list items.</Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript"> + <Footnote> + <ParagraphStyleRange> + <CharacterStyleRange> + <Content><?ACE 4?></Content> + </CharacterStyleRange> + </ParagraphStyleRange> + <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote > Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content> </Content> + </CharacterStyleRange> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>In list.</Content> + </CharacterStyleRange><Br /> + </ParagraphStyleRange> + </Footnote> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> +<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph"> + <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle"> + <Content>This paragraph should not be part of the note, as it is not indented.</Content> + </CharacterStyleRange><Br /> +</ParagraphStyleRange> + + </Story> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://google.com" Name="link" DestinationURL="http://google.com" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-31" Name="http://google.com" Source="htss-31" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://google.com</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://example.com/" Name="link" DestinationURL="http://example.com/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-30" Name="http://example.com/" Source="htss-30" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://example.com/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/mailto:nobody@nowhere.net" Name="link" DestinationURL="mailto:nobody@nowhere.net" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-29" Name="mailto:nobody@nowhere.net" Source="htss-29" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/mailto:nobody@nowhere.net</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://example.com/" Name="link" DestinationURL="http://example.com/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-28" Name="http://example.com/" Source="htss-28" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://example.com/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://example.com/?foo=1&bar=2" Name="link" DestinationURL="http://example.com/?foo=1&bar=2" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-27" Name="http://example.com/?foo=1&bar=2" Source="htss-27" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://example.com/?foo=1&bar=2</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//script?foo=1&bar=2" Name="link" DestinationURL="/script?foo=1&bar=2" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-26" Name="/script?foo=1&bar=2" Source="htss-26" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//script?foo=1&bar=2</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//script?foo=1&bar=2" Name="link" DestinationURL="/script?foo=1&bar=2" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-25" Name="/script?foo=1&bar=2" Source="htss-25" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//script?foo=1&bar=2</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://att.com/" Name="link" DestinationURL="http://att.com/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-24" Name="http://att.com/" Source="htss-24" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://att.com/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://example.com/?foo=1&bar=2" Name="link" DestinationURL="http://example.com/?foo=1&bar=2" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-23" Name="http://example.com/?foo=1&bar=2" Source="htss-23" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://example.com/?foo=1&bar=2</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-22" Name="/url/" Source="htss-22" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-21" Name="/url/" Source="htss-21" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-20" Name="/url" Source="htss-20" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-19" Name="/url" Source="htss-19" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-18" Name="/url" Source="htss-18" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-17" Name="/url/" Source="htss-17" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-16" Name="/url/" Source="htss-16" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-15" Name="/url/" Source="htss-15" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-14" Name="/url/" Source="htss-14" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-13" Name="/url/" Source="htss-13" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/" Name="link" DestinationURL="" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-12" Name="" Source="htss-12" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/mailto:nobody@nowhere.net" Name="link" DestinationURL="mailto:nobody@nowhere.net" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-11" Name="mailto:nobody@nowhere.net" Source="htss-11" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/mailto:nobody@nowhere.net</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/with_underscore" Name="link" DestinationURL="/url/with_underscore" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-10" Name="/url/with_underscore" Source="htss-10" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/with_underscore</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-9" Name="/url/" Source="htss-9" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-8" Name="/url/" Source="htss-8" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-7" Name="/url/" Source="htss-7" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-6" Name="/url/" Source="htss-6" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-5" Name="/url/" Source="htss-5" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-4" Name="/url/" Source="htss-4" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url/</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination/http://example.com/?foo=1&bar=2" Name="link" DestinationURL="http://example.com/?foo=1&bar=2" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-3" Name="http://example.com/?foo=1&bar=2" Source="htss-3" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination/http://example.com/?foo=1&bar=2</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-2" Name="/url" Source="htss-2" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url</Destination> + </Properties> + </Hyperlink> + <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" /> + <Hyperlink Self="uf-1" Name="/url" Source="htss-1" Visible="true" DestinationUniqueKey="1"> + <Properties> + <BorderColor type="enumeration">Black</BorderColor> + <Destination type="object">HyperlinkURLDestination//url</Destination> + </Properties> + </Hyperlink> +</Document> -- cgit v1.2.3 From f3c9d3788530e450d1bb23a4fd829bc5a6eed266 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Wed, 5 Mar 2014 13:01:23 -0800 Subject: HTML writer: Add colgroup around col tags. Also affects EPUB writer. Closes #877. --- src/Text/Pandoc/Writers/HTML.hs | 15 ++++++++++----- tests/tables.html | 6 ++++++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 3ac2a836f..e0385af25 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -533,11 +533,16 @@ blockToHtml opts (Table capt aligns widths headers rows') = do let percent w = show (truncate (100*w) :: Integer) ++ "%" let coltags = if all (== 0.0) widths then mempty - else mconcat $ map (\w -> - if writerHtml5 opts - then H.col ! A.style (toValue $ "width: " ++ percent w) - else H.col ! A.width (toValue $ percent w) >> nl opts) - widths + else do + H.colgroup $ do + nl opts + mapM_ (\w -> do + if writerHtml5 opts + then H.col ! A.style (toValue $ "width: " ++ + percent w) + else H.col ! A.width (toValue $ percent w) + nl opts) widths + nl opts head' <- if all null headers then return mempty else do diff --git a/tests/tables.html b/tests/tables.html index b72aa784e..a9b2b247d 100644 --- a/tests/tables.html +++ b/tests/tables.html @@ -96,10 +96,12 @@ <p>Multiline table with caption:</p> <table> <caption>Here's the caption. It may span multiple lines.</caption> +<colgroup> <col width="15%" /> <col width="13%" /> <col width="16%" /> <col width="33%" /> +</colgroup> <thead> <tr class="header"> <th align="center">Centered Header</th> @@ -125,10 +127,12 @@ </table> <p>Multiline table without caption:</p> <table> +<colgroup> <col width="15%" /> <col width="13%" /> <col width="16%" /> <col width="33%" /> +</colgroup> <thead> <tr class="header"> <th align="center">Centered Header</th> @@ -177,10 +181,12 @@ </table> <p>Multiline table without column headers:</p> <table> +<colgroup> <col width="15%" /> <col width="13%" /> <col width="16%" /> <col width="33%" /> +</colgroup> <tbody> <tr class="odd"> <td align="center">First</td> -- cgit v1.2.3 From 76ef65f0b36d3a613e004350609d3696d0bf5658 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Wed, 12 Mar 2014 10:23:45 -0700 Subject: Man writer: Ensure that terms in definition lists aren't line wrapped. Closes #1195. --- src/Text/Pandoc/Writers/Man.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index b31cc2b70..680bfef44 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -283,7 +283,7 @@ definitionListItemToMan opts (label, defs) = do mapM (\item -> blockToMan opts item) rest first' <- blockToMan opts first return $ first' $$ text ".RS" $$ rest' $$ text ".RE" - return $ text ".TP" $$ text ".B " <> labelText $$ contents + return $ text ".TP" $$ nowrap (text ".B " <> labelText) $$ contents -- | Convert list of Pandoc block elements to man. blockListToMan :: WriterOptions -- ^ Options -- cgit v1.2.3 From 814af2002e4837c160526123ef753bb34547d811 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 14 Mar 2014 14:03:15 -0700 Subject: RST writer: Avoid stack overflow with certain tables. Closes #1197. Note that there are still problems with the formatting of the tables inside tables with output produced from the input file in the original bug report. But this fixes the stack overflow problem. --- src/Text/Pandoc/Writers/RST.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 37bb66632..1e7596b21 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -219,11 +219,15 @@ blockToRST (Table caption _ widths headers rows) = do else blankline <> text "Table: " <> caption' headers' <- mapM blockListToRST headers rawRows <- mapM (mapM blockListToRST) rows - let isSimple = all (==0) widths && all (all (\bs -> length bs <= 1)) rows + -- let isSimpleCell [Plain _] = True + -- isSimpleCell [Para _] = True + -- isSimpleCell [] = True + -- isSimpleCell _ = False + -- let isSimple = all (==0) widths && all (all isSimpleCell) rows let numChars = maximum . map offset opts <- get >>= return . stOptions let widthsInChars = - if isSimple + if all (== 0) widths then map ((+2) . numChars) $ transpose (headers' : rawRows) else map (floor . (fromIntegral (writerColumns opts) *)) widths let hpipeBlocks blocks = hcat [beg, middle, end] -- cgit v1.2.3 From f6141aa241eb2e636cda369c12d26c8f4b4a3308 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 14 Mar 2014 15:18:43 -0700 Subject: EPUB writer: Incorporate files linked in <video> tags. src and poster will both be incorporated into content.opf and the epub container. This partially address #1170. Still need to do something similar for <audio>. --- src/Text/Pandoc/MIME.hs | 1 + src/Text/Pandoc/Writers/EPUB.hs | 56 +++++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 10 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs index 44989ee94..977cb576b 100644 --- a/src/Text/Pandoc/MIME.hs +++ b/src/Text/Pandoc/MIME.hs @@ -246,6 +246,7 @@ mimeTypesList = -- List borrowed from happstack-server. ,("lzx","application/x-lzx") ,("m3u","audio/mpegurl") ,("m4a","audio/mpeg") + ,("m4v","video/x-m4v") ,("maker","application/x-maker") ,("man","application/x-troff-man") ,("mcif","chemical/x-mmcif") diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index a48300939..d4044d475 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -65,6 +65,7 @@ import Prelude hiding (catch) #endif import Control.Exception (catch, SomeException) import Text.Blaze.Html.Renderer.Utf8 (renderHtml) +import Text.HTML.TagSoup -- A Chapter includes a list of blocks and maybe a section -- number offset. Note, some chapters are unnumbered. The section @@ -342,8 +343,8 @@ writeEPUB opts doc@(Pandoc meta _) = do -- handle pictures picsRef <- newIORef [] - Pandoc _ blocks <- walkM - (transformInline opts' picsRef) doc + Pandoc _ blocks <- walkM (transformInline opts' picsRef) doc >>= + walkM (transformBlock opts' picsRef) pics <- readIORef picsRef let readPicEntry entries (oldsrc, newsrc) = do res <- fetchItem (writerSourceURL opts') oldsrc @@ -715,21 +716,55 @@ metadataElement version md currentTime = showDateTimeISO8601 :: UTCTime -> String showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ" +transformTag :: WriterOptions + -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images + -> Tag String + -> IO (Tag String) +transformTag opts picsRef tag@(TagOpen "video" attr) = do + let src = fromAttrib "src" tag + let poster = fromAttrib "poster" tag + let oldsrc = maybe src (</> src) $ writerSourceURL opts + let oldposter = maybe poster (</> poster) $ writerSourceURL opts + newsrc <- modifyPicsRef picsRef oldsrc + newposter <- modifyPicsRef picsRef oldposter + let attr' = filter (\(x,_) -> x /= "src" && x /= "poster") attr ++ + [("src", newsrc) | not (null newsrc)] ++ + [("poster", newposter) | not (null newposter)] + return $ TagOpen "video" attr' +transformTag _ _ tag = return tag + +modifyPicsRef :: IORef [(FilePath, FilePath)] -> FilePath -> IO FilePath +modifyPicsRef _ "" = return "" +modifyPicsRef picsRef oldsrc = do + pics <- readIORef picsRef + case lookup oldsrc pics of + Just n -> return n + Nothing -> do + let new = "images/img" ++ show (length pics) ++ + takeExtension oldsrc + modifyIORef picsRef ( (oldsrc, new): ) + return new + +transformBlock :: WriterOptions + -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images + -> Block + -> IO Block +transformBlock opts picsRef (RawBlock fmt raw) + | fmt == Format "html" = do + let tags = parseTags raw + -- look for video tags and add poster and src to images + tags' <- mapM (transformTag opts picsRef) tags + return $ RawBlock fmt (renderTags tags') +transformBlock _ _ b = return b + transformInline :: WriterOptions -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images -> Inline -> IO Inline transformInline opts picsRef (Image lab (src,tit)) = do let src' = unEscapeString src - pics <- readIORef picsRef let oldsrc = maybe src' (</> src) $ writerSourceURL opts - let ext = takeExtension src' - newsrc <- case lookup oldsrc pics of - Just n -> return n - Nothing -> do - let new = "images/img" ++ show (length pics) ++ ext - modifyIORef picsRef ( (oldsrc, new): ) - return new + newsrc <- modifyPicsRef picsRef oldsrc return $ Image lab (newsrc, tit) transformInline opts _ (x@(Math _ _)) | WebTeX _ <- writerHTMLMathMethod opts = do @@ -762,6 +797,7 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity . imageTypeOf :: FilePath -> Maybe String imageTypeOf x = case getMimeType x of Just y@('i':'m':'a':'g':'e':_) -> Just y + Just y@('v':'i':'d':'e':'o':_) -> Just y _ -> Nothing data IdentState = IdentState{ -- cgit v1.2.3 From 91696c62c431b85de7704b5444431230464d77b3 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 14 Mar 2014 15:30:11 -0700 Subject: EPUB writer: Handle media in audio source tags. This should resolve the rest of #1170, but it needs extensive testing. Note that we now use a 'media' directory rather than 'images'. --- src/Text/Pandoc/Writers/EPUB.hs | 55 +++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index d4044d475..75aae55c1 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -342,15 +342,15 @@ writeEPUB opts doc@(Pandoc meta _) = do let tpEntry = mkEntry "title_page.xhtml" tpContent -- handle pictures - picsRef <- newIORef [] - Pandoc _ blocks <- walkM (transformInline opts' picsRef) doc >>= - walkM (transformBlock opts' picsRef) - pics <- readIORef picsRef + mediaRef <- newIORef [] + Pandoc _ blocks <- walkM (transformInline opts' mediaRef) doc >>= + walkM (transformBlock opts' mediaRef) + pics <- readIORef mediaRef let readPicEntry entries (oldsrc, newsrc) = do res <- fetchItem (writerSourceURL opts') oldsrc case res of Left _ -> do - warn $ "Could not find image `" ++ oldsrc ++ "', skipping..." + warn $ "Could not find media `" ++ oldsrc ++ "', skipping..." return entries Right (img,_) -> return $ (toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img) : entries @@ -440,7 +440,7 @@ writeEPUB opts doc@(Pandoc meta _) = do [("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", fromMaybe "application/octet-stream" - $ imageTypeOf $ eRelativePath ent)] $ () + $ mediaTypeOf $ eRelativePath ent)] $ () let fontNode ent = unode "item" ! [("id", takeBaseName $ eRelativePath ent), ("href", eRelativePath ent), @@ -717,54 +717,54 @@ showDateTimeISO8601 :: UTCTime -> String showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ" transformTag :: WriterOptions - -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images + -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media -> Tag String -> IO (Tag String) -transformTag opts picsRef tag@(TagOpen "video" attr) = do +transformTag opts mediaRef tag@(TagOpen name attr) + | name == "video" || name == "source" = do let src = fromAttrib "src" tag let poster = fromAttrib "poster" tag let oldsrc = maybe src (</> src) $ writerSourceURL opts let oldposter = maybe poster (</> poster) $ writerSourceURL opts - newsrc <- modifyPicsRef picsRef oldsrc - newposter <- modifyPicsRef picsRef oldposter + newsrc <- modifyMediaRef mediaRef oldsrc + newposter <- modifyMediaRef mediaRef oldposter let attr' = filter (\(x,_) -> x /= "src" && x /= "poster") attr ++ [("src", newsrc) | not (null newsrc)] ++ [("poster", newposter) | not (null newposter)] - return $ TagOpen "video" attr' + return $ TagOpen name attr' transformTag _ _ tag = return tag -modifyPicsRef :: IORef [(FilePath, FilePath)] -> FilePath -> IO FilePath -modifyPicsRef _ "" = return "" -modifyPicsRef picsRef oldsrc = do - pics <- readIORef picsRef - case lookup oldsrc pics of +modifyMediaRef :: IORef [(FilePath, FilePath)] -> FilePath -> IO FilePath +modifyMediaRef _ "" = return "" +modifyMediaRef mediaRef oldsrc = do + media <- readIORef mediaRef + case lookup oldsrc media of Just n -> return n Nothing -> do - let new = "images/img" ++ show (length pics) ++ + let new = "media/file" ++ show (length media) ++ takeExtension oldsrc - modifyIORef picsRef ( (oldsrc, new): ) + modifyIORef mediaRef ( (oldsrc, new): ) return new transformBlock :: WriterOptions - -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images + -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media -> Block -> IO Block -transformBlock opts picsRef (RawBlock fmt raw) +transformBlock opts mediaRef (RawBlock fmt raw) | fmt == Format "html" = do let tags = parseTags raw - -- look for video tags and add poster and src to images - tags' <- mapM (transformTag opts picsRef) tags + tags' <- mapM (transformTag opts mediaRef) tags return $ RawBlock fmt (renderTags tags') transformBlock _ _ b = return b transformInline :: WriterOptions - -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images + -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media -> Inline -> IO Inline -transformInline opts picsRef (Image lab (src,tit)) = do +transformInline opts mediaRef (Image lab (src,tit)) = do let src' = unEscapeString src let oldsrc = maybe src' (</> src) $ writerSourceURL opts - newsrc <- modifyPicsRef picsRef oldsrc + newsrc <- modifyMediaRef mediaRef oldsrc return $ Image lab (newsrc, tit) transformInline opts _ (x@(Math _ _)) | WebTeX _ <- writerHTMLMathMethod opts = do @@ -794,10 +794,11 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity . Nothing -> '&':'#':unEntity xs unEntity (x:xs) = x : unEntity xs -imageTypeOf :: FilePath -> Maybe String -imageTypeOf x = case getMimeType x of +mediaTypeOf :: FilePath -> Maybe String +mediaTypeOf x = case getMimeType x of Just y@('i':'m':'a':'g':'e':_) -> Just y Just y@('v':'i':'d':'e':'o':_) -> Just y + Just y@('a':'u':'d':'i':'o':_) -> Just y _ -> Nothing data IdentState = IdentState{ -- cgit v1.2.3 From 44f58e7e380b2ec38ba65e1cebb295661d3bad62 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 14 Mar 2014 15:41:28 -0700 Subject: EPUB writer: Handle files linked in raw img tags. See #1170. --- src/Text/Pandoc/Writers/EPUB.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 75aae55c1..dae45b90f 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -721,7 +721,7 @@ transformTag :: WriterOptions -> Tag String -> IO (Tag String) transformTag opts mediaRef tag@(TagOpen name attr) - | name == "video" || name == "source" = do + | name == "video" || name == "source" || name == "img" = do let src = fromAttrib "src" tag let poster = fromAttrib "poster" tag let oldsrc = maybe src (</> src) $ writerSourceURL opts -- cgit v1.2.3 From d7fbc40dff9771181f26d7d9cb3129c9884a5f01 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 24 Mar 2014 15:07:19 -0700 Subject: RTF writer: Fixed tables cells containing paragraphs. This moves \intbl after \pard. --- src/Text/Pandoc/Writers/RTF.hs | 2 +- tests/tables.rtf | 184 ++++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 93 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index fb935fa6a..3e0bd9976 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -259,7 +259,7 @@ tableRowToRTF header indent aligns sizes' cols = tableItemToRTF :: Int -> Alignment -> [Block] -> String tableItemToRTF indent alignment item = let contents = concatMap (blockToRTF indent alignment) item - in "{\\intbl " ++ contents ++ "\\cell}\n" + in "{" ++ substitute "\\pard" "\\pard\\intbl" contents ++ "\\cell}\n" -- | Ensure that there's the same amount of space after compact -- lists as after regular lists. diff --git a/tests/tables.rtf b/tests/tables.rtf index 011724967..e1fe4aab1 100644 --- a/tests/tables.rtf +++ b/tests/tables.rtf @@ -4,13 +4,13 @@ \clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Center\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par} \cell} } \intbl\row} @@ -19,13 +19,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} } \intbl\row} @@ -34,13 +34,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} } \intbl\row} @@ -49,13 +49,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} } \intbl\row} @@ -66,13 +66,13 @@ \clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Center\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par} \cell} } \intbl\row} @@ -81,13 +81,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} } \intbl\row} @@ -96,13 +96,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} } \intbl\row} @@ -111,13 +111,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} } \intbl\row} @@ -128,13 +128,13 @@ \clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Center\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par} \cell} } \intbl\row} @@ -143,13 +143,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} } \intbl\row} @@ -158,13 +158,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} } \intbl\row} @@ -173,13 +173,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} } \intbl\row} @@ -190,13 +190,13 @@ \clbrdrb\brdrs\cellx1296\clbrdrb\brdrs\cellx2484\clbrdrb\brdrs\cellx3888\clbrdrb\brdrs\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Centered Header\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Centered Header\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left Aligned\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left Aligned\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right Aligned\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right Aligned\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default aligned\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default aligned\par} \cell} } \intbl\row} @@ -205,13 +205,13 @@ \cellx1296\cellx2484\cellx3888\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 First\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12.0\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par} \cell} } \intbl\row} @@ -220,13 +220,13 @@ \cellx1296\cellx2484\cellx3888\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Second\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 5.0\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par} \cell} } \intbl\row} @@ -237,13 +237,13 @@ \clbrdrb\brdrs\cellx1296\clbrdrb\brdrs\cellx2484\clbrdrb\brdrs\cellx3888\clbrdrb\brdrs\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Centered Header\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Centered Header\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left Aligned\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left Aligned\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right Aligned\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right Aligned\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default aligned\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default aligned\par} \cell} } \intbl\row} @@ -252,13 +252,13 @@ \cellx1296\cellx2484\cellx3888\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 First\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12.0\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par} \cell} } \intbl\row} @@ -267,13 +267,13 @@ \cellx1296\cellx2484\cellx3888\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Second\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 5.0\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par} \cell} } \intbl\row} @@ -284,13 +284,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par} \cell} } \intbl\row} @@ -299,13 +299,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par} \cell} } \intbl\row} @@ -314,13 +314,13 @@ \cellx2160\cellx4320\cellx6480\cellx8640 \trkeep\intbl { -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par} \cell} } \intbl\row} @@ -331,13 +331,13 @@ \cellx1296\cellx2484\cellx3888\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 First\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12.0\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par} \cell} } \intbl\row} @@ -346,13 +346,13 @@ \cellx1296\cellx2484\cellx3888\cellx6804 \trkeep\intbl { -{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Second\par} +{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par} \cell} -{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 5.0\par} +{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par} \cell} -{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par} +{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par} \cell} } \intbl\row} -- cgit v1.2.3 From 361167deff57e0e2d3508c598785a7de7b887fb7 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 30 Mar 2014 15:48:40 -0700 Subject: Markdown writer: Use longer backtick fences if needed. If the content contains a backtick fence and there are attributes, make sure longer fences are used to delimit the code. Note: This works well in pandoc, but github markdown is more limited, and will interpret the first string of three or more backticks as ending the code block. Closes #1206. --- src/Text/Pandoc/Writers/Markdown.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 278e5cc9d..e8f976da1 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -392,7 +392,11 @@ blockToMarkdown opts (CodeBlock attribs str) = return $ xs -> case maximum $ map length xs of n | n < 3 -> "~~~~" | otherwise -> replicate (n+1) '~' - backticks = text "```" + backticks = text $ case [ln | ln <- lines str, all (=='`') ln] of + [] -> "```" + xs -> case maximum $ map length xs of + n | n < 3 -> "```" + | otherwise -> replicate (n+1) '`' attrs = if isEnabled Ext_fenced_code_attributes opts then nowrap $ " " <> attrsToMarkdown attribs else case attribs of -- cgit v1.2.3 From 99f4f636df36d84a4bc58f67337af3584595f5c1 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Mon, 31 Mar 2014 11:08:10 -0700 Subject: Make --toc-depth work well with books in latex/pdf output. Closes #1210. --- src/Text/Pandoc/Writers/LaTeX.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index b2eff4490..07be6e9af 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -133,7 +133,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta let context = defField "toc" (writerTableOfContents options) $ defField "toc-depth" (show (writerTOCDepth options - - if writerChapters options + if stBook st then 1 else 0)) $ defField "body" main $ @@ -141,7 +141,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do defField "author-meta" (intercalate "; " authorsMeta) $ defField "documentclass" (if writerBeamer options then ("beamer" :: String) - else if writerChapters options + else if stBook st then "book" else "article") $ defField "verbatim-in-note" (stVerbInNote st) $ -- cgit v1.2.3 From fa0f73aef9d9ff3ca89c1479e3644ac7e7c15991 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Fri, 4 Apr 2014 10:07:56 -0700 Subject: Custom writer: read lua script as UTF-8. This should fix #1189. --- src/Text/Pandoc/Writers/Custom.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 0234e1e35..0d58afb61 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -37,6 +37,7 @@ import Data.Char ( toLower ) import Scripting.Lua (LuaState, StackValue, callfunc) import qualified Scripting.Lua as Lua import Text.Pandoc.UTF8 (fromString, toString) +import qualified Text.Pandoc.UTF8 as UTF8 import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8 import Data.Monoid @@ -131,7 +132,7 @@ instance StackValue MetaValue where -- | Convert Pandoc to custom markup. writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String writeCustom luaFile opts doc = do - luaScript <- readFile luaFile + luaScript <- UTF8.readFile luaFile lua <- Lua.newstate Lua.openlibs lua Lua.loadstring lua luaScript "custom" -- cgit v1.2.3 From 036576c5a2660897e1c977407c621c8c436b7600 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 4 Apr 2014 15:43:47 -0700 Subject: Correctly handle UTF-8 in custom lua scripts. Closes #1189. --- src/Text/Pandoc/Writers/Custom.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 0d58afb61..0b30287f5 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -37,7 +37,6 @@ import Data.Char ( toLower ) import Scripting.Lua (LuaState, StackValue, callfunc) import qualified Scripting.Lua as Lua import Text.Pandoc.UTF8 (fromString, toString) -import qualified Text.Pandoc.UTF8 as UTF8 import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8 import Data.Monoid @@ -132,7 +131,7 @@ instance StackValue MetaValue where -- | Convert Pandoc to custom markup. writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String writeCustom luaFile opts doc = do - luaScript <- UTF8.readFile luaFile + luaScript <- C8.unpack `fmap` C8.readFile luaFile lua <- Lua.newstate Lua.openlibs lua Lua.loadstring lua luaScript "custom" -- cgit v1.2.3 From 98658b55fc922d9ad3d883bdc3bdaddd2318dff2 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 4 Apr 2014 17:39:56 -0700 Subject: LaTeX writer: handle line breaks in simple table cells. Closes #1217. --- src/Text/Pandoc/Writers/LaTeX.hs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 07be6e9af..6cf7ed730 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -500,9 +500,28 @@ tableRowToLaTeX header aligns widths cols = do cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace" +-- For simple latex tables (without minipages or parboxes), +-- we need to go to some lengths to get line breaks working: +-- as LineBreak bs = \vtop{\hbox{\strut as}\hbox{\strut bs}}. +fixLineBreaks :: Block -> Block +fixLineBreaks (Para ils) = Para $ fixLineBreaks' ils +fixLineBreaks (Plain ils) = Plain $ fixLineBreaks' ils +fixLineBreaks x = x + +fixLineBreaks' :: [Inline] -> [Inline] +fixLineBreaks' ils = case splitBy (== LineBreak) ils of + [] -> [] + [xs] -> xs + chunks -> RawInline "tex" "\\vtop{" : + concatMap tohbox chunks ++ + [RawInline "tex" "}"] + where tohbox ys = RawInline "tex" "\\hbox{\\strut " : ys ++ + [RawInline "tex" "}"] + tableCellToLaTeX :: Bool -> (Double, Alignment, [Block]) -> State WriterState Doc -tableCellToLaTeX _ (0, _, blocks) = blockListToLaTeX blocks +tableCellToLaTeX _ (0, _, blocks) = + blockListToLaTeX $ walk fixLineBreaks blocks tableCellToLaTeX header (width, align, blocks) = do modify $ \st -> st{ stInMinipage = True, stNotes = [] } cellContents <- blockListToLaTeX blocks -- cgit v1.2.3 From e352ec5a0e4af245584972e89ae13352e907cdf0 Mon Sep 17 00:00:00 2001 From: John MacFarlane <fiddlosopher@gmail.com> Date: Sun, 6 Apr 2014 16:32:53 -0700 Subject: LaTeX writer: Workaround for level 4-5 headers in quotes. These previously produced invalid LaTeX: `\paragraph` or `\subparagraph` in a `quote` environment. This adds an `mbox{}` in these contexts to work around the problem. See http://tex.stackexchange.com/a/169833/22451. Closes #1221. --- src/Text/Pandoc/Writers/LaTeX.hs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 6cf7ed730..e12c9078f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -51,6 +51,7 @@ import Text.Pandoc.Highlighting (highlight, styleToLaTeX, data WriterState = WriterState { stInNote :: Bool -- true if we're in a note + , stInQuote :: Bool -- true if in a blockquote , stInMinipage :: Bool -- true if in minipage , stNotes :: [Doc] -- notes in a minipage , stOLLevel :: Int -- level of ordered list nesting @@ -73,7 +74,8 @@ data WriterState = writeLaTeX :: WriterOptions -> Pandoc -> String writeLaTeX options document = evalState (pandocToLaTeX options document) $ - WriterState { stInNote = False, stInMinipage = False, stNotes = [], + WriterState { stInNote = False, stInQuote = False, + stInMinipage = False, stNotes = [], stOLLevel = 1, stOptions = options, stVerbInNote = False, stTable = False, stStrikeout = False, @@ -331,7 +333,10 @@ blockToLaTeX (BlockQuote lst) = do modify $ \s -> s{ stIncremental = oldIncremental } return result _ -> do + oldInQuote <- gets stInQuote + modify (\s -> s{stInQuote = True}) contents <- blockListToLaTeX lst + modify (\s -> s{stInQuote = oldInQuote}) return $ "\\begin{quote}" $$ contents $$ "\\end{quote}" blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do opts <- gets stOptions @@ -610,9 +615,16 @@ sectionHeader unnumbered ref level lst = do 4 -> "paragraph" 5 -> "subparagraph" _ -> "" + inQuote <- gets stInQuote + let prefix = if inQuote && level' >= 4 + then text "\\mbox{}%" + -- needed for \paragraph, \subparagraph in quote environment + -- see http://tex.stackexchange.com/questions/169830/ + else empty return $ if level' > 5 then txt - else headerWith ('\\':sectionType) stuffing ref + else prefix $$ + headerWith ('\\':sectionType) stuffing ref $$ if unnumbered then "\\addcontentsline{toc}" <> braces (text sectionType) <> -- cgit v1.2.3 From 36066699c31ca50566ca2492a5c112ecbe690a63 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel <tarleb@moltkeplatz.de> Date: Sat, 12 Apr 2014 00:22:49 +0200 Subject: Org writer: Fix output for linebreaks Hard linebreaks in Org mode are represented by the string "\\" as the last characters in a line. Adds this feature to the Org-mode writer. --- src/Text/Pandoc/Writers/Org.hs | 2 +- tests/writer.org | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index d318c5f6a..58a5729e7 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -271,7 +271,7 @@ inlineToOrg (Math t str) = do else "$$" <> text str <> "$$" inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str inlineToOrg (RawInline _ _) = return empty -inlineToOrg (LineBreak) = return cr -- there's no line break in Org +inlineToOrg (LineBreak) = return (text "\\\\" <> cr) inlineToOrg Space = return space inlineToOrg (Link txt (src, _)) = do case txt of diff --git a/tests/writer.org b/tests/writer.org index 85016f352..524d49305 100644 --- a/tests/writer.org +++ b/tests/writer.org @@ -42,7 +42,7 @@ item. Here's one with a bullet. * criminey. -There should be a hard line break +There should be a hard line break\\ here. -------------- -- cgit v1.2.3 From 464d7a8e49b81a0c883b8c4a9bfd5d26cdfb38ba Mon Sep 17 00:00:00 2001 From: Neil Mayhew <neiljhmayhew@gmail.com> Date: Thu, 6 Mar 2014 07:31:49 -0700 Subject: Improve handling of hard line breaks in Docbook writer * Use a <literallayout> for the entire paragraph, not just for the newline character * Don't let LineBreaks inside footnotes influence the enclosing paragraph --- src/Text/Pandoc/Writers/Docbook.hs | 19 ++++++++++++++++--- tests/writer.docbook | 6 ++---- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 02d875be3..2d6ce3020 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -32,12 +32,14 @@ module Text.Pandoc.Writers.Docbook ( writeDocbook) where import Text.Pandoc.Definition import Text.Pandoc.XML import Text.Pandoc.Shared +import Text.Pandoc.Walk import Text.Pandoc.Writers.Shared import Text.Pandoc.Options import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Readers.TeXMath import Data.List ( isPrefixOf, intercalate, isSuffixOf ) import Data.Char ( toLower ) +import Data.Monoid ( Any(..) ) import Text.Pandoc.Highlighting ( languages, languagesByExtension ) import Text.Pandoc.Pretty import qualified Text.Pandoc.Builder as B @@ -165,8 +167,9 @@ blockToDocbook opts (Para [Image txt (src,'f':'i':'g':':':_)]) = (inTagsIndented "imageobject" (selfClosingTag "imagedata" [("fileref",src)])) $$ inTagsSimple "textobject" (inTagsSimple "phrase" alt)) -blockToDocbook opts (Para lst) = - inTagsIndented "para" $ inlinesToDocbook opts lst +blockToDocbook opts (Para lst) + | hasLineBreaks lst = flush $ nowrap $ inTagsSimple "literallayout" $ inlinesToDocbook opts lst + | otherwise = inTagsIndented "para" $ inlinesToDocbook opts lst blockToDocbook opts (BlockQuote blocks) = inTagsIndented "blockquote" $ blocksToDocbook opts blocks blockToDocbook _ (CodeBlock (_,classes,_) str) = @@ -226,6 +229,16 @@ blockToDocbook opts (Table caption aligns widths headers rows) = (inTags True "tgroup" [("cols", show (length headers))] $ coltags $$ head' $$ body') +hasLineBreaks :: [Inline] -> Bool +hasLineBreaks = getAny . query isLineBreak . walk removeNote + where + removeNote :: Inline -> Inline + removeNote (Note _) = Str "" + removeNote x = x + isLineBreak :: Inline -> Any + isLineBreak LineBreak = Any True + isLineBreak _ = Any False + alignmentToString :: Alignment -> [Char] alignmentToString alignment = case alignment of AlignLeft -> "left" @@ -293,7 +306,7 @@ inlineToDocbook opts (Math t str) fixNS = everywhere (mkT fixNS') inlineToDocbook _ (RawInline f x) | f == "html" || f == "docbook" = text x | otherwise = empty -inlineToDocbook _ LineBreak = flush $ inTagsSimple "literallayout" (text "\n") +inlineToDocbook _ LineBreak = text "\n" inlineToDocbook _ Space = space inlineToDocbook opts (Link txt (src, _)) = if isPrefixOf "mailto:" src diff --git a/tests/writer.docbook b/tests/writer.docbook index d4b3c7efd..9cb9a5359 100644 --- a/tests/writer.docbook +++ b/tests/writer.docbook @@ -68,10 +68,8 @@ <para> Here’s one with a bullet. * criminey. </para> - <para> - There should be a hard line break<literallayout> -</literallayout>here. - </para> +<literallayout>There should be a hard line break +here.</literallayout> </sect1> <sect1 id="block-quotes"> <title>Block Quotes -- cgit v1.2.3 From e0688711fd8fb640d96044413aa2d7b1b1cd4e03 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 23 Apr 2014 10:23:02 -0700 Subject: EPUB writer: include extension in epub ids. This fixes a problem with duplicate extensions for fonts and images with the same base name but different extensions. Closes #1254. --- src/Text/Pandoc/Writers/EPUB.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index dae45b90f..9f10554a9 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -35,7 +35,7 @@ import Data.Maybe ( fromMaybe ) import Data.List ( isInfixOf, intercalate ) import System.Environment ( getEnv ) import Text.Printf (printf) -import System.FilePath ( (), takeBaseName, takeExtension, takeFileName ) +import System.FilePath ( (), takeExtension, takeFileName ) import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy.Char8 as B8 import qualified Text.Pandoc.UTF8 as UTF8 @@ -56,7 +56,7 @@ import Text.XML.Light hiding (ppTopElement) import Text.Pandoc.UUID import Text.Pandoc.Writers.HTML import Text.Pandoc.Writers.Markdown ( writePlain ) -import Data.Char ( toLower, isDigit ) +import Data.Char ( toLower, isDigit, isAlphaNum ) import Network.URI ( unEscapeString ) import Text.Pandoc.MIME (getMimeType) #if MIN_VERSION_base(4,6,0) @@ -132,6 +132,11 @@ removeNote :: Inline -> Inline removeNote (Note _) = Str "" removeNote x = x +toId :: FilePath -> String +toId = map (\x -> if isAlphaNum x || x == '-' || x == '_' + then x + else '_') . takeFileName + getEPUBMetadata :: WriterOptions -> Meta -> IO EPUBMetadata getEPUBMetadata opts meta = do let md = metadataFromMeta opts meta @@ -427,7 +432,7 @@ writeEPUB opts doc@(Pandoc meta _) = do -- contents.opf let chapterNode ent = unode "item" ! - ([("id", takeBaseName $ eRelativePath ent), + ([("id", toId $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", "application/xhtml+xml")] ++ case props ent of @@ -435,14 +440,14 @@ writeEPUB opts doc@(Pandoc meta _) = do xs -> [("properties", unwords xs)]) $ () let chapterRefNode ent = unode "itemref" ! - [("idref", takeBaseName $ eRelativePath ent)] $ () + [("idref", takeFileName $ eRelativePath ent)] $ () let pictureNode ent = unode "item" ! - [("id", takeBaseName $ eRelativePath ent), + [("id", toId $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", fromMaybe "application/octet-stream" $ mediaTypeOf $ eRelativePath ent)] $ () let fontNode ent = unode "item" ! - [("id", takeBaseName $ eRelativePath ent), + [("id", toId $ eRelativePath ent), ("href", eRelativePath ent), ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ () let plainTitle = case docTitle meta of -- cgit v1.2.3 From e6333a9d7cfe8ec36acae59bd19a654d868f4b8d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 24 Apr 2014 16:44:49 -0700 Subject: Markdown writer: Use proper escapes to avoid unwanted lists. Previously we used 0-width spaces, an ugly hack. Closes #980. --- src/Text/Pandoc/Writers/Markdown.hs | 27 ++++++++++++++++----------- tests/writer.opml | 10 +++++----- 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index e8f976da1..95082add6 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -316,20 +316,25 @@ blockToMarkdown opts (Div attrs ils) = do contents <> blankline <> "
" <> blankline blockToMarkdown opts (Plain inlines) = do contents <- inlineListToMarkdown opts inlines - return $ contents <> cr + -- escape if para starts with ordered list marker + st <- get + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + let rendered = render colwidth contents + let escapeDelimiter (x:xs) | x `elem` ".()" = '\\':x:xs + | otherwise = x : escapeDelimiter xs + escapeDelimiter [] = [] + let contents' = if isEnabled Ext_all_symbols_escapable opts && + not (stPlain st) && beginsWithOrderedListMarker rendered + then text $ escapeDelimiter rendered + else contents + return $ contents' <> cr -- title beginning with fig: indicates figure blockToMarkdown opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = blockToMarkdown opts (Para [Image alt (src,tit)]) -blockToMarkdown opts (Para inlines) = do - contents <- inlineListToMarkdown opts inlines - -- escape if para starts with ordered list marker - st <- get - let esc = if isEnabled Ext_all_symbols_escapable opts && - not (stPlain st) && - beginsWithOrderedListMarker (render Nothing contents) - then text "\x200B" -- zero-width space, a hack - else empty - return $ esc <> contents <> blankline +blockToMarkdown opts (Para inlines) = + (<> blankline) `fmap` blockToMarkdown opts (Plain inlines) blockToMarkdown opts (RawBlock f str) | f == "html" = do st <- get diff --git a/tests/writer.opml b/tests/writer.opml index 228cad247..34d161fb8 100644 --- a/tests/writer.opml +++ b/tests/writer.opml @@ -18,7 +18,7 @@ - + @@ -55,18 +55,18 @@ - + - + - + - + -- cgit v1.2.3 From cbeb3bb2132908b76e3a83e61ff99418ebdf83b4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 24 Apr 2014 17:37:10 -0700 Subject: EPUB writer: Fixed some idrefs to match changes in ids. --- src/Text/Pandoc/Writers/EPUB.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 9f10554a9..c39a7798d 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -440,7 +440,7 @@ writeEPUB opts doc@(Pandoc meta _) = do xs -> [("properties", unwords xs)]) $ () let chapterRefNode ent = unode "itemref" ! - [("idref", takeFileName $ eRelativePath ent)] $ () + [("idref", toId $ eRelativePath ent)] $ () let pictureNode ent = unode "item" ! [("id", toId $ eRelativePath ent), ("href", eRelativePath ent), @@ -488,8 +488,8 @@ writeEPUB opts doc@(Pandoc meta _) = do case epubCoverImage metadata of Nothing -> [] Just _ -> [ unode "itemref" ! - [("idref", "cover"),("linear","no")] $ () ] - ++ ((unode "itemref" ! [("idref", "title_page") + [("idref", "cover_xhtml"),("linear","no")] $ () ] + ++ ((unode "itemref" ! [("idref", "title_page_xhtml") ,("linear", if null (docTitle meta) then "no" else "yes")] $ ()) : -- cgit v1.2.3 From b09412d852880a0c8e18e1cab9b0ce33f0e0e8a2 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 25 Apr 2014 16:14:52 +0200 Subject: LaTeX writer: Mark span contents with label if span has an ID Prepend `\label{span-id}` to span contents iff `span-id` is defined. --- src/Text/Pandoc/Writers/LaTeX.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index e12c9078f..e52220f01 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -655,16 +655,20 @@ isQuoted _ = False -- | Convert inline element to LaTeX inlineToLaTeX :: Inline -- ^ Inline to convert -> State WriterState Doc -inlineToLaTeX (Span (_,classes,_) ils) = do +inlineToLaTeX (Span (id',classes,_) ils) = do let noEmph = "csl-no-emph" `elem` classes let noStrong = "csl-no-strong" `elem` classes let noSmallCaps = "csl-no-smallcaps" `elem` classes - ((if noEmph then inCmd "textup" else id) . - (if noStrong then inCmd "textnormal" else id) . - (if noSmallCaps then inCmd "textnormal" else id) . - (if not (noEmph || noStrong || noSmallCaps) - then braces - else id)) `fmap` inlineListToLaTeX ils + let label' = if (null id') + then empty + else text "\\label" <> braces (text $ toLabel id') + fmap (label' <>) + ((if noEmph then inCmd "textup" else id) . + (if noStrong then inCmd "textnormal" else id) . + (if noSmallCaps then inCmd "textnormal" else id) . + (if not (noEmph || noStrong || noSmallCaps) + then braces + else id)) `fmap` inlineListToLaTeX ils inlineToLaTeX (Emph lst) = inlineListToLaTeX lst >>= return . inCmd "emph" inlineToLaTeX (Strong lst) = -- cgit v1.2.3 From 35ea8de3690fcd9bf06532576ced4d82fd51f26d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 26 Apr 2014 12:04:08 -0700 Subject: HTML writer: improved detection of image links. Previously image links with queries were not recognized, leading to use of an embed tag rather than an img tag. --- src/Text/Pandoc/Writers/HTML.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index e0385af25..1de4345f9 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -40,6 +40,7 @@ import Text.Pandoc.Slides import Text.Pandoc.Highlighting ( highlight, styleToCss, formatHtmlInline, formatHtmlBlock ) import Text.Pandoc.XML (fromEntities, escapeStringForXML) +import Network.URI ( parseURIReference, URI(..) ) import Network.HTTP ( urlEncode ) import Numeric ( showHex ) import Data.Char ( ord, toLower ) @@ -396,7 +397,10 @@ imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf", treatAsImage :: FilePath -> Bool treatAsImage fp = - let ext = map toLower $ drop 1 $ takeExtension fp + let path = case uriPath `fmap` parseURIReference fp of + Nothing -> fp + Just up -> up + ext = map toLower $ drop 1 $ takeExtension path in null ext || ext `elem` imageExts -- | Convert Pandoc block element to HTML. -- cgit v1.2.3 From 093229dc35506bff88f4edc6f2ae5316d621f8ff Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 30 Apr 2014 08:58:10 -0700 Subject: ConTeXt writer: Improved autolinks. Closes #1270. --- src/Text/Pandoc/Writers/ConTeXt.hs | 16 +++++----------- tests/writer.context | 10 ++++------ 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 3095cf508..cec420dcf 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -35,7 +35,7 @@ import Text.Pandoc.Writers.Shared import Text.Pandoc.Options import Text.Pandoc.Walk (query) import Text.Printf ( printf ) -import Data.List ( intercalate, isPrefixOf ) +import Data.List ( intercalate ) import Control.Monad.State import Text.Pandoc.Pretty import Text.Pandoc.Templates ( renderTemplate' ) @@ -283,14 +283,6 @@ inlineToConTeXt (RawInline "tex" str) = return $ text str inlineToConTeXt (RawInline _ _) = return empty inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr inlineToConTeXt Space = return space --- autolink -inlineToConTeXt (Link [Str str] (src, tit)) - | if "mailto:" `isPrefixOf` src - then src == escapeURI ("mailto:" ++ str) - else src == escapeURI str = - inlineToConTeXt (Link - [RawInline "context" "\\hyphenatedurl{", Str str, RawInline "context" "}"] - (src, tit)) -- Handle HTML-like internal document references to sections inlineToConTeXt (Link txt (('#' : ref), _)) = do opts <- gets stOptions @@ -305,6 +297,7 @@ inlineToConTeXt (Link txt (('#' : ref), _)) = do <> brackets (text ref) inlineToConTeXt (Link txt (src, _)) = do + let isAutolink = txt == [Str src] st <- get let next = stNextRef st put $ st {stNextRef = next + 1} @@ -313,8 +306,9 @@ inlineToConTeXt (Link txt (src, _)) = do return $ "\\useURL" <> brackets (text ref) <> brackets (text $ escapeStringUsing [('#',"\\#"),('%',"\\%")] src) - <> brackets empty - <> brackets label + <> (if isAutolink + then empty + else brackets empty <> brackets label) <> "\\from" <> brackets (text ref) inlineToConTeXt (Image _ (src, _)) = do diff --git a/tests/writer.context b/tests/writer.context index 0b031fd76..0c5024d89 100644 --- a/tests/writer.context +++ b/tests/writer.context @@ -813,24 +813,22 @@ braces]\from[url26]. \subsection[autolinks]{Autolinks} -With an ampersand: -\useURL[url27][http://example.com/?foo=1&bar=2][][\hyphenatedurl{http://example.com/?foo=1&bar=2}]\from[url27] +With an ampersand: \useURL[url27][http://example.com/?foo=1&bar=2]\from[url27] \startitemize[packed] \item In a list? \item - \useURL[url28][http://example.com/][][\hyphenatedurl{http://example.com/}]\from[url28] + \useURL[url28][http://example.com/]\from[url28] \item It should. \stopitemize An e-mail address: -\useURL[url29][mailto:nobody@nowhere.net][][\hyphenatedurl{nobody@nowhere.net}]\from[url29] +\useURL[url29][mailto:nobody@nowhere.net][][nobody@nowhere.net]\from[url29] \startblockquote -Blockquoted: -\useURL[url30][http://example.com/][][\hyphenatedurl{http://example.com/}]\from[url30] +Blockquoted: \useURL[url30][http://example.com/]\from[url30] \stopblockquote Auto-links should not occur here: \type{} -- cgit v1.2.3 From ccbf4fc9c20ccdce0f7144845cd022ee8cfca1af Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Mon, 14 Apr 2014 19:07:14 -0600 Subject: Distinguish tight and loose lists in Docbook output Determined by the first block of the first item being Plain. --- src/Text/Pandoc/Writers/Docbook.hs | 26 +++-- tests/Tests/Writers/Docbook.hs | 199 +++++++++++++++++++++++++++++++++++-- tests/writer.docbook | 60 +++++------ 3 files changed, 236 insertions(+), 49 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 2d6ce3020..e1b62f02d 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -185,10 +185,13 @@ blockToDocbook _ (CodeBlock (_,classes,_) str) = else languagesByExtension . map toLower $ s langs = concatMap langsFrom classes blockToDocbook opts (BulletList lst) = - inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst + let attribs = case lst of + ((Plain _:_):_) -> [("spacing", "compact")] + _ -> [] + in inTags True "itemizedlist" attribs $ listItemsToDocbook opts lst blockToDocbook _ (OrderedList _ []) = empty blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = - let attribs = case numstyle of + let numeration = case numstyle of DefaultStyle -> [] Decimal -> [("numeration", "arabic")] Example -> [("numeration", "arabic")] @@ -196,14 +199,21 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = LowerAlpha -> [("numeration", "loweralpha")] UpperRoman -> [("numeration", "upperroman")] LowerRoman -> [("numeration", "lowerroman")] - items = if start == 1 - then listItemsToDocbook opts (first:rest) - else (inTags True "listitem" [("override",show start)] - (blocksToDocbook opts $ map plainToPara first)) $$ - listItemsToDocbook opts rest + spacing = case first of + (Plain _:_) -> [("spacing", "compact")] + _ -> [] + attribs = numeration ++ spacing + items = if start == 1 + then listItemsToDocbook opts (first:rest) + else (inTags True "listitem" [("override",show start)] + (blocksToDocbook opts $ map plainToPara first)) $$ + listItemsToDocbook opts rest in inTags True "orderedlist" attribs items blockToDocbook opts (DefinitionList lst) = - inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst + let attribs = case lst of + ((_, (Plain _:_):_):_) -> [("spacing", "compact")] + _ -> [] + in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst blockToDocbook _ (RawBlock f str) | f == "docbook" = text str -- raw XML block | f == "html" = text str -- allow html for backwards compatibility diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs index e815b4f5a..97126b473 100644 --- a/tests/Tests/Writers/Docbook.hs +++ b/tests/Tests/Writers/Docbook.hs @@ -31,22 +31,199 @@ lineblock :: Blocks lineblock = para ("some text" <> linebreak <> "and more lines" <> linebreak <> "and again") -lineblock_out :: String -lineblock_out = "some text\n" ++ - "and more lines\n" ++ - "and again" +lineblock_out :: [String] +lineblock_out = [ "some text" + , "and more lines" + , "and again" + ] tests :: [Test] tests = [ testGroup "line blocks" [ "none" =: para "This is a test" - =?> "\n This is a test\n" + =?> unlines + [ "" + , " This is a test" + , "" + ] , "basic" =: lineblock - =?> lineblock_out + =?> unlines lineblock_out , "blockquote" =: blockQuote lineblock - =?> ("
\n" ++ lineblock_out ++ "\n
") - , "footnote" =: para ("This is a test" <> note lineblock <> " of footnotes") - =?> ("\n This is a test\n" ++ - lineblock_out ++ - "\n of footnotes\n") + =?> unlines + ( [ "
" ] ++ + lineblock_out ++ + [ "
" ] + ) + , "footnote" =: para ("This is a test" <> + note lineblock <> + " of footnotes") + =?> unlines + ( [ "" + , " This is a test" ] ++ + lineblock_out ++ + [ " of footnotes" + , "" ] + ) + ] + , testGroup "compact lists" + [ testGroup "bullet" + [ "compact" =: bulletList [plain "a", plain "b", plain "c"] + =?> unlines + [ "" + , " " + , " " + , " a" + , " " + , " " + , " " + , " " + , " b" + , " " + , " " + , " " + , " " + , " c" + , " " + , " " + , "" + ] + , "loose" =: bulletList [para "a", para "b", para "c"] + =?> unlines + [ "" + , " " + , " " + , " a" + , " " + , " " + , " " + , " " + , " b" + , " " + , " " + , " " + , " " + , " c" + , " " + , " " + , "" + ] + ] + , testGroup "ordered" + [ "compact" =: orderedList [plain "a", plain "b", plain "c"] + =?> unlines + [ "" + , " " + , " " + , " a" + , " " + , " " + , " " + , " " + , " b" + , " " + , " " + , " " + , " " + , " c" + , " " + , " " + , "" + ] + , "loose" =: orderedList [para "a", para "b", para "c"] + =?> unlines + [ "" + , " " + , " " + , " a" + , " " + , " " + , " " + , " " + , " b" + , " " + , " " + , " " + , " " + , " c" + , " " + , " " + , "" + ] + ] + , testGroup "definition" + [ "compact" =: definitionList [ ("an", [plain "apple" ]) + , ("a", [plain "banana"]) + , ("an", [plain "orange"])] + =?> unlines + [ "" + , " " + , " " + , " an" + , " " + , " " + , " " + , " apple" + , " " + , " " + , " " + , " " + , " " + , " a" + , " " + , " " + , " " + , " banana" + , " " + , " " + , " " + , " " + , " " + , " an" + , " " + , " " + , " " + , " orange" + , " " + , " " + , " " + , "" + ] + , "loose" =: definitionList [ ("an", [para "apple" ]) + , ("a", [para "banana"]) + , ("an", [para "orange"])] + =?> unlines + [ "" + , " " + , " " + , " an" + , " " + , " " + , " " + , " apple" + , " " + , " " + , " " + , " " + , " " + , " a" + , " " + , " " + , " " + , " banana" + , " " + , " " + , " " + , " " + , " " + , " an" + , " " + , " " + , " " + , " orange" + , " " + , " " + , " " + , "" + ] + ] ] ] diff --git a/tests/writer.docbook b/tests/writer.docbook index 9cb9a5359..26dcbadaa 100644 --- a/tests/writer.docbook +++ b/tests/writer.docbook @@ -93,7 +93,7 @@ sub status { A list: - + item one @@ -156,7 +156,7 @@ These should not be escaped: \$ \\ \> \[ \{ Asterisks tight: - + asterisk 1 @@ -196,7 +196,7 @@ These should not be escaped: \$ \\ \> \[ \{ Pluses tight: - + Plus 1 @@ -236,7 +236,7 @@ These should not be escaped: \$ \\ \> \[ \{ Minuses tight: - + Minus 1 @@ -279,7 +279,7 @@ These should not be escaped: \$ \\ \> \[ \{ Tight: - + First @@ -299,7 +299,7 @@ These should not be escaped: \$ \\ \> \[ \{ and: - + One @@ -383,17 +383,17 @@ These should not be escaped: \$ \\ \> \[ \{ Nested - + Tab - + Tab - + Tab @@ -407,7 +407,7 @@ These should not be escaped: \$ \\ \> \[ \{ Here’s another: - + First @@ -417,7 +417,7 @@ These should not be escaped: \$ \\ \> \[ \{ Second: - + Fee @@ -454,7 +454,7 @@ These should not be escaped: \$ \\ \> \[ \{ Second: - + Fee @@ -508,7 +508,7 @@ These should not be escaped: \$ \\ \> \[ \{ Fancy list markers - + begins with 2 @@ -521,7 +521,7 @@ These should not be escaped: \$ \\ \> \[ \{ with a continuation - + sublist with roman numerals, starting with 4 @@ -531,7 +531,7 @@ These should not be escaped: \$ \\ \> \[ \{ more items - + a subsublist @@ -550,22 +550,22 @@ These should not be escaped: \$ \\ \> \[ \{ Nesting: - + Upper Alpha - + Upper Roman. - + Decimal start with 6 - + Lower alpha with paren @@ -581,7 +581,7 @@ These should not be escaped: \$ \\ \> \[ \{ Autonumbering: - + Autonumber. @@ -591,7 +591,7 @@ These should not be escaped: \$ \\ \> \[ \{ More. - + Nested. @@ -616,7 +616,7 @@ These should not be escaped: \$ \\ \> \[ \{ Tight using spaces: - + apple @@ -651,7 +651,7 @@ These should not be escaped: \$ \\ \> \[ \{ Tight using tabs: - + apple @@ -757,7 +757,7 @@ These should not be escaped: \$ \\ \> \[ \{ Multiple definitions, tight: - + apple @@ -841,7 +841,7 @@ These should not be escaped: \$ \\ \> \[ \{ orange fruit - + sublist @@ -1051,7 +1051,7 @@ These should not be escaped: \$ \\ \> \[ \{ LaTeX - + @@ -1097,7 +1097,7 @@ These should not be escaped: \$ \\ \> \[ \{ These shouldn’t be math: - + To get the famous equation, write $e = mc^2$. @@ -1130,7 +1130,7 @@ These should not be escaped: \$ \\ \> \[ \{ Here is some unicode: - + I hat: Î @@ -1316,7 +1316,7 @@ These should not be escaped: \$ \\ \> \[ \{ With an ampersand: http://example.com/?foo=1&bar=2 - + In a list? @@ -1414,7 +1414,7 @@ or here: <http://example.com/> - + And in list items. -- cgit v1.2.3 From abd3a039b9adcafa8aa1df6e0753a725f90c78fc Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 3 May 2014 20:45:05 -0700 Subject: DocBook writer: Small tweaks to last commit. * Use isTightList from Shared. * Adjust writer test, since isTightList is a bit different from what was used before. Closes #1250. --- src/Text/Pandoc/Writers/Docbook.hs | 12 +++--------- tests/writer.docbook | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index e1b62f02d..1a8e58354 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -185,9 +185,7 @@ blockToDocbook _ (CodeBlock (_,classes,_) str) = else languagesByExtension . map toLower $ s langs = concatMap langsFrom classes blockToDocbook opts (BulletList lst) = - let attribs = case lst of - ((Plain _:_):_) -> [("spacing", "compact")] - _ -> [] + let attribs = [("spacing", "compact") | isTightList lst] in inTags True "itemizedlist" attribs $ listItemsToDocbook opts lst blockToDocbook _ (OrderedList _ []) = empty blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = @@ -199,9 +197,7 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = LowerAlpha -> [("numeration", "loweralpha")] UpperRoman -> [("numeration", "upperroman")] LowerRoman -> [("numeration", "lowerroman")] - spacing = case first of - (Plain _:_) -> [("spacing", "compact")] - _ -> [] + spacing = [("spacing", "compact") | isTightList (first:rest)] attribs = numeration ++ spacing items = if start == 1 then listItemsToDocbook opts (first:rest) @@ -210,9 +206,7 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = listItemsToDocbook opts rest in inTags True "orderedlist" attribs items blockToDocbook opts (DefinitionList lst) = - let attribs = case lst of - ((_, (Plain _:_):_):_) -> [("spacing", "compact")] - _ -> [] + let attribs = [("spacing", "compact") | isTightList $ concatMap snd lst] in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst blockToDocbook _ (RawBlock f str) | f == "docbook" = text str -- raw XML block diff --git a/tests/writer.docbook b/tests/writer.docbook index 26dcbadaa..01daa2c30 100644 --- a/tests/writer.docbook +++ b/tests/writer.docbook @@ -508,7 +508,7 @@ These should not be escaped: \$ \\ \> \[ \{ Fancy list markers - + begins with 2 -- cgit v1.2.3 From fde52c25a65c479871afcf8192f56d2918230f5e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 3 May 2014 21:08:45 -0700 Subject: AsciiDoc writer: Correctly handle empty table cells. Closes #1245. --- src/Text/Pandoc/Writers/AsciiDoc.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 68b525742..e5868172e 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -217,6 +217,7 @@ blockToAsciiDoc opts (Table caption aligns widths headers rows) = do let makeCell [Plain x] = do d <- blockListToAsciiDoc opts [Plain x] return $ text "|" <> chomp d makeCell [Para x] = makeCell [Plain x] + makeCell [] = return $ text "|" makeCell _ = return $ text "|" <> "[multiblock cell omitted]" let makeRow cells = hsep `fmap` mapM makeCell cells rows' <- mapM makeRow rows @@ -227,7 +228,7 @@ blockToAsciiDoc opts (Table caption aligns widths headers rows) = do else 100000 let maxwidth = maximum $ map offset (head':rows') let body = if maxwidth > colwidth then vsep rows' else vcat rows' - let border = text $ "|" ++ replicate ((min maxwidth colwidth) - 1) '=' + let border = text $ "|" ++ replicate (max 5 (min maxwidth colwidth) - 1) '=' return $ caption'' $$ tablespec $$ border $$ head'' $$ body $$ border $$ blankline blockToAsciiDoc opts (BulletList items) = do -- cgit v1.2.3 From 96c0c950cab8b42d5d6b8b1a6f1fb20f7f4a5aae Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 3 May 2014 21:31:53 -0700 Subject: AsciiDoc writer: Handle multiblock table cells. Closes #1246. --- src/Text/Pandoc/Writers/AsciiDoc.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index e5868172e..15579cba2 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -218,7 +218,8 @@ blockToAsciiDoc opts (Table caption aligns widths headers rows) = do return $ text "|" <> chomp d makeCell [Para x] = makeCell [Plain x] makeCell [] = return $ text "|" - makeCell _ = return $ text "|" <> "[multiblock cell omitted]" + makeCell bs = do d <- blockListToAsciiDoc opts bs + return $ text "a|" $$ d let makeRow cells = hsep `fmap` mapM makeCell cells rows' <- mapM makeRow rows head' <- makeRow headers -- cgit v1.2.3 From d72871598174474218ae46dd984632a3753882b1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 4 May 2014 10:45:20 -0700 Subject: Docx writer: Added ability to give fallback in parseXml. --- src/Text/Pandoc/Writers/Docx.hs | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 2a834c2da..bb2071455 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -217,7 +217,7 @@ writeDocx opts doc@(Pandoc meta _) = do -- styles let newstyles = styleToOpenXml $ writerHighlightStyle opts let stylepath = "word/styles.xml" - styledoc <- parseXml refArchive stylepath + styledoc <- parseXml refArchive stylepath Nothing let styledoc' = styledoc{ elContent = elContent styledoc ++ [Elem x | x <- newstyles, writerHighlight opts] } let styleEntry = toEntry stylepath epochtime $ renderXml styledoc' @@ -256,19 +256,20 @@ writeDocx opts doc@(Pandoc meta _) = do ] let relsEntry = toEntry relsPath epochtime $ renderXml rels - let entryFromArchive path = (toEntry path epochtime . renderXml) `fmap` - parseXml refArchive path - docPropsAppEntry <- entryFromArchive "docProps/app.xml" - themeEntry <- entryFromArchive "word/theme/theme1.xml" - fontTableEntry <- entryFromArchive "word/fontTable.xml" - settingsEntry <- entryFromArchive "word/settings.xml" - webSettingsEntry <- entryFromArchive "word/webSettings.xml" + let entryFromArchive path fallback = + (toEntry path epochtime . renderXml) `fmap` + parseXml refArchive path fallback + docPropsAppEntry <- entryFromArchive "docProps/app.xml" Nothing + themeEntry <- entryFromArchive "word/theme/theme1.xml" Nothing + fontTableEntry <- entryFromArchive "word/fontTable.xml" Nothing + settingsEntry <- entryFromArchive "word/settings.xml" Nothing + webSettingsEntry <- entryFromArchive "word/webSettings.xml" Nothing let miscRels = [ f | f <- filesInArchive refArchive , "word/_rels/" `isPrefixOf` f , ".xml.rels" `isSuffixOf` f , f /= "word/_rels/document.xml.rels" , f /= "word/_rels/footnotes.xml.rels" ] - miscRelEntries <- mapM entryFromArchive miscRels + miscRelEntries <- mapM (\f -> entryFromArchive f Nothing) miscRels -- Create archive let archive = foldr addEntryToArchive emptyArchive $ @@ -814,10 +815,10 @@ inlineToOpenXML opts (Image alt (src, tit)) = do br :: Element br = mknode "w:r" [] [mknode "w:br" [("w:type","textWrapping")] () ] -parseXml :: Archive -> String -> IO Element -parseXml refArchive relpath = - case findEntryByPath relpath refArchive of - Just e -> case parseXMLDoc $ UTF8.toStringLazy $ fromEntry e of - Just d -> return d - Nothing -> fail $ relpath ++ " corrupt in reference docx" - Nothing -> fail $ relpath ++ " missing in reference docx" +parseXml :: Archive -> String -> Maybe String -> IO Element +parseXml refArchive relpath fallback = + case (findEntryByPath relpath refArchive + >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) `mplus` + (fallback >>= parseXMLDoc) of + Just d -> return d + Nothing -> fail $ relpath ++ " corrupt or missing in reference docx" -- cgit v1.2.3 From 0c7e084342b2a077f83809e6613979adcefb1592 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 4 May 2014 10:54:45 -0700 Subject: Docx writer: Fall back on distribution reference.docx. * Undid changes to parseXml in last commit. * Instead of a string fallback, we have parseXml fall back on the reference.docx that comes with pandoc if the user's reference.docx does not contain a needed file. * Closes #1185. --- src/Text/Pandoc/Writers/Docx.hs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index bb2071455..fcb73a427 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -116,6 +116,7 @@ writeDocx opts doc@(Pandoc meta _) = do case writerReferenceDocx opts of Just f -> B.readFile f Nothing -> readDataFile datadir "reference.docx" + distArchive <- liftM (toArchive . toLazy) $ readDataFile Nothing "reference.docx" ((contents, footnotes), st) <- runStateT (writeOpenXML opts{writerWrapText = False} doc') defaultWriterState @@ -217,7 +218,7 @@ writeDocx opts doc@(Pandoc meta _) = do -- styles let newstyles = styleToOpenXml $ writerHighlightStyle opts let stylepath = "word/styles.xml" - styledoc <- parseXml refArchive stylepath Nothing + styledoc <- parseXml refArchive distArchive stylepath let styledoc' = styledoc{ elContent = elContent styledoc ++ [Elem x | x <- newstyles, writerHighlight opts] } let styleEntry = toEntry stylepath epochtime $ renderXml styledoc' @@ -256,20 +257,20 @@ writeDocx opts doc@(Pandoc meta _) = do ] let relsEntry = toEntry relsPath epochtime $ renderXml rels - let entryFromArchive path fallback = + let entryFromArchive path = (toEntry path epochtime . renderXml) `fmap` - parseXml refArchive path fallback - docPropsAppEntry <- entryFromArchive "docProps/app.xml" Nothing - themeEntry <- entryFromArchive "word/theme/theme1.xml" Nothing - fontTableEntry <- entryFromArchive "word/fontTable.xml" Nothing - settingsEntry <- entryFromArchive "word/settings.xml" Nothing - webSettingsEntry <- entryFromArchive "word/webSettings.xml" Nothing + parseXml refArchive distArchive path + docPropsAppEntry <- entryFromArchive "docProps/app.xml" + themeEntry <- entryFromArchive "word/theme/theme1.xml" + fontTableEntry <- entryFromArchive "word/fontTable.xml" + settingsEntry <- entryFromArchive "word/settings.xml" + webSettingsEntry <- entryFromArchive "word/webSettings.xml" let miscRels = [ f | f <- filesInArchive refArchive , "word/_rels/" `isPrefixOf` f , ".xml.rels" `isSuffixOf` f , f /= "word/_rels/document.xml.rels" , f /= "word/_rels/footnotes.xml.rels" ] - miscRelEntries <- mapM (\f -> entryFromArchive f Nothing) miscRels + miscRelEntries <- mapM entryFromArchive miscRels -- Create archive let archive = foldr addEntryToArchive emptyArchive $ @@ -815,10 +816,10 @@ inlineToOpenXML opts (Image alt (src, tit)) = do br :: Element br = mknode "w:r" [] [mknode "w:br" [("w:type","textWrapping")] () ] -parseXml :: Archive -> String -> Maybe String -> IO Element -parseXml refArchive relpath fallback = - case (findEntryByPath relpath refArchive - >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) `mplus` - (fallback >>= parseXMLDoc) of +parseXml :: Archive -> Archive -> String -> IO Element +parseXml refArchive distArchive relpath = + case ((findEntryByPath relpath refArchive `mplus` + findEntryByPath relpath distArchive) + >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of Just d -> return d Nothing -> fail $ relpath ++ " corrupt or missing in reference docx" -- cgit v1.2.3 From 51aa3048347280db6798a84a30af4f6e1ae56b26 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 4 May 2014 14:43:05 -0700 Subject: LaTeX writer: Fixed inconsistencies with reference escaping. - toLabel is now monadic, and it does the needed string escaping. - Closes #1130. --- src/Text/Pandoc/Writers/LaTeX.hs | 131 ++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 64 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index e52220f01..c17e041b5 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -193,7 +193,7 @@ stringToLaTeX _ [] = return "" stringToLaTeX ctx (x:xs) = do opts <- gets stOptions rest <- stringToLaTeX ctx xs - let ligatures = writerTeXLigatures opts && (ctx /= CodeString) + let ligatures = writerTeXLigatures opts && ctx == TextString let isUrl = ctx == URLString when (x == '€') $ modify $ \st -> st{ stUsesEuro = True } @@ -207,7 +207,8 @@ stringToLaTeX ctx (x:xs) = do '&' -> "\\&" ++ rest '_' | not isUrl -> "\\_" ++ rest '#' -> "\\#" ++ rest - '-' -> case xs of -- prevent adjacent hyphens from forming ligatures + '-' | not isUrl -> case xs of + -- prevent adjacent hyphens from forming ligatures ('-':_) -> "-\\/" ++ rest _ -> '-' : rest '~' | not isUrl -> "\\textasciitilde{}" ++ rest @@ -229,12 +230,13 @@ stringToLaTeX ctx (x:xs) = do '\x2013' | ligatures -> "--" ++ rest _ -> x : rest -toLabel :: String -> String -toLabel [] = "" -toLabel (x:xs) - | (isLetter x || isDigit x) && isAscii x = x:toLabel xs - | elem x "-+=:;." = x:toLabel xs - | otherwise = "ux" ++ printf "%x" (ord x) ++ toLabel xs +toLabel :: String -> State WriterState String +toLabel z = go `fmap` stringToLaTeX URLString z + where go [] = "" + go (x:xs) + | (isLetter x || isDigit x) && isAscii x = x:go xs + | elem x "-+=:;." = x:go xs + | otherwise = "ux" ++ printf "%x" (ord x) ++ go xs -- | Puts contents into LaTeX command. inCmd :: String -> Doc -> Doc @@ -340,57 +342,57 @@ blockToLaTeX (BlockQuote lst) = do return $ "\\begin{quote}" $$ contents $$ "\\end{quote}" blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do opts <- gets stOptions + ref <- toLabel identifier + let linkAnchor = if null identifier + then empty + else "\\hyperdef{}" <> braces (text ref) <> + braces ("\\label" <> braces (text ref)) + let lhsCodeBlock = do + modify $ \s -> s{ stLHS = True } + return $ flush (linkAnchor $$ "\\begin{code}" $$ text str $$ + "\\end{code}") $$ cr + let rawCodeBlock = do + st <- get + env <- if stInNote st + then modify (\s -> s{ stVerbInNote = True }) >> + return "Verbatim" + else return "verbatim" + return $ flush (linkAnchor $$ text ("\\begin{" ++ env ++ "}") $$ + text str $$ text ("\\end{" ++ env ++ "}")) <> cr + let listingsCodeBlock = do + st <- get + let params = if writerListings (stOptions st) + then (case getListingsLanguage classes of + Just l -> [ "language=" ++ l ] + Nothing -> []) ++ + [ "numbers=left" | "numberLines" `elem` classes + || "number" `elem` classes + || "number-lines" `elem` classes ] ++ + [ (if key == "startFrom" + then "firstnumber" + else key) ++ "=" ++ attr | + (key,attr) <- keyvalAttr ] ++ + (if identifier == "" + then [] + else [ "label=" ++ ref ]) + + else [] + printParams + | null params = empty + | otherwise = brackets $ hcat (intersperse ", " (map text params)) + return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$ + "\\end{lstlisting}") $$ cr + let highlightedCodeBlock = + case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of + Nothing -> rawCodeBlock + Just h -> modify (\st -> st{ stHighlighting = True }) >> + return (flush $ linkAnchor $$ text h) case () of _ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes && "literate" `elem` classes -> lhsCodeBlock | writerListings opts -> listingsCodeBlock | writerHighlight opts && not (null classes) -> highlightedCodeBlock | otherwise -> rawCodeBlock - where ref = text $ toLabel identifier - linkAnchor = if null identifier - then empty - else "\\hyperdef{}" <> braces ref <> - braces ("\\label" <> braces ref) - lhsCodeBlock = do - modify $ \s -> s{ stLHS = True } - return $ flush (linkAnchor $$ "\\begin{code}" $$ text str $$ - "\\end{code}") $$ cr - rawCodeBlock = do - st <- get - env <- if stInNote st - then modify (\s -> s{ stVerbInNote = True }) >> - return "Verbatim" - else return "verbatim" - return $ flush (linkAnchor $$ text ("\\begin{" ++ env ++ "}") $$ - text str $$ text ("\\end{" ++ env ++ "}")) <> cr - listingsCodeBlock = do - st <- get - let params = if writerListings (stOptions st) - then (case getListingsLanguage classes of - Just l -> [ "language=" ++ l ] - Nothing -> []) ++ - [ "numbers=left" | "numberLines" `elem` classes - || "number" `elem` classes - || "number-lines" `elem` classes ] ++ - [ (if key == "startFrom" - then "firstnumber" - else key) ++ "=" ++ attr | - (key,attr) <- keyvalAttr ] ++ - (if identifier == "" - then [] - else [ "label=" ++ toLabel identifier ]) - - else [] - printParams - | null params = empty - | otherwise = brackets $ hcat (intersperse ", " (map text params)) - return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$ - "\\end{lstlisting}") $$ cr - highlightedCodeBlock = - case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of - Nothing -> rawCodeBlock - Just h -> modify (\st -> st{ stHighlighting = True }) >> - return (flush $ linkAnchor $$ text h) blockToLaTeX (RawBlock f x) | f == Format "latex" || f == Format "tex" = return $ text x @@ -579,6 +581,7 @@ sectionHeader :: Bool -- True for unnumbered -> State WriterState Doc sectionHeader unnumbered ref level lst = do txt <- inlineListToLaTeX lst + lab <- text `fmap` toLabel ref let noNote (Note _) = Str "" noNote x = x let lstNoNotes = walk noNote lst @@ -599,13 +602,13 @@ sectionHeader unnumbered ref level lst = do let refLabel x = (if ref `elem` internalLinks then text "\\hyperdef" <> braces empty - <> braces (text $ toLabel ref) + <> braces lab <> braces x else x) - let headerWith x y r = refLabel $ text x <> y <> - if null r + let headerWith x y = refLabel $ text x <> y <> + if null ref then empty - else text "\\label" <> braces (text $ toLabel r) + else text "\\label" <> braces lab let sectionType = case level' of 0 | writerBeamer opts -> "part" | otherwise -> "chapter" @@ -624,7 +627,7 @@ sectionHeader unnumbered ref level lst = do return $ if level' > 5 then txt else prefix $$ - headerWith ('\\':sectionType) stuffing ref + headerWith ('\\':sectionType) stuffing $$ if unnumbered then "\\addcontentsline{toc}" <> braces (text sectionType) <> @@ -659,9 +662,10 @@ inlineToLaTeX (Span (id',classes,_) ils) = do let noEmph = "csl-no-emph" `elem` classes let noStrong = "csl-no-strong" `elem` classes let noSmallCaps = "csl-no-smallcaps" `elem` classes - let label' = if (null id') - then empty - else text "\\label" <> braces (text $ toLabel id') + label' <- if null id' + then return empty + else toLabel id' >>= \x -> + return (text "\\label" <> braces (text x)) fmap (label' <>) ((if noEmph then inCmd "textup" else id) . (if noStrong then inCmd "textnormal" else id) . @@ -745,9 +749,8 @@ inlineToLaTeX (LineBreak) = return "\\\\" inlineToLaTeX Space = return space inlineToLaTeX (Link txt ('#':ident, _)) = do contents <- inlineListToLaTeX txt - ident' <- stringToLaTeX URLString ident - return $ text "\\hyperref" <> brackets (text $ toLabel ident') <> - braces contents + lab <- toLabel ident + return $ text "\\hyperref" <> brackets (text lab) <> braces contents inlineToLaTeX (Link txt (src, _)) = case txt of [Str x] | x == src -> -- autolink -- cgit v1.2.3 From 8fdbef841d0ef77dcc2e30cfa475e92a0f3de6cf Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 8 May 2014 21:50:20 +0200 Subject: Update copyright notices for 2014, add missing notices --- COPYRIGHT | 10 +++++----- Setup.hs | 17 +++++++++++++++++ benchmark/benchmark-pandoc.hs | 18 +++++++++++++++++- pandoc.cabal | 2 +- pandoc.hs | 6 +++--- src/Text/Pandoc.hs | 4 ++-- src/Text/Pandoc/Asciify.hs | 4 ++-- src/Text/Pandoc/Highlighting.hs | 4 ++-- src/Text/Pandoc/ImageSize.hs | 4 ++-- src/Text/Pandoc/MIME.hs | 4 ++-- src/Text/Pandoc/Options.hs | 4 ++-- src/Text/Pandoc/PDF.hs | 4 ++-- src/Text/Pandoc/Parsing.hs | 4 ++-- src/Text/Pandoc/Pretty.hs | 4 ++-- src/Text/Pandoc/Process.hs | 4 ++-- src/Text/Pandoc/Readers/HTML.hs | 4 ++-- src/Text/Pandoc/Readers/LaTeX.hs | 4 ++-- src/Text/Pandoc/Readers/Markdown.hs | 4 ++-- src/Text/Pandoc/Readers/MediaWiki.hs | 4 ++-- src/Text/Pandoc/Readers/Native.hs | 4 ++-- src/Text/Pandoc/Readers/RST.hs | 4 ++-- src/Text/Pandoc/Readers/TeXMath.hs | 4 ++-- src/Text/Pandoc/Readers/Textile.hs | 5 +++-- src/Text/Pandoc/SelfContained.hs | 4 ++-- src/Text/Pandoc/Shared.hs | 4 ++-- src/Text/Pandoc/Slides.hs | 4 ++-- src/Text/Pandoc/Templates.hs | 4 ++-- src/Text/Pandoc/UTF8.hs | 4 ++-- src/Text/Pandoc/UUID.hs | 4 ++-- src/Text/Pandoc/Writers/AsciiDoc.hs | 4 ++-- src/Text/Pandoc/Writers/ConTeXt.hs | 4 ++-- src/Text/Pandoc/Writers/Custom.hs | 4 ++-- src/Text/Pandoc/Writers/Docbook.hs | 4 ++-- src/Text/Pandoc/Writers/Docx.hs | 4 ++-- src/Text/Pandoc/Writers/EPUB.hs | 4 ++-- src/Text/Pandoc/Writers/HTML.hs | 4 ++-- src/Text/Pandoc/Writers/LaTeX.hs | 4 ++-- src/Text/Pandoc/Writers/Man.hs | 4 ++-- src/Text/Pandoc/Writers/Markdown.hs | 4 ++-- src/Text/Pandoc/Writers/MediaWiki.hs | 4 ++-- src/Text/Pandoc/Writers/Native.hs | 4 ++-- src/Text/Pandoc/Writers/ODT.hs | 4 ++-- src/Text/Pandoc/Writers/OPML.hs | 4 ++-- src/Text/Pandoc/Writers/OpenDocument.hs | 6 +++--- src/Text/Pandoc/Writers/Org.hs | 5 +++-- src/Text/Pandoc/Writers/RST.hs | 4 ++-- src/Text/Pandoc/Writers/RTF.hs | 4 ++-- src/Text/Pandoc/Writers/Shared.hs | 4 ++-- src/Text/Pandoc/Writers/Texinfo.hs | 4 ++-- src/Text/Pandoc/Writers/Textile.hs | 4 ++-- src/Text/Pandoc/XML.hs | 4 ++-- 51 files changed, 138 insertions(+), 103 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/COPYRIGHT b/COPYRIGHT index cd5adb1be..065090018 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,5 +1,5 @@ Pandoc -Copyright (C) 2006-2013 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane This code is released under the [GPL], version 2 or later: @@ -33,25 +33,25 @@ licenses. ---------------------------------------------------------------------- src/Text/Pandoc/Writers/Texinfo.hs -Copyright (C) 2008-2010 John MacFarlane and Peter Wang +Copyright (C) 2008-2014 John MacFarlane and Peter Wang Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Writers/OpenDocument.hs -Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane +Copyright (C) 2008-2014 Andrea Rossato and John MacFarlane Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Writers/Org.hs -Copyright (C) 2010 Puneeth Chaganti +Copyright (C) 2010-2014 Puneeth Chaganti and JohnMacFarlane Released under the GNU General Public License version 2 or later. ---------------------------------------------------------------------- src/Text/Pandoc/Readers/Textile.hs -Copyright (C) 2010 Paul Rivier +Copyright (C) 2010-2014 Paul Rivier and John MacFarlane Released under the GNU General Public License version 2 or later. diff --git a/Setup.hs b/Setup.hs index 89d03ee7a..f5d18eee4 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,4 +1,21 @@ {-# LANGUAGE CPP #-} +{- +Copyright (C) 2006-2014 John MacFarlane + +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 +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-} import Distribution.Simple import Distribution.Simple.PreProcess diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs index 2eaaf91a1..9238b09d7 100644 --- a/benchmark/benchmark-pandoc.hs +++ b/benchmark/benchmark-pandoc.hs @@ -1,3 +1,20 @@ +{- +Copyright (C) 2012-2014 John MacFarlane + +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 +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-} import Text.Pandoc import Criterion.Main import Criterion.Config @@ -36,4 +53,3 @@ main = do let writers' = [(n,w) | (n, PureStringWriter w) <- writers] defaultMainWith conf (return ()) $ map (writerBench doc) writers' ++ readerBs - diff --git a/pandoc.cabal b/pandoc.cabal index ea0aa71ba..63c748a47 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -4,7 +4,7 @@ Cabal-Version: >= 1.10 Build-Type: Custom License: GPL License-File: COPYING -Copyright: (c) 2006-2013 John MacFarlane +Copyright: (c) 2006-2014 John MacFarlane Author: John MacFarlane Maintainer: John MacFarlane Bug-Reports: https://github.com/jgm/pandoc/issues diff --git a/pandoc.hs b/pandoc.hs index 959605625..5dd0e6899 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -1,6 +1,6 @@ {-# LANGUAGE CPP #-} {- -Copyright (C) 2006-2013 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Main - Copyright : Copyright (C) 2006-2013 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane @@ -69,7 +69,7 @@ import qualified Data.Yaml as Yaml import qualified Data.Text as T copyrightMessage :: String -copyrightMessage = "\nCopyright (C) 2006-2013 John MacFarlane\n" ++ +copyrightMessage = "\nCopyright (C) 2006-2014 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." diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index a37c98814..dd5bc18f6 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -1,6 +1,6 @@ {-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Asciify.hs b/src/Text/Pandoc/Asciify.hs index 1c177da90..8a5ccec5c 100644 --- a/src/Text/Pandoc/Asciify.hs +++ b/src/Text/Pandoc/Asciify.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2013 John MacFarlane +Copyright (C) 2013-2014 John MacFarlane 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 : Text.Pandoc.SelfContained - Copyright : Copyright (C) 2013 John MacFarlane + Copyright : Copyright (C) 2013-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs index 11d608db6..2e7a9f648 100644 --- a/src/Text/Pandoc/Highlighting.hs +++ b/src/Text/Pandoc/Highlighting.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2008 John MacFarlane +Copyright (C) 2008-2014 John MacFarlane 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 : Text.Pandoc.Highlighting - Copyright : Copyright (C) 2008 John MacFarlane + Copyright : Copyright (C) 2008-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs index 3c9623b3c..a6d076fa9 100644 --- a/src/Text/Pandoc/ImageSize.hs +++ b/src/Text/Pandoc/ImageSize.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} {- - Copyright (C) 2011 John MacFarlane + Copyright (C) 2011-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ {- | Module : Text.Pandoc.ImageSize -Copyright : Copyright (C) 2011 John MacFarlane +Copyright : Copyright (C) 2011-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs index 977cb576b..6e6284b25 100644 --- a/src/Text/Pandoc/MIME.hs +++ b/src/Text/Pandoc/MIME.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2011 John MacFarlane +Copyright (C) 2011-2014 John MacFarlane 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 : Text.Pandoc.MIME - Copyright : Copyright (C) 2011 John MacFarlane + Copyright : Copyright (C) 2011-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 38220f542..611a6bb06 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2012 John MacFarlane +Copyright (C) 2012-2014 John MacFarlane 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 : Text.Pandoc.Options - Copyright : Copyright (C) 2012 John MacFarlane + Copyright : Copyright (C) 2012-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index abc5c41b7..e4e06e6c9 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings, CPP #-} {- -Copyright (C) 2012 John MacFarlane +Copyright (C) 2012-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.PDF - Copyright : Copyright (C) 2012 John MacFarlane + Copyright : Copyright (C) 2012-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 4d0a677da..d1e55cbc4 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -1,7 +1,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving, TypeSynonymInstances, FlexibleInstances#-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Parsing - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index 5331587ce..d25ba725f 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -1,6 +1,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving, CPP #-} {- -Copyright (C) 2010 John MacFarlane +Copyright (C) 2010-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111(-1)307 USA {- | Module : Text.Pandoc.Pretty - Copyright : Copyright (C) 2010 John MacFarlane + Copyright : Copyright (C) 2010-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Process.hs b/src/Text/Pandoc/Process.hs index 112c5b974..9c8853366 100644 --- a/src/Text/Pandoc/Process.hs +++ b/src/Text/Pandoc/Process.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2013 John MacFarlane +Copyright (C) 2013-2014 John MacFarlane 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 : Text.Pandoc.Process - Copyright : Copyright (C) 2013 John MacFarlane + Copyright : Copyright (C) 2013-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index c94ee3d6b..905e55b22 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 : Text.Pandoc.Readers.HTML - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 79c66b510..bfafea1f6 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1,6 +1,6 @@ {-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-} {- -Copyright (C) 2006-2012 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Readers.LaTeX - Copyright : Copyright (C) 2006-2012 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index aac87f363..d1637b701 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RelaxedPolyRec #-} -- needed for inlinesBetween on GHC < 7 {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Readers.Markdown - Copyright : Copyright (C) 2006-2013 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs index feaedb7c2..e4fabc898 100644 --- a/src/Text/Pandoc/Readers/MediaWiki.hs +++ b/src/Text/Pandoc/Readers/MediaWiki.hs @@ -1,7 +1,7 @@ {-# LANGUAGE RelaxedPolyRec, FlexibleInstances, TypeSynonymInstances #-} -- RelaxedPolyRec needed for inlinesBetween on GHC < 7 {- - Copyright (C) 2012 John MacFarlane + Copyright (C) 2012-2014 John MacFarlane 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 @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Readers.MediaWiki - Copyright : Copyright (C) 2012 John MacFarlane + Copyright : Copyright (C) 2012-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs index c5d4cb98a..f4dfa62c1 100644 --- a/src/Text/Pandoc/Readers/Native.hs +++ b/src/Text/Pandoc/Readers/Native.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2011 John MacFarlane +Copyright (C) 2011-2014 John MacFarlane 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 : Text.Pandoc.Readers.Native - Copyright : Copyright (C) 2011 John MacFarlane + Copyright : Copyright (C) 2011-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 54b6fa34a..fa8438e70 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Readers.RST - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/TeXMath.hs b/src/Text/Pandoc/Readers/TeXMath.hs index 6bd617f7e..f03eae044 100644 --- a/src/Text/Pandoc/Readers/TeXMath.hs +++ b/src/Text/Pandoc/Readers/TeXMath.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2007-2010 John MacFarlane +Copyright (C) 2007-2014 John MacFarlane 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 : Text.Pandoc.Readers.TeXMath - Copyright : Copyright (C) 2007-2010 John MacFarlane + Copyright : Copyright (C) 2007-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 9ee34caa5..6d839ec1d 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -1,5 +1,6 @@ {- -Copyright (C) 2010 Paul Rivier | tr '*#' '.@' +Copyright (C) 2010-2014 Paul Rivier | tr '*#' '.@' + and John MacFarlane 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 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Readers.Textile - Copyright : Copyright (C) 2010-2012 Paul Rivier and John MacFarlane + Copyright : Copyright (C) 2010-2014 Paul Rivier and John MacFarlane License : GNU GPL, version 2 or above Maintainer : Paul Rivier diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 7fc9c2966..2a2f56281 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2011 John MacFarlane +Copyright (C) 2011-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.SelfContained - Copyright : Copyright (C) 2011 John MacFarlane + Copyright : Copyright (C) 2011-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 6f0629ea2..31c490af6 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DeriveDataTypeable, CPP, MultiParamTypeClasses, FlexibleContexts, ScopedTypeVariables #-} {- -Copyright (C) 2006-2013 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Shared - Copyright : Copyright (C) 2006-2013 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs index 50c46d17f..2b863c780 100644 --- a/src/Text/Pandoc/Slides.hs +++ b/src/Text/Pandoc/Slides.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2012 John MacFarlane +Copyright (C) 2012-2014 John MacFarlane 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 : Text.Pandoc.Slides - Copyright : Copyright (C) 2012 John MacFarlane + Copyright : Copyright (C) 2012-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index 52625abf6..551db6483 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -1,7 +1,7 @@ {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, CPP, OverloadedStrings, GeneralizedNewtypeDeriving #-} {- -Copyright (C) 2009-2013 John MacFarlane +Copyright (C) 2009-2014 John MacFarlane 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 @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Templates - Copyright : Copyright (C) 2009-2013 John MacFarlane + Copyright : Copyright (C) 2009-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs index 229442543..33c9ec1c5 100644 --- a/src/Text/Pandoc/UTF8.hs +++ b/src/Text/Pandoc/UTF8.hs @@ -1,6 +1,6 @@ {-# LANGUAGE CPP #-} {- -Copyright (C) 2010 John MacFarlane +Copyright (C) 2010-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.UTF8 - Copyright : Copyright (C) 2010 John MacFarlane + Copyright : Copyright (C) 2010-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs index 082644eea..eebfe09d2 100644 --- a/src/Text/Pandoc/UUID.hs +++ b/src/Text/Pandoc/UUID.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2010 John MacFarlane +Copyright (C) 2010-2014 John MacFarlane 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 : Text.Pandoc.UUID - Copyright : Copyright (C) 2010 John MacFarlane + Copyright : Copyright (C) 2010-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 15579cba2..19112d8f5 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.AsciiDoc - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index cec420dcf..3b321cc19 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2007-2010 John MacFarlane +Copyright (C) 2007-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.ConTeXt - Copyright : Copyright (C) 2007-2010 John MacFarlane + Copyright : Copyright (C) 2007-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs index 0b30287f5..88f590c43 100644 --- a/src/Text/Pandoc/Writers/Custom.hs +++ b/src/Text/Pandoc/Writers/Custom.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverlappingInstances, FlexibleInstances, OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -{- Copyright (C) 2012 John MacFarlane +{- Copyright (C) 2012-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Custom - Copyright : Copyright (C) 2012 John MacFarlane + Copyright : Copyright (C) 2012-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 1a8e58354..ba6a92a08 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Docbook - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index fcb73a427..551d97855 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -1,6 +1,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {- -Copyright (C) 2012 John MacFarlane +Copyright (C) 2012-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Docx - Copyright : Copyright (C) 2012 John MacFarlane + Copyright : Copyright (C) 2012-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index c39a7798d..893ec3be9 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -1,6 +1,6 @@ {-# LANGUAGE PatternGuards, CPP, ScopedTypeVariables #-} {- -Copyright (C) 2010 John MacFarlane +Copyright (C) 2010-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.EPUB - Copyright : Copyright (C) 2010 John MacFarlane + Copyright : Copyright (C) 2010-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 1de4345f9..9a26cf2ac 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings, CPP #-} {-# OPTIONS_GHC -fno-warn-deprecations #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.HTML - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index c17e041b5..c221b318e 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.LaTeX - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index 680bfef44..41eb3e5be 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2007-2010 John MacFarlane +Copyright (C) 2007-2014 John MacFarlane 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 : Text.Pandoc.Writers.Man - Copyright : Copyright (C) 2007-2010 John MacFarlane + Copyright : Copyright (C) 2007-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 95082add6..f42a1b54c 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-} {- -Copyright (C) 2006-2013 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Markdown - Copyright : Copyright (C) 2006-2013 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index 83fefaa29..3b987ba2b 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2008-2010 John MacFarlane +Copyright (C) 2008-2014 John MacFarlane 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 : Text.Pandoc.Writers.MediaWiki - Copyright : Copyright (C) 2008-2010 John MacFarlane + Copyright : Copyright (C) 2008-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs index 090b97433..cb821e40b 100644 --- a/src/Text/Pandoc/Writers/Native.hs +++ b/src/Text/Pandoc/Writers/Native.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Native - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index c3652d65d..15f7c8be8 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -1,6 +1,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {- -Copyright (C) 2008-2010 John MacFarlane +Copyright (C) 2008-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.ODT - Copyright : Copyright (C) 2008-2010 John MacFarlane + Copyright : Copyright (C) 2008-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/OPML.hs b/src/Text/Pandoc/Writers/OPML.hs index f6926c1dc..dd359f3f5 100644 --- a/src/Text/Pandoc/Writers/OPML.hs +++ b/src/Text/Pandoc/Writers/OPML.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2013 John MacFarlane +Copyright (C) 2013-2014 John MacFarlane 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 : Text.Pandoc.Writers.OPML - Copyright : Copyright (C) 2013 John MacFarlane + Copyright : Copyright (C) 2013-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 0029c3296..b6da2694c 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -1,7 +1,7 @@ {-# LANGUAGE PatternGuards, OverloadedStrings #-} {- -Copyright (C) 2008-2010 Andrea Rossato -and John MacFarlane. +Copyright (C) 2008-2014 Andrea Rossato + and John MacFarlane. 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 @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.OpenDocument - Copyright : Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane + Copyright : Copyright (C) 2008-2014 Andrea Rossato and John MacFarlane License : GNU GPL, version 2 or above Maintainer : Andrea Rossato diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index 58a5729e7..87046537c 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -1,6 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2006-2010 Puneeth Chaganti +Copyright (C) 2010-2014 Puneeth Chaganti + and John MacFarlane 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 @@ -19,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Org - Copyright : Copyright (C) 2010 Puneeth Chaganti + Copyright : Copyright (C) 2010-2014 Puneeth Chaganti and John MacFarlane License : GNU GPL, version 2 or above Maintainer : Puneeth Chaganti diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 1e7596b21..31c97349b 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.RST - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 3e0bd9976..e0428aaa8 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 : Text.Pandoc.Writers.RTF - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 604aac1c9..800e741a4 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2013 John MacFarlane +Copyright (C) 2013-2014 John MacFarlane 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Shared - Copyright : Copyright (C) 2013 John MacFarlane + Copyright : Copyright (C) 2013-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs index bf3df8035..8ac717bab 100644 --- a/src/Text/Pandoc/Writers/Texinfo.hs +++ b/src/Text/Pandoc/Writers/Texinfo.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {- -Copyright (C) 2008-2010 John MacFarlane and Peter Wang +Copyright (C) 2008-2014 John MacFarlane and Peter Wang 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 @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA {- | Module : Text.Pandoc.Writers.Texinfo - Copyright : Copyright (C) 2008-2010 John MacFarlane and Peter Wang + Copyright : Copyright (C) 2008-2014 John MacFarlane and Peter Wang License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index 95aedf780..3a6982a01 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2010 John MacFarlane +Copyright (C) 2010-2014 John MacFarlane 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 : Text.Pandoc.Writers.Textile - Copyright : Copyright (C) 2010 John MacFarlane + Copyright : Copyright (C) 2010-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs index c11af9a19..8000368aa 100644 --- a/src/Text/Pandoc/XML.hs +++ b/src/Text/Pandoc/XML.hs @@ -1,5 +1,5 @@ {- -Copyright (C) 2006-2010 John MacFarlane +Copyright (C) 2006-2014 John MacFarlane 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 : Text.Pandoc.XML - Copyright : Copyright (C) 2006-2010 John MacFarlane + Copyright : Copyright (C) 2006-2014 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane -- cgit v1.2.3 From c5c9b0d2890699ee8fcdbb660662957f8efad319 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 15 May 2014 10:11:48 -0700 Subject: EPUB writer: Fixed regression on cover image. In 1.12.4 and 1.12.4.2, the cover image would not appear properly, because the metadata id was not correct. This was introduced by the fix to #1254. Now we derive the id from the actual cover image filename, which we preserve rather than using "cover-image." --- src/Text/Pandoc/Writers/EPUB.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 893ec3be9..4d2a39846 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -333,7 +333,7 @@ writeEPUB opts doc@(Pandoc meta _) = do case epubCoverImage metadata of Nothing -> return ([],[]) Just img -> do - let coverImage = "cover-image" ++ takeExtension img + let coverImage = "media/" ++ takeFileName img let cpContent = renderHtml $ writeHtml opts' (Pandoc meta [RawBlock (Format "html") $ "
\n\"cover\n
"]) imgContent <- B.readFile img @@ -561,8 +561,8 @@ writeEPUB opts doc@(Pandoc meta _) = do ,("content", "0")] $ () ] ++ case epubCoverImage metadata of Nothing -> [] - Just _ -> [unode "meta" ! [("name","cover"), - ("content","cover-image")] $ ()] + Just img -> [unode "meta" ! [("name","cover"), + ("content", toId img)] $ ()] , unode "docTitle" $ unode "text" $ plainTitle , unode "navMap" $ tpNode : evalState (mapM (navPointNode navMapFormatter) secs) 1 @@ -657,8 +657,8 @@ metadataElement version md currentTime = coverageNodes = maybe [] (dcTag' "coverage") $ epubCoverage md rightsNodes = maybe [] (dcTag' "rights") $ epubRights md coverImageNodes = maybe [] - (const $ [unode "meta" ! [("name","cover"), - ("content","cover-image")] $ ()]) + (\img -> [unode "meta" ! [("name","cover"), + ("content",toId img)] $ ()]) $ epubCoverImage md modifiedNodes = [ unode "meta" ! [("property", "dcterms:modified")] $ (showDateTimeISO8601 currentTime) | version == EPUB3 ] -- cgit v1.2.3 From 8d04c821aaa8a96803126140b58b8aef02d85906 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 19 May 2014 09:45:00 -0700 Subject: Avoid `import Prelude hiding (catch)`. See #1309. --- src/Text/Pandoc/UTF8.hs | 3 +-- src/Text/Pandoc/Writers/EPUB.hs | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs index 33c9ec1c5..cf25de85b 100644 --- a/src/Text/Pandoc/UTF8.hs +++ b/src/Text/Pandoc/UTF8.hs @@ -51,8 +51,7 @@ import System.IO hiding (readFile, writeFile, getContents, #if MIN_VERSION_base(4,6,0) import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn) #else -import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn, - catch) +import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn) #endif import qualified System.IO as IO import qualified Data.ByteString.Char8 as B diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 4d2a39846..9514e87c9 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -59,11 +59,7 @@ import Text.Pandoc.Writers.Markdown ( writePlain ) import Data.Char ( toLower, isDigit, isAlphaNum ) import Network.URI ( unEscapeString ) import Text.Pandoc.MIME (getMimeType) -#if MIN_VERSION_base(4,6,0) -#else -import Prelude hiding (catch) -#endif -import Control.Exception (catch, SomeException) +import qualified Control.Exception as E import Text.Blaze.Html.Renderer.Utf8 (renderHtml) import Text.HTML.TagSoup @@ -153,10 +149,10 @@ getEPUBMetadata opts meta = do then case lookup "lang" (writerVariables opts) of Just x -> return m{ epubLanguage = x } Nothing -> do - localeLang <- catch (liftM + localeLang <- E.catch (liftM (map (\c -> if c == '_' then '-' else c) . takeWhile (/='.')) $ getEnv "LANG") - (\e -> let _ = (e :: SomeException) in return "en-US") + (\e -> let _ = (e :: E.SomeException) in return "en-US") return m{ epubLanguage = localeLang } else return m let fixDate m = -- cgit v1.2.3 From 3c77ab98bf9a055237a69be48001f5c6ef1d64ca Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 19 May 2014 12:52:25 -0700 Subject: EPUB writer: Handle multiple dates with OPF `event` attributes. Note: in EPUB3 we can have only one dc:date, so only the first one is used. --- src/Text/Pandoc/Writers/EPUB.hs | 47 +++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 9514e87c9..b6687c330 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -72,7 +72,7 @@ data Chapter = Chapter (Maybe [Int]) [Block] data EPUBMetadata = EPUBMetadata{ epubIdentifier :: [Identifier] , epubTitle :: [Title] - , epubDate :: String + , epubDate :: [Date] , epubLanguage :: String , epubCreator :: [Creator] , epubContributor :: [Creator] @@ -93,6 +93,11 @@ data Stylesheet = StylesheetPath FilePath | StylesheetContents String deriving Show +data Date = Date{ + dateText :: String + , dateEvent :: Maybe String + } deriving Show + data Creator = Creator{ creatorText :: String , creatorRole :: Maybe String @@ -159,7 +164,9 @@ getEPUBMetadata opts meta = do if null (epubDate m) then do currentTime <- getCurrentTime - return $ m{ epubDate = showDateTimeISO8601 currentTime } + return $ m{ epubDate = [ Date{ + dateText = showDateTimeISO8601 currentTime + , dateEvent = Nothing } ] } else return m let addAuthor m = if any (\c -> creatorRole c == Just "aut") $ epubCreator m @@ -183,8 +190,10 @@ addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md , titleFileAs = getAttr "file-as" , titleType = getAttr "type" } : epubTitle md } - | name == "date" = md{ epubDate = fromMaybe "" $ normalizeDate' - $ strContent e } + | name == "date" = md{ epubDate = + Date{ dateText = fromMaybe "" $ normalizeDate' $ strContent e + , dateEvent = getAttr "event" + } : epubDate md } | name == "language" = md{ epubLanguage = strContent e } | name == "creator" = md{ epubCreator = Creator{ creatorText = strContent e @@ -249,6 +258,16 @@ getCreator s meta = getList s meta handleMetaValue , creatorRole = metaValueToString <$> M.lookup "role" m } handleMetaValue mv = Creator (metaValueToString mv) Nothing Nothing +getDate :: String -> Meta -> [Date] +getDate s meta = getList s meta handleMetaValue + where handleMetaValue (MetaMap m) = + Date{ dateText = maybe "" id $ + M.lookup "text" m >>= normalizeDate' . metaValueToString + , dateEvent = metaValueToString <$> M.lookup "event" m } + handleMetaValue mv = Date { dateText = maybe "" + id $ normalizeDate' $ metaValueToString mv + , dateEvent = Nothing } + simpleList :: String -> Meta -> [String] simpleList s meta = case lookupMeta s meta of @@ -278,8 +297,7 @@ metadataFromMeta opts meta = EPUBMetadata{ } where identifiers = getIdentifier meta titles = getTitle meta - date = fromMaybe "" $ - (metaValueToString <$> lookupMeta "date" meta) >>= normalizeDate' + date = getDate "date" meta language = maybe "" metaValueToString $ lookupMeta "language" meta `mplus` lookupMeta "lang" meta creators = getCreator "creator" meta @@ -637,7 +655,14 @@ metadataElement version md currentTime = identifierNodes = withIds "epub-id" toIdentifierNode $ epubIdentifier md titleNodes = withIds "epub-title" toTitleNode $ epubTitle md - dateNodes = dcTag' "date" $ epubDate md + dateNodes = if version == EPUB2 + then withIds "epub-date" toDateNode $ epubDate md + else -- epub3 allows only one dc:date + -- http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-opf-dcdate + case epubDate md of + [] -> [] + (x:_) -> [dcNode "date" ! [("id","epub-date")] + $ dateText x] languageNodes = [dcTag "language" $ epubLanguage md] creatorNodes = withIds "epub-creator" (toCreatorNode "creator") $ epubCreator md @@ -671,7 +696,7 @@ metadataElement version md currentTime = (schemeToOnix `fmap` scheme) toCreatorNode s id' creator | version == EPUB2 = [dcNode s ! - ([("id",id')] ++ + (("id",id') : maybe [] (\x -> [("opf:file-as",x)]) (creatorFileAs creator) ++ maybe [] (\x -> [("opf:role",x)]) (creatorRole creator >>= toRelator)) $ creatorText creator] @@ -685,7 +710,7 @@ metadataElement version md currentTime = (creatorRole creator >>= toRelator) toTitleNode id' title | version == EPUB2 = [dcNode "title" ! - ([("id",id')] ++ + (("id",id') : maybe [] (\x -> [("opf:file-as",x)]) (titleFileAs title) ++ maybe [] (\x -> [("opf:title-type",x)]) (titleType title)) $ titleText title] @@ -697,6 +722,10 @@ metadataElement version md currentTime = maybe [] (\x -> [unode "meta" ! [("refines",'#':id'),("property","title-type")] $ x]) (titleType title) + toDateNode id' date = [dcNode "date" ! + (("id",id') : + maybe [] (\x -> [("opf:event",x)]) (dateEvent date)) $ + dateText date] schemeToOnix "ISBN-10" = "02" schemeToOnix "GTIN-13" = "03" schemeToOnix "UPC" = "04" -- cgit v1.2.3 From 23a9b800a35d3c17d29a278b6bb218f05642d282 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 31 May 2014 22:02:33 -0700 Subject: Docx writer: Take over document formatting from reference.docx. This includes margins, page size, page orientation. --- src/Text/Pandoc/Writers/Docx.hs | 47 ++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 551d97855..6fd76c9c7 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -204,11 +204,35 @@ writeDocx opts doc@(Pandoc meta _) = do let toImageEntry (_,path,_,_,img) = toEntry ("word/" ++ path) epochtime $ toLazy img let imageEntries = map toImageEntry imgs + -- adjust contents to add sectPr from reference.docx + let docpath = "word/document.xml" + parsedDoc <- parseXml refArchive distArchive docpath + let sectprs = filterElementsName (\qn -> qPrefix qn == Just "w" && + qName qn == "sectPr") + parsedDoc + + let stdAttributes = + [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main") + ,("xmlns:m","http://schemas.openxmlformats.org/officeDocument/2006/math") + ,("xmlns:r","http://schemas.openxmlformats.org/officeDocument/2006/relationships") + ,("xmlns:o","urn:schemas-microsoft-com:office:office") + ,("xmlns:v","urn:schemas-microsoft-com:vml") + ,("xmlns:w10","urn:schemas-microsoft-com:office:word") + ,("xmlns:a","http://schemas.openxmlformats.org/drawingml/2006/main") + ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture") + ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")] + + let contents' = contents ++ sectprs + let docContents = mknode "w:document" stdAttributes + $ mknode "w:body" [] $ contents' + -- word/document.xml - let contentEntry = toEntry "word/document.xml" epochtime $ renderXml contents + let contentEntry = toEntry "word/document.xml" epochtime + $ renderXml docContents -- footnotes - let footnotesEntry = toEntry "word/footnotes.xml" epochtime $ renderXml footnotes + let notes = mknode "w:footnotes" stdAttributes footnotes + let footnotesEntry = toEntry "word/footnotes.xml" epochtime $ renderXml notes -- footnote rels let footnoteRelEntry = toEntry "word/_rels/footnotes.xml.rels" epochtime @@ -392,8 +416,9 @@ mkLvl marker lvl = getNumId :: WS Int getNumId = length `fmap` gets stLists --- | Convert Pandoc document to two OpenXML elements (the main document and footnotes). -writeOpenXML :: WriterOptions -> Pandoc -> WS (Element, Element) +-- | Convert Pandoc document to two lists of +-- OpenXML elements (the main document and footnotes). +writeOpenXML :: WriterOptions -> Pandoc -> WS ([Element], [Element]) writeOpenXML opts (Pandoc meta blocks) = do let tit = docTitle meta ++ case lookupMeta "subtitle" meta of Just (MetaBlocks [Plain xs]) -> LineBreak : xs @@ -411,19 +436,7 @@ writeOpenXML opts (Pandoc meta blocks) = do doc' <- blocksToOpenXML opts blocks' notes' <- reverse `fmap` gets stFootnotes let meta' = title ++ authors ++ date - let stdAttributes = - [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main") - ,("xmlns:m","http://schemas.openxmlformats.org/officeDocument/2006/math") - ,("xmlns:r","http://schemas.openxmlformats.org/officeDocument/2006/relationships") - ,("xmlns:o","urn:schemas-microsoft-com:office:office") - ,("xmlns:v","urn:schemas-microsoft-com:vml") - ,("xmlns:w10","urn:schemas-microsoft-com:office:word") - ,("xmlns:a","http://schemas.openxmlformats.org/drawingml/2006/main") - ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture") - ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")] - let doc = mknode "w:document" stdAttributes $ mknode "w:body" [] (meta' ++ doc') - let notes = mknode "w:footnotes" stdAttributes notes' - return (doc, notes) + return (meta' ++ doc', notes') -- | Convert a list of Pandoc blocks to OpenXML. blocksToOpenXML :: WriterOptions -> [Block] -> WS [Element] -- cgit v1.2.3 From 6327ccf523bb5d550d85dd7782079b8f070fe5d1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 1 Jun 2014 15:29:27 -0700 Subject: Minor code reformat. --- src/Text/Pandoc/Writers/Docx.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 6fd76c9c7..026cfcb41 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -60,6 +60,11 @@ import qualified Control.Exception as E import Text.Pandoc.MIME (getMimeType, extensionFromMimeType) import Control.Applicative ((<|>)) +data ListMarker = NoMarker + | BulletMarker + | NumberMarker ListNumberStyle ListNumberDelim Int + deriving (Show, Read, Eq, Ord) + data WriterState = WriterState{ stTextProperties :: [Element] , stParaProperties :: [Element] @@ -73,11 +78,6 @@ data WriterState = WriterState{ , stLists :: [ListMarker] } -data ListMarker = NoMarker - | BulletMarker - | NumberMarker ListNumberStyle ListNumberDelim Int - deriving (Show, Read, Eq, Ord) - defaultWriterState :: WriterState defaultWriterState = WriterState{ stTextProperties = [] -- cgit v1.2.3 From 6848f642e82322c0894c62d3215e98325ab7fd8c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 1 Jun 2014 21:15:03 -0700 Subject: Docx writer: Header and footer are now carried over from reference.docx. --- data/reference.docx | Bin 9797 -> 9360 bytes src/Text/Pandoc/Writers/Docx.hs | 54 ++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/data/reference.docx b/data/reference.docx index a9c268b9f..789237dd8 100644 Binary files a/data/reference.docx and b/data/reference.docx differ diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 026cfcb41..584662be8 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -155,8 +155,11 @@ writeDocx opts doc@(Pandoc meta _) = do ,("/word/document.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml") ,("/word/footnotes.xml", - "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml") - ] ++ map mkImageOverride imgs + "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"), + ("/word/header1.xml", + "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"), + ("/word/footer1.xml", + "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml") ] ++ map mkImageOverride imgs let defaultnodes = [mknode "Default" [("Extension","xml"),("ContentType","application/xml")] (), mknode "Default" @@ -191,7 +194,14 @@ writeDocx opts doc@(Pandoc meta _) = do "theme/theme1.xml") ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", "rId7", - "footnotes.xml")] + "footnotes.xml") + ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", + "rId8", + "header1.xml") + ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", + "rId9", + "footer1.xml") + ] let toImgRel (ident,path,_,_,_) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"),("Id",ident),("Target",path)] () let imgrels = map toImgRel imgs let toLinkRel (src,ident) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"),("Id",ident),("Target",src),("TargetMode","External") ] () @@ -207,9 +217,16 @@ writeDocx opts doc@(Pandoc meta _) = do -- adjust contents to add sectPr from reference.docx let docpath = "word/document.xml" parsedDoc <- parseXml refArchive distArchive docpath - let sectprs = filterElementsName (\qn -> qPrefix qn == Just "w" && - qName qn == "sectPr") - parsedDoc + let mbsectpr = filterElementName (\qn -> qPrefix qn == Just "w" && + qName qn == "sectPr") parsedDoc + let sectPrProps = case mbsectpr of + Nothing -> [] + Just e -> filterElementsName (\qn -> + qPrefix qn == Just "w" && + qName qn `notElem` ["headerReference","footerReference","sectPr"]) e + let headerPr = mknode "w:headerReference" [("w:type","default"),("r:id","rId8")] $ () + let footerPr = mknode "w:footerReference" [("w:type","default"),("r:id","rId9")] $ () + let sectpr = mknode "w:sectPr" [] $ [headerPr, footerPr] ++ sectPrProps let stdAttributes = [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main") @@ -222,7 +239,7 @@ writeDocx opts doc@(Pandoc meta _) = do ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture") ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")] - let contents' = contents ++ sectprs + let contents' = contents ++ [sectpr] let docContents = mknode "w:document" stdAttributes $ mknode "w:body" [] $ contents' @@ -281,20 +298,25 @@ writeDocx opts doc@(Pandoc meta _) = do ] let relsEntry = toEntry relsPath epochtime $ renderXml rels - let entryFromArchive path = + let entryFromArchive arch path = (toEntry path epochtime . renderXml) `fmap` - parseXml refArchive distArchive path - docPropsAppEntry <- entryFromArchive "docProps/app.xml" - themeEntry <- entryFromArchive "word/theme/theme1.xml" - fontTableEntry <- entryFromArchive "word/fontTable.xml" - settingsEntry <- entryFromArchive "word/settings.xml" - webSettingsEntry <- entryFromArchive "word/webSettings.xml" + parseXml arch distArchive path + docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml" + themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml" + fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml" + -- we take settings.xml from dist archive because the ref archive + -- sometimes references special footnotes and endnotes that may + -- not be defined in footnotes.xml or endnotes.xml. + settingsEntry <- entryFromArchive distArchive "word/settings.xml" + webSettingsEntry <- entryFromArchive distArchive "word/webSettings.xml" + headerEntry <- entryFromArchive refArchive "word/header1.xml" + footerEntry <- entryFromArchive refArchive "word/footer1.xml" let miscRels = [ f | f <- filesInArchive refArchive , "word/_rels/" `isPrefixOf` f , ".xml.rels" `isSuffixOf` f , f /= "word/_rels/document.xml.rels" , f /= "word/_rels/footnotes.xml.rels" ] - miscRelEntries <- mapM entryFromArchive miscRels + miscRelEntries <- mapM (entryFromArchive refArchive) miscRels -- Create archive let archive = foldr addEntryToArchive emptyArchive $ @@ -302,7 +324,7 @@ writeDocx opts doc@(Pandoc meta _) = do footnoteRelEntry : numEntry : styleEntry : footnotesEntry : docPropsEntry : docPropsAppEntry : themeEntry : fontTableEntry : settingsEntry : webSettingsEntry : - imageEntries ++ miscRelEntries + headerEntry : footerEntry : imageEntries ++ miscRelEntries return $ fromArchive archive styleToOpenXml :: Style -> [Element] -- cgit v1.2.3 From 7242165bed21a63b49e1ce7d639400f095800204 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 1 Jun 2014 22:29:13 -0700 Subject: Docx writer: Improved handling of headers/footers. --- src/Text/Pandoc/Writers/Docx.hs | 105 ++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 52 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 584662be8..098da119b 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -59,6 +59,7 @@ import Text.Printf (printf) import qualified Control.Exception as E import Text.Pandoc.MIME (getMimeType, extensionFromMimeType) import Control.Applicative ((<|>)) +import Data.Maybe (mapMaybe) data ListMarker = NoMarker | BulletMarker @@ -123,6 +124,40 @@ writeDocx opts doc@(Pandoc meta _) = do epochtime <- floor `fmap` getPOSIXTime let imgs = M.elems $ stImages st + -- create entries for images in word/media/... + let toImageEntry (_,path,_,_,img) = toEntry ("word/" ++ path) epochtime $ toLazy img + let imageEntries = map toImageEntry imgs + + -- adjust contents to add sectPr from reference.docx + parsedDoc <- parseXml refArchive distArchive "word/document.xml" + let wname f qn = qPrefix qn == Just "w" && f (qName qn) + let mbsectpr = filterElementName (wname (=="sectPr")) parsedDoc + + let sectpr = maybe (mknode "w:sectPr" [] $ ()) id mbsectpr + + let stdAttributes = + [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main") + ,("xmlns:m","http://schemas.openxmlformats.org/officeDocument/2006/math") + ,("xmlns:r","http://schemas.openxmlformats.org/officeDocument/2006/relationships") + ,("xmlns:o","urn:schemas-microsoft-com:office:office") + ,("xmlns:v","urn:schemas-microsoft-com:vml") + ,("xmlns:w10","urn:schemas-microsoft-com:office:word") + ,("xmlns:a","http://schemas.openxmlformats.org/drawingml/2006/main") + ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture") + ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")] + + let contents' = contents ++ [sectpr] + let docContents = mknode "w:document" stdAttributes + $ mknode "w:body" [] $ contents' + + parsedRels <- parseXml refArchive distArchive "word/_rels/document.xml.rels" + let isHeaderNode e = findAttr (QName "Type" Nothing Nothing) e == Just "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" + let isFooterNode e = findAttr (QName "Type" Nothing Nothing) e == Just "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" + let headers = filterElements isHeaderNode parsedRels + let footers = filterElements isFooterNode parsedRels + + let extractTarget e = findAttr (QName "Target" Nothing Nothing) e + -- we create [Content_Types].xml and word/_rels/document.xml.rels -- from scratch rather than reading from reference.docx, -- because Word sometimes changes these files when a reference.docx is modified, @@ -135,7 +170,7 @@ writeDocx opts doc@(Pandoc meta _) = do let mkImageOverride (_, imgpath, mbMimeType, _, _) = mkOverrideNode ("/word/" ++ imgpath, fromMaybe "application/octet-stream" mbMimeType) - let overrides = map mkOverrideNode + let overrides = map mkOverrideNode ( [("/word/webSettings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml") ,("/word/numbering.xml", @@ -155,11 +190,13 @@ writeDocx opts doc@(Pandoc meta _) = do ,("/word/document.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml") ,("/word/footnotes.xml", - "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"), - ("/word/header1.xml", - "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"), - ("/word/footer1.xml", - "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml") ] ++ map mkImageOverride imgs + "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml") + ] ++ + map (\x -> (maybe "" ("/word/" ++) $ extractTarget x, + "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")) headers ++ + map (\x -> (maybe "" ("/word/" ++) $ extractTarget x, + "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++ + map mkImageOverride imgs let defaultnodes = [mknode "Default" [("Extension","xml"),("ContentType","application/xml")] (), mknode "Default" @@ -195,13 +232,8 @@ writeDocx opts doc@(Pandoc meta _) = do ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", "rId7", "footnotes.xml") - ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", - "rId8", - "header1.xml") - ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", - "rId9", - "footer1.xml") - ] + ] ++ + headers ++ footers let toImgRel (ident,path,_,_,_) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"),("Id",ident),("Target",path)] () let imgrels = map toImgRel imgs let toLinkRel (src,ident) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"),("Id",ident),("Target",src),("TargetMode","External") ] () @@ -210,38 +242,6 @@ writeDocx opts doc@(Pandoc meta _) = do let relEntry = toEntry "word/_rels/document.xml.rels" epochtime $ renderXml reldoc - -- create entries for images in word/media/... - let toImageEntry (_,path,_,_,img) = toEntry ("word/" ++ path) epochtime $ toLazy img - let imageEntries = map toImageEntry imgs - - -- adjust contents to add sectPr from reference.docx - let docpath = "word/document.xml" - parsedDoc <- parseXml refArchive distArchive docpath - let mbsectpr = filterElementName (\qn -> qPrefix qn == Just "w" && - qName qn == "sectPr") parsedDoc - let sectPrProps = case mbsectpr of - Nothing -> [] - Just e -> filterElementsName (\qn -> - qPrefix qn == Just "w" && - qName qn `notElem` ["headerReference","footerReference","sectPr"]) e - let headerPr = mknode "w:headerReference" [("w:type","default"),("r:id","rId8")] $ () - let footerPr = mknode "w:footerReference" [("w:type","default"),("r:id","rId9")] $ () - let sectpr = mknode "w:sectPr" [] $ [headerPr, footerPr] ++ sectPrProps - - let stdAttributes = - [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main") - ,("xmlns:m","http://schemas.openxmlformats.org/officeDocument/2006/math") - ,("xmlns:r","http://schemas.openxmlformats.org/officeDocument/2006/relationships") - ,("xmlns:o","urn:schemas-microsoft-com:office:office") - ,("xmlns:v","urn:schemas-microsoft-com:vml") - ,("xmlns:w10","urn:schemas-microsoft-com:office:word") - ,("xmlns:a","http://schemas.openxmlformats.org/drawingml/2006/main") - ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture") - ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")] - - let contents' = contents ++ [sectpr] - let docContents = mknode "w:document" stdAttributes - $ mknode "w:body" [] $ contents' -- word/document.xml let contentEntry = toEntry "word/document.xml" epochtime @@ -304,13 +304,13 @@ writeDocx opts doc@(Pandoc meta _) = do docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml" themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml" fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml" - -- we take settings.xml from dist archive because the ref archive - -- sometimes references special footnotes and endnotes that may - -- not be defined in footnotes.xml or endnotes.xml. + -- we use dist archive for settings.xml, because Word sometimes + -- adds references to footnotes or endnotes we don't have... settingsEntry <- entryFromArchive distArchive "word/settings.xml" - webSettingsEntry <- entryFromArchive distArchive "word/webSettings.xml" - headerEntry <- entryFromArchive refArchive "word/header1.xml" - footerEntry <- entryFromArchive refArchive "word/footer1.xml" + webSettingsEntry <- entryFromArchive refArchive "word/webSettings.xml" + headerFooterEntries <- mapM (entryFromArchive refArchive) $ + mapMaybe (\e -> fmap ("word/" ++) $ extractTarget e) + (headers ++ footers) let miscRels = [ f | f <- filesInArchive refArchive , "word/_rels/" `isPrefixOf` f , ".xml.rels" `isSuffixOf` f @@ -324,7 +324,8 @@ writeDocx opts doc@(Pandoc meta _) = do footnoteRelEntry : numEntry : styleEntry : footnotesEntry : docPropsEntry : docPropsAppEntry : themeEntry : fontTableEntry : settingsEntry : webSettingsEntry : - headerEntry : footerEntry : imageEntries ++ miscRelEntries + imageEntries ++ headerFooterEntries ++ + miscRelEntries return $ fromArchive archive styleToOpenXml :: Style -> [Element] -- cgit v1.2.3 From bf915da6cd0dc97a231100b784450e334c715969 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 2 Jun 2014 20:07:41 -0700 Subject: Docx writer: Make images work in reference.docx headers/footers. * All media from reference.docx are copied into result. * Added defaults for common image types to [Content Types]. * Avoided redundant XML parse + write for entries taken over from reference.docx, for better performance. --- src/Text/Pandoc/Writers/Docx.hs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 098da119b..8aaf3c1b8 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -197,10 +197,21 @@ writeDocx opts doc@(Pandoc meta _) = do map (\x -> (maybe "" ("/word/" ++) $ extractTarget x, "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++ map mkImageOverride imgs + let imageDefaults = map (\(x,y) -> mknode "Default" + [("Extension",x),("ContentType",y)] ()) + [("jpg","image/jpeg") + ,("jpeg","image/jpeg") + ,("png","image/png") + ,("svg","image/svg+xml") + ,("tif","image/tiff") + ,("tiff","image/tiff") + ,("bmp","image/x-ms-bmp") + ,("gif","image/gif") + ] let defaultnodes = [mknode "Default" [("Extension","xml"),("ContentType","application/xml")] (), mknode "Default" - [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()] + [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()] ++ imageDefaults let contentTypesDoc = mknode "Types" [("xmlns","http://schemas.openxmlformats.org/package/2006/content-types")] $ defaultnodes ++ overrides let contentTypesEntry = toEntry "[Content_Types].xml" epochtime $ renderXml contentTypesDoc @@ -311,12 +322,13 @@ writeDocx opts doc@(Pandoc meta _) = do headerFooterEntries <- mapM (entryFromArchive refArchive) $ mapMaybe (\e -> fmap ("word/" ++) $ extractTarget e) (headers ++ footers) - let miscRels = [ f | f <- filesInArchive refArchive - , "word/_rels/" `isPrefixOf` f - , ".xml.rels" `isSuffixOf` f - , f /= "word/_rels/document.xml.rels" - , f /= "word/_rels/footnotes.xml.rels" ] - miscRelEntries <- mapM (entryFromArchive refArchive) miscRels + let miscRelEntries = [ e | e <- zEntries refArchive + , "word/_rels/" `isPrefixOf` (eRelativePath e) + , ".xml.rels" `isSuffixOf` (eRelativePath e) + , eRelativePath e /= "word/_rels/document.xml.rels" + , eRelativePath e /= "word/_rels/footnotes.xml.rels" ] + let otherMediaEntries = [ e | e <- zEntries refArchive + , "word/media/" `isPrefixOf` eRelativePath e ] -- Create archive let archive = foldr addEntryToArchive emptyArchive $ @@ -325,7 +337,7 @@ writeDocx opts doc@(Pandoc meta _) = do docPropsEntry : docPropsAppEntry : themeEntry : fontTableEntry : settingsEntry : webSettingsEntry : imageEntries ++ headerFooterEntries ++ - miscRelEntries + miscRelEntries ++ otherMediaEntries return $ fromArchive archive styleToOpenXml :: Style -> [Element] -- cgit v1.2.3 From 326d7fa8f89f9a4b74042bf4cbb04931e26c8d8d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 2 Jun 2014 20:20:16 -0700 Subject: Docx writer: Improved entryFromArchive to avoid parse. No need to parse the XML if we're just going to render it right away! --- src/Text/Pandoc/Writers/Docx.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 8aaf3c1b8..1e37b5515 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -310,8 +310,9 @@ writeDocx opts doc@(Pandoc meta _) = do let relsEntry = toEntry relsPath epochtime $ renderXml rels let entryFromArchive arch path = - (toEntry path epochtime . renderXml) `fmap` - parseXml arch distArchive path + maybe (fail $ path ++ " corrupt or missing in reference docx") + return + (findEntryByPath path arch `mplus` findEntryByPath path distArchive) docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml" themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml" fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml" -- cgit v1.2.3 From cbfde5cb50a461995a8b60d148615b5a72159f3d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 2 Jun 2014 20:39:27 -0700 Subject: Docx writer: Create overrides per-image for media/ in ref docx. This should be somewhat more robust and cover more types of images. --- src/Text/Pandoc/Writers/Docx.hs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 1e37b5515..e630c5094 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -170,6 +170,9 @@ writeDocx opts doc@(Pandoc meta _) = do let mkImageOverride (_, imgpath, mbMimeType, _, _) = mkOverrideNode ("/word/" ++ imgpath, fromMaybe "application/octet-stream" mbMimeType) + let mkMediaOverride imgpath = mkOverrideNode ('/':imgpath, + fromMaybe "application/octet-stream" + $ getMimeType imgpath) let overrides = map mkOverrideNode ( [("/word/webSettings.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml") @@ -196,22 +199,14 @@ writeDocx opts doc@(Pandoc meta _) = do "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")) headers ++ map (\x -> (maybe "" ("/word/" ++) $ extractTarget x, "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++ - map mkImageOverride imgs - let imageDefaults = map (\(x,y) -> mknode "Default" - [("Extension",x),("ContentType",y)] ()) - [("jpg","image/jpeg") - ,("jpeg","image/jpeg") - ,("png","image/png") - ,("svg","image/svg+xml") - ,("tif","image/tiff") - ,("tiff","image/tiff") - ,("bmp","image/x-ms-bmp") - ,("gif","image/gif") - ] + map mkImageOverride imgs ++ + map mkMediaOverride [ eRelativePath e | e <- zEntries refArchive + , "word/media/" `isPrefixOf` eRelativePath e ] + let defaultnodes = [mknode "Default" [("Extension","xml"),("ContentType","application/xml")] (), mknode "Default" - [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()] ++ imageDefaults + [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()] let contentTypesDoc = mknode "Types" [("xmlns","http://schemas.openxmlformats.org/package/2006/content-types")] $ defaultnodes ++ overrides let contentTypesEntry = toEntry "[Content_Types].xml" epochtime $ renderXml contentTypesDoc -- cgit v1.2.3 From 05355ac57b7ccadfa4462f3304a7f6364147c8eb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 3 Jun 2014 11:03:40 -0700 Subject: Docx writer: Simplified abstractNumId numbering. Instead of sequential numbering, we assign numbers based on the list marker styles. This simplifies some of the code and should make it easier to modify numbering in the future. --- src/Text/Pandoc/Writers/Docx.hs | 49 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index e630c5094..572823871 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -66,6 +66,25 @@ data ListMarker = NoMarker | NumberMarker ListNumberStyle ListNumberDelim Int deriving (Show, Read, Eq, Ord) +listMarkerToId :: ListMarker -> String +listMarkerToId NoMarker = "0" +listMarkerToId BulletMarker = "1" +listMarkerToId (NumberMarker sty delim n) = + styNum : delimNum : show n + where styNum = case sty of + DefaultStyle -> '2' + Example -> '3' + Decimal -> '4' + LowerRoman -> '5' + UpperRoman -> '6' + LowerAlpha -> '7' + UpperAlpha -> '8' + delimNum = case delim of + DefaultDelim -> '0' + Period -> '1' + OneParen -> '2' + TwoParens -> '3' + data WriterState = WriterState{ stTextProperties :: [Element] , stParaProperties :: [Element] @@ -75,7 +94,6 @@ data WriterState = WriterState{ , stImages :: M.Map FilePath (String, String, Maybe String, Element, B.ByteString) , stListLevel :: Int , stListNumId :: Int - , stNumStyles :: M.Map ListMarker Int , stLists :: [ListMarker] } @@ -89,7 +107,6 @@ defaultWriterState = WriterState{ , stImages = M.empty , stListLevel = -1 , stListNumId = 1 - , stNumStyles = M.fromList [(NoMarker, 0)] , stLists = [NoMarker] } @@ -273,7 +290,7 @@ writeDocx opts doc@(Pandoc meta _) = do -- construct word/numbering.xml let numpath = "word/numbering.xml" numEntry <- (toEntry numpath epochtime . renderXml) - `fmap` mkNumbering (stNumStyles st) (stLists st) + `fmap` mkNumbering (stLists st) let docPropsPath = "docProps/core.xml" let docProps = mknode "cp:coreProperties" [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties") @@ -371,29 +388,28 @@ styleToOpenXml style = parStyle : map toStyle alltoktypes $ backgroundColor style ) ] -mkNumbering :: M.Map ListMarker Int -> [ListMarker] -> IO Element -mkNumbering markers lists = do - elts <- mapM mkAbstractNum (M.toList markers) +mkNumbering :: [ListMarker] -> IO Element +mkNumbering lists = do + elts <- mapM mkAbstractNum (ordNub lists) return $ mknode "w:numbering" [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")] - $ elts ++ zipWith (mkNum markers) lists [1..(length lists)] + $ elts ++ zipWith mkNum lists [1..(length lists)] -mkNum :: M.Map ListMarker Int -> ListMarker -> Int -> Element -mkNum markers marker numid = +mkNum :: ListMarker -> Int -> Element +mkNum marker numid = mknode "w:num" [("w:numId",show numid)] - $ mknode "w:abstractNumId" [("w:val",show absnumid)] () + $ mknode "w:abstractNumId" [("w:val",listMarkerToId marker)] () : case marker of NoMarker -> [] BulletMarker -> [] NumberMarker _ _ start -> map (\lvl -> mknode "w:lvlOverride" [("w:ilvl",show (lvl :: Int))] $ mknode "w:startOverride" [("w:val",show start)] ()) [0..6] - where absnumid = fromMaybe 0 $ M.lookup marker markers -mkAbstractNum :: (ListMarker,Int) -> IO Element -mkAbstractNum (marker,numid) = do +mkAbstractNum :: ListMarker -> IO Element +mkAbstractNum marker = do nsid <- randomRIO (0x10000000 :: Integer, 0xFFFFFFFF :: Integer) - return $ mknode "w:abstractNum" [("w:abstractNumId",show numid)] + return $ mknode "w:abstractNum" [("w:abstractNumId",listMarkerToId marker)] $ mknode "w:nsid" [("w:val", printf "%8x" nsid)] () : mknode "w:multiLevelType" [("w:val","multilevel")] () : map (mkLvl marker) [0..6] @@ -594,11 +610,6 @@ addList :: ListMarker -> WS () addList marker = do lists <- gets stLists modify $ \st -> st{ stLists = lists ++ [marker] } - numStyles <- gets stNumStyles - case M.lookup marker numStyles of - Just _ -> return () - Nothing -> modify $ \st -> - st{ stNumStyles = M.insert marker (M.size numStyles + 1) numStyles } listItemToOpenXML :: WriterOptions -> Int -> [Block] -> WS [Element] listItemToOpenXML _ _ [] = return [] -- cgit v1.2.3 From 2842ad5a978de758d70801b5279f75b9ba679406 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 3 Jun 2014 11:33:09 -0700 Subject: Docx writer: Changed abstractNumId numbering scheme. Now the minimum id used by pandoc is 990. All ids start with "99". This gives some room for a reference.docx to define numbering styles. Note: this is not yet possible, since pandoc generates numbering.xml entirely on its own. --- src/Text/Pandoc/Writers/Docx.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 572823871..ca0892547 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -67,10 +67,10 @@ data ListMarker = NoMarker deriving (Show, Read, Eq, Ord) listMarkerToId :: ListMarker -> String -listMarkerToId NoMarker = "0" -listMarkerToId BulletMarker = "1" +listMarkerToId NoMarker = "990" +listMarkerToId BulletMarker = "991" listMarkerToId (NumberMarker sty delim n) = - styNum : delimNum : show n + '9' : '9' : styNum : delimNum : show n where styNum = case sty of DefaultStyle -> '2' Example -> '3' -- cgit v1.2.3 From ec047aaa8c1c1e9d69b0029a2e4512785fbc15a8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 3 Jun 2014 12:13:31 -0700 Subject: Docx writer: pandoc uses only numIds >= 1000 for lists. This opens up the possiblity (with further code changes) of preserving some numbering from the reference.docx (e.g. header numbering.) See #1305. --- src/Text/Pandoc/Writers/Docx.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index ca0892547..3d2f5d4b5 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -388,12 +388,16 @@ styleToOpenXml style = parStyle : map toStyle alltoktypes $ backgroundColor style ) ] +-- this is the lowest number used for a list numId +baseListId :: Int +baseListId = 1000 + mkNumbering :: [ListMarker] -> IO Element mkNumbering lists = do elts <- mapM mkAbstractNum (ordNub lists) return $ mknode "w:numbering" [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")] - $ elts ++ zipWith mkNum lists [1..(length lists)] + $ elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)] mkNum :: ListMarker -> Int -> Element mkNum marker numid = @@ -461,7 +465,7 @@ mkLvl marker lvl = patternFor _ s = s ++ "." getNumId :: WS Int -getNumId = length `fmap` gets stLists +getNumId = ((999 +) . length) `fmap` gets stLists -- | Convert Pandoc document to two lists of -- OpenXML elements (the main document and footnotes). @@ -615,7 +619,8 @@ listItemToOpenXML :: WriterOptions -> Int -> [Block] -> WS [Element] listItemToOpenXML _ _ [] = return [] listItemToOpenXML opts numid (first:rest) = do first' <- withNumId numid $ blockToOpenXML opts first - rest' <- withNumId 1 $ blocksToOpenXML opts rest + -- baseListId is the code for no list marker: + rest' <- withNumId baseListId $ blocksToOpenXML opts rest return $ first' ++ rest' alignmentToString :: Alignment -> [Char] -- cgit v1.2.3 From 0ddb4cd2e8883c226ca7ab8a92737dc29f07dfda Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 3 Jun 2014 13:14:32 -0700 Subject: Docx writer: Combine reference.docx numbering with pandoc's. This should have fixed #1305, allowing the reference.docx to define section numbering, but it doesn't. Now the headings appear with proper indentation, but the numbers don't appear. Unclear why. styles.xml and numbering.xml basically match the docx which has the expected result. --- src/Text/Pandoc/Writers/Docx.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 3d2f5d4b5..785238d6f 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -289,8 +289,10 @@ writeDocx opts doc@(Pandoc meta _) = do -- construct word/numbering.xml let numpath = "word/numbering.xml" - numEntry <- (toEntry numpath epochtime . renderXml) - `fmap` mkNumbering (stLists st) + numbering <- parseXml refArchive distArchive numpath + newNumElts <- mkNumbering (stLists st) + let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent = + elContent numbering ++ map Elem newNumElts } let docPropsPath = "docProps/core.xml" let docProps = mknode "cp:coreProperties" [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties") @@ -392,12 +394,10 @@ styleToOpenXml style = parStyle : map toStyle alltoktypes baseListId :: Int baseListId = 1000 -mkNumbering :: [ListMarker] -> IO Element +mkNumbering :: [ListMarker] -> IO [Element] mkNumbering lists = do elts <- mapM mkAbstractNum (ordNub lists) - return $ mknode "w:numbering" - [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")] - $ elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)] + return $ elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)] mkNum :: ListMarker -> Int -> Element mkNum marker numid = -- cgit v1.2.3 From 45f3851611007f18530b52c9fcc5f0106fbc6816 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 3 Jun 2014 16:46:55 -0700 Subject: Docx writer: Section numbering carries over from reference.docx. Closes #1305. --- src/Text/Pandoc/Writers/Docx.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 785238d6f..4e64a79df 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -291,8 +291,13 @@ writeDocx opts doc@(Pandoc meta _) = do let numpath = "word/numbering.xml" numbering <- parseXml refArchive distArchive numpath newNumElts <- mkNumbering (stLists st) + let allElts = onlyElems (elContent numbering) ++ newNumElts let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent = - elContent numbering ++ map Elem newNumElts } + -- we want all the abstractNums first, then the nums, + -- otherwise things break: + [Elem e | e <- allElts + , qName (elName e) == "abstractNum" ] ++ + [Elem e | e <- allElts, qName (elName e) == "num" ] } let docPropsPath = "docProps/core.xml" let docProps = mknode "cp:coreProperties" [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties") -- cgit v1.2.3 From ab5dda7a601ad93b97ee02b3d216cc6d5321a462 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 3 Jun 2014 23:17:03 -0700 Subject: Markdown writer: Prettier pipe tables. Columns are now aligned. Closes #1323. --- src/Text/Pandoc/Writers/Markdown.hs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index f42a1b54c..a67271a5d 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -478,16 +478,24 @@ addMarkdownAttribute s = pipeTable :: Bool -> [Alignment] -> [Doc] -> [[Doc]] -> State WriterState Doc pipeTable headless aligns rawHeaders rawRows = do + let sp = text " " + let blockFor AlignLeft x y = lblock (x + 2) (sp <> y) <> lblock 0 empty + blockFor AlignCenter x y = cblock (x + 2) (sp <> y) <> lblock 0 empty + blockFor AlignRight x y = rblock (x + 2) (sp <> y) <> lblock 0 empty + blockFor _ x y = lblock (x + 2) (sp <> y) <> lblock 0 empty + let widths = map (max 3 . maximum . map offset) $ transpose (rawHeaders : rawRows) let torow cs = nowrap $ text "|" <> - hcat (intersperse (text "|") $ map chomp cs) <> text "|" - let toborder (a, h) = let wid = max (offset h) 3 - in text $ case a of - AlignLeft -> ':':replicate (wid - 1) '-' - AlignCenter -> ':':replicate (wid - 2) '-' ++ ":" - AlignRight -> replicate (wid - 1) '-' ++ ":" - AlignDefault -> replicate wid '-' + hcat (intersperse (text "|") $ + zipWith3 blockFor aligns widths (map chomp cs)) + <> text "|" + let toborder (a, w) = text $ case a of + AlignLeft -> ':':replicate (w + 1) '-' + AlignCenter -> ':':replicate w '-' ++ ":" + AlignRight -> replicate (w + 1) '-' ++ ":" + AlignDefault -> replicate (w + 2) '-' let header = if headless then empty else torow rawHeaders - let border = torow $ map toborder $ zip aligns rawHeaders + let border = nowrap $ text "|" <> hcat (intersperse (text "|") $ + map toborder $ zip aligns widths) <> text "|" let body = vcat $ map torow rawRows return $ header $$ border $$ body -- cgit v1.2.3 From 35e57db5c292957e74c24eb2cee63928c7865cc6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 Jun 2014 15:32:13 -0700 Subject: Finished first draft of Haddock writer. --- README | 12 +- pandoc.cabal | 7 +- src/Text/Pandoc.hs | 3 + src/Text/Pandoc/Readers/Haddock.hs | 13 +- src/Text/Pandoc/Writers/Haddock.hs | 357 +++++++++++++++++++++++++++++++++++++ 5 files changed, 381 insertions(+), 11 deletions(-) create mode 100644 src/Text/Pandoc/Writers/Haddock.hs (limited to 'src/Text/Pandoc/Writers') diff --git a/README b/README index 1883ecd57..122db23ec 100644 --- a/README +++ b/README @@ -18,10 +18,10 @@ Org-mode], [DocBook], and [Word docx]; and it can write plain text, [markdown], [reStructuredText], [XHTML], [HTML 5], [LaTeX] (including [beamer] slide shows), [ConTeXt], [RTF], [OPML], [DocBook], [OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki markup], -[EPUB] (v2 or v3), [FictionBook2], [Textile], [groff man] pages, -[Emacs Org-Mode], [AsciiDoc], [InDesign ICML], and [Slidy], -[Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. It can -also produce [PDF] output on systems where LaTeX is installed. +[Haddock markup], [EPUB] (v2 or v3), [FictionBook2], [Textile], +[groff man] pages, [Emacs Org-Mode], [AsciiDoc], [InDesign ICML], +and [Slidy], [Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. +It can also produce [PDF] output on systems where LaTeX is installed. Pandoc's enhanced version of markdown includes syntax for footnotes, tables, flexible ordered lists, definition lists, fenced code blocks, @@ -169,8 +169,8 @@ General options `context` (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs Org-Mode), `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` (DocBook), `opendocument` (OpenDocument), `odt` - (OpenOffice text document), `docx` (Word docx), - `rtf` (rich text format), `epub` (EPUB v2 book), `epub3` + (OpenOffice text document), `docx` (Word docx), `haddock` (Haddock + markup), `rtf` (rich text format), `epub` (EPUB v2 book), `epub3` (EPUB v3), `fb2` (FictionBook2 e-book), `asciidoc` (AsciiDoc), `icml` (InDesign ICML), `slidy` (Slidy HTML and javascript slide show), `slideous` (Slideous HTML and javascript slide show), `dzslides` diff --git a/pandoc.cabal b/pandoc.cabal index f9938bede..058e82a7f 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -21,9 +21,9 @@ Description: Pandoc is a Haskell library for converting from one markup markdown, reStructuredText, HTML, LaTeX, ConTeXt, Docbook, OPML, OpenDocument, ODT, Word docx, RTF, MediaWiki, Textile, groff man pages, plain text, Emacs Org-Mode, AsciiDoc, - EPUB (v2 and v3), FictionBook2, InDesign ICML, and several kinds - of HTML/javascript slide shows (S5, Slidy, Slideous, DZSlides, - reveal.js). + Haddock markup, EPUB (v2 and v3), FictionBook2, + InDesign ICML, and several kinds of HTML/javascript + slide shows (S5, Slidy, Slideous, DZSlides, reveal.js). . Pandoc extends standard markdown syntax with footnotes, embedded LaTeX, definition lists, tables, and other @@ -305,6 +305,7 @@ Library Text.Pandoc.Writers.Texinfo, Text.Pandoc.Writers.Man, Text.Pandoc.Writers.Markdown, + Text.Pandoc.Writers.Haddock, Text.Pandoc.Writers.RST, Text.Pandoc.Writers.Org, Text.Pandoc.Writers.AsciiDoc, diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs index 45c2f453b..d2e7887b5 100644 --- a/src/Text/Pandoc.hs +++ b/src/Text/Pandoc.hs @@ -102,6 +102,7 @@ module Text.Pandoc , writeFB2 , writeOrg , writeAsciiDoc + , writeHaddock , writeCustom -- * Rendering templates and default templates , module Text.Pandoc.Templates @@ -149,6 +150,7 @@ import Text.Pandoc.Writers.MediaWiki import Text.Pandoc.Writers.Textile import Text.Pandoc.Writers.Org import Text.Pandoc.Writers.AsciiDoc +import Text.Pandoc.Writers.Haddock import Text.Pandoc.Writers.Custom import Text.Pandoc.Templates import Text.Pandoc.Options @@ -279,6 +281,7 @@ writers = [ ,("rtf" , IOStringWriter writeRTFWithEmbeddedImages) ,("org" , PureStringWriter writeOrg) ,("asciidoc" , PureStringWriter writeAsciiDoc) + ,("haddock" , PureStringWriter writeHaddock) ] getDefaultExtensions :: String -> Set Extension diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs index a512f969d..f184eabdb 100644 --- a/src/Text/Pandoc/Readers/Haddock.hs +++ b/src/Text/Pandoc/Readers/Haddock.hs @@ -23,19 +23,28 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import Documentation.Haddock.Parser import Documentation.Haddock.Types +import Debug.Trace (trace) -- | Parse Haddock markup and return a 'Pandoc' document. readHaddock :: ReaderOptions -- ^ Reader options -> String -- ^ String to parse -> Pandoc -readHaddock _ = B.doc . docHToBlocks . parseParas +readHaddock opts = B.doc . docHToBlocks . trace' . parseParas + where trace' x = if readerTrace opts + then trace (show x) x + else x docHToBlocks :: DocH String Identifier -> Blocks docHToBlocks d' = case d' of DocEmpty -> mempty + DocAppend (DocParagraph (DocHeader h)) (DocParagraph (DocAName ident)) -> + B.headerWith (ident,[],[]) (headerLevel h) + (docHToInlines False $ headerTitle h) DocAppend d1 d2 -> mappend (docHToBlocks d1) (docHToBlocks d2) DocString _ -> inlineFallback + DocParagraph (DocHeader h) -> docHToBlocks (DocHeader h) + DocParagraph (DocAName h) -> B.plain $ docHToInlines False $ DocAName h DocParagraph ils -> B.para $ docHToInlines False ils DocIdentifier _ -> inlineFallback DocIdentifierUnchecked _ -> inlineFallback @@ -64,7 +73,7 @@ docHToBlocks d' = consolidatePlains = B.fromList . consolidatePlains' . B.toList consolidatePlains' zs@(Plain _ : _) = let (xs, ys) = span isPlain zs in - Plain (concatMap extractContents xs) : consolidatePlains' ys + Para (concatMap extractContents xs) : consolidatePlains' ys consolidatePlains' (x : xs) = x : consolidatePlains' xs consolidatePlains' [] = [] isPlain (Plain _) = True diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs new file mode 100644 index 000000000..4d6b8e69f --- /dev/null +++ b/src/Text/Pandoc/Writers/Haddock.hs @@ -0,0 +1,357 @@ +{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-} +{- +Copyright (C) 2014 John MacFarlane + +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 +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-} + +{- | + Module : Text.Pandoc.Writers.Haddock + Copyright : Copyright (C) 2014 John MacFarlane + License : GNU GPL, version 2 or above + + Maintainer : John MacFarlane + Stability : alpha + Portability : portable + +Conversion of 'Pandoc' documents to haddock markup. + +Haddock: +-} +module Text.Pandoc.Writers.Haddock (writeHaddock) where +import Text.Pandoc.Definition +import Text.Pandoc.Templates (renderTemplate') +import Text.Pandoc.Shared +import Text.Pandoc.Writers.Shared +import Text.Pandoc.Options +import Data.List ( intersperse, transpose ) +import Text.Pandoc.Pretty +import Control.Monad.State +import Text.Pandoc.Readers.TeXMath (readTeXMath') +import Network.URI (isURI) +import Data.Default + +type Notes = [[Block]] +data WriterState = WriterState { stNotes :: Notes } +instance Default WriterState + where def = WriterState{ stNotes = [] } + +-- | Convert Pandoc to Haddock. +writeHaddock :: WriterOptions -> Pandoc -> String +writeHaddock opts document = + evalState (pandocToHaddock opts{ + writerWrapText = writerWrapText opts } document) def + +-- | Return haddock representation of document. +pandocToHaddock :: WriterOptions -> Pandoc -> State WriterState String +pandocToHaddock opts (Pandoc meta blocks) = do + let colwidth = if writerWrapText opts + then Just $ writerColumns opts + else Nothing + body <- blockListToHaddock opts blocks + st <- get + notes' <- notesToHaddock opts (reverse $ stNotes st) + let render' :: Doc -> String + render' = render colwidth + let main = render' $ body <> + (if isEmpty notes' then empty else blankline <> notes') + metadata <- metaToJSON opts + (fmap (render colwidth) . blockListToHaddock opts) + (fmap (render colwidth) . inlineListToHaddock opts) + meta + let context = defField "body" main + $ metadata + if writerStandalone opts + then return $ renderTemplate' (writerTemplate opts) context + else return main + +-- | Return haddock representation of notes. +notesToHaddock :: WriterOptions -> [[Block]] -> State WriterState Doc +notesToHaddock opts notes = + mapM (\(num, note) -> noteToHaddock opts num note) (zip [1..] notes) >>= + return . vsep + +-- | Return haddock representation of a note. +noteToHaddock :: WriterOptions -> Int -> [Block] -> State WriterState Doc +noteToHaddock opts num blocks = do + contents <- blockListToHaddock opts blocks + let num' = text $ writerIdentifierPrefix opts ++ show num + let marker = text "[" <> num' <> text "]" + let markerSize = 4 + offset num' + let spacer = case writerTabStop opts - markerSize of + n | n > 0 -> text $ replicate n ' ' + _ -> text " " + return $ if isEnabled Ext_footnotes opts + then hang (writerTabStop opts) (marker <> spacer) contents + else marker <> spacer <> contents + +-- | Escape special characters for Haddock. +escapeString :: String -> String +escapeString = escapeStringUsing haddockEscapes + where haddockEscapes = backslashEscapes "\\/'`\"@<" + +-- | Convert Pandoc block element to haddock. +blockToHaddock :: WriterOptions -- ^ Options + -> Block -- ^ Block element + -> State WriterState Doc +blockToHaddock _ Null = return empty +blockToHaddock opts (Div _ ils) = do + contents <- blockListToHaddock opts ils + return $ contents <> blankline +blockToHaddock opts (Plain inlines) = do + contents <- inlineListToHaddock opts inlines + return $ contents <> cr +-- title beginning with fig: indicates figure +blockToHaddock opts (Para [Image alt (src,'f':'i':'g':':':tit)]) = + blockToHaddock opts (Para [Image alt (src,tit)]) +blockToHaddock opts (Para inlines) = + -- TODO: if it contains linebreaks, we need to use a @...@ block + (<> blankline) `fmap` blockToHaddock opts (Plain inlines) +blockToHaddock _ (RawBlock f str) + | f == "haddock" = do + return $ text str <> text "\n" + | otherwise = return empty +blockToHaddock _ HorizontalRule = + return $ blankline <> text "--------------" <> blankline +blockToHaddock opts (Header level (ident,_,_) inlines) = do + contents <- inlineListToHaddock opts inlines + let attr' = if null ident + then empty + else cr <> text "#" <> text ident <> text "#" + return $ nowrap (text (replicate level '=') <> space <> contents) + <> attr' <> blankline +blockToHaddock _ (CodeBlock (_,_,_) str) = + return $ prefixed "> " (text str) <> blankline +-- Nothing in haddock corresponds to block quotes: +blockToHaddock opts (BlockQuote blocks) = + blockListToHaddock opts blocks +-- Haddock doesn't have tables. Use haddock tables in code. +blockToHaddock opts (Table caption aligns widths headers rows) = do + caption' <- inlineListToHaddock opts caption + let caption'' = if null caption || not (isEnabled Ext_table_captions opts) + then empty + else blankline <> caption' <> blankline + rawHeaders <- mapM (blockListToHaddock opts) headers + rawRows <- mapM (mapM (blockListToHaddock opts)) rows + let isSimple = all (==0) widths + let isPlainBlock (Plain _) = True + isPlainBlock _ = False + let hasBlocks = not (all isPlainBlock $ concat . concat $ headers:rows) + (nst,tbl) <- case True of + _ | isSimple -> fmap (nest 2,) $ + pandocTable opts (all null headers) aligns widths + rawHeaders rawRows + | not hasBlocks -> fmap (nest 2,) $ + pandocTable opts (all null headers) aligns widths + rawHeaders rawRows + | otherwise -> fmap (id,) $ + gridTable opts (all null headers) aligns widths + rawHeaders rawRows + return $ prefixed "> " $ nst $ tbl $$ blankline $$ caption'' $$ blankline +blockToHaddock opts (BulletList items) = do + contents <- mapM (bulletListItemToHaddock opts) items + return $ cat contents <> blankline +blockToHaddock opts (OrderedList (start,sty,delim) items) = do + let attribs = (start, sty, delim) + let markers = orderedListMarkers attribs + let markers' = map (\m -> if length m < 3 + then m ++ replicate (3 - length m) ' ' + else m) markers + contents <- mapM (\(item, num) -> orderedListItemToHaddock opts item num) $ + zip markers' items + return $ cat contents <> blankline +blockToHaddock opts (DefinitionList items) = do + contents <- mapM (definitionListItemToHaddock opts) items + return $ cat contents <> blankline + +pandocTable :: WriterOptions -> Bool -> [Alignment] -> [Double] + -> [Doc] -> [[Doc]] -> State WriterState Doc +pandocTable opts headless aligns widths rawHeaders rawRows = do + let isSimple = all (==0) widths + let alignHeader alignment = case alignment of + AlignLeft -> lblock + AlignCenter -> cblock + AlignRight -> rblock + AlignDefault -> lblock + let numChars = maximum . map offset + let widthsInChars = if isSimple + then map ((+2) . numChars) + $ transpose (rawHeaders : rawRows) + else map + (floor . (fromIntegral (writerColumns opts) *)) + widths + let makeRow = hcat . intersperse (lblock 1 (text " ")) . + (zipWith3 alignHeader aligns widthsInChars) + let rows' = map makeRow rawRows + let head' = makeRow rawHeaders + let maxRowHeight = maximum $ map height (head':rows') + let underline = cat $ intersperse (text " ") $ + map (\width -> text (replicate width '-')) widthsInChars + let border = if maxRowHeight > 1 + then text (replicate (sum widthsInChars + + length widthsInChars - 1) '-') + else if headless + then underline + else empty + let head'' = if headless + then empty + else border <> cr <> head' + let body = if maxRowHeight > 1 + then vsep rows' + else vcat rows' + let bottom = if headless + then underline + else border + return $ head'' $$ underline $$ body $$ bottom + +gridTable :: WriterOptions -> Bool -> [Alignment] -> [Double] + -> [Doc] -> [[Doc]] -> State WriterState Doc +gridTable opts headless _aligns widths headers' rawRows = do + let numcols = length headers' + let widths' = if all (==0) widths + then replicate numcols (1.0 / fromIntegral numcols) + else widths + let widthsInChars = map (floor . (fromIntegral (writerColumns opts) *)) widths' + let hpipeBlocks blocks = hcat [beg, middle, end] + where h = maximum (map height blocks) + sep' = lblock 3 $ vcat (map text $ replicate h " | ") + beg = lblock 2 $ vcat (map text $ replicate h "| ") + end = lblock 2 $ vcat (map text $ replicate h " |") + middle = chomp $ hcat $ intersperse sep' blocks + let makeRow = hpipeBlocks . zipWith lblock widthsInChars + let head' = makeRow headers' + let rows' = map (makeRow . map chomp) rawRows + let border ch = char '+' <> char ch <> + (hcat $ intersperse (char ch <> char '+' <> char ch) $ + map (\l -> text $ replicate l ch) widthsInChars) <> + char ch <> char '+' + let body = vcat $ intersperse (border '-') rows' + let head'' = if headless + then empty + else head' $$ border '=' + return $ border '-' $$ head'' $$ body $$ border '-' + +-- | Convert bullet list item (list of blocks) to haddock +bulletListItemToHaddock :: WriterOptions -> [Block] -> State WriterState Doc +bulletListItemToHaddock opts items = do + contents <- blockListToHaddock opts items + let sps = replicate (writerTabStop opts - 2) ' ' + let start = text ('-' : ' ' : sps) + -- remove trailing blank line if it is a tight list + let contents' = case reverse items of + (BulletList xs:_) | isTightList xs -> + chomp contents <> cr + (OrderedList _ xs:_) | isTightList xs -> + chomp contents <> cr + _ -> contents + return $ hang (writerTabStop opts) start $ contents' <> cr + +-- | Convert ordered list item (a list of blocks) to haddock +orderedListItemToHaddock :: WriterOptions -- ^ options + -> String -- ^ list item marker + -> [Block] -- ^ list item (list of blocks) + -> State WriterState Doc +orderedListItemToHaddock opts marker items = do + contents <- blockListToHaddock opts items + let sps = case length marker - writerTabStop opts of + n | n > 0 -> text $ replicate n ' ' + _ -> text " " + let start = text marker <> sps + return $ hang (writerTabStop opts) start $ contents <> cr + +-- | Convert definition list item (label, list of blocks) to haddock +definitionListItemToHaddock :: WriterOptions + -> ([Inline],[[Block]]) + -> State WriterState Doc +definitionListItemToHaddock opts (label, defs) = do + labelText <- inlineListToHaddock opts label + defs' <- mapM (mapM (blockToHaddock opts)) defs + let contents = vcat $ map (\d -> hang 4 empty $ vcat d <> cr) defs' + return $ nowrap (brackets labelText) <> cr <> contents <> cr + +-- | Convert list of Pandoc block elements to haddock +blockListToHaddock :: WriterOptions -- ^ Options + -> [Block] -- ^ List of block elements + -> State WriterState Doc +blockListToHaddock opts blocks = + mapM (blockToHaddock opts) blocks >>= return . cat + +-- | Convert list of Pandoc inline elements to haddock. +inlineListToHaddock :: WriterOptions -> [Inline] -> State WriterState Doc +inlineListToHaddock opts lst = + mapM (inlineToHaddock opts) lst >>= return . cat + +-- | Convert Pandoc inline element to haddock. +inlineToHaddock :: WriterOptions -> Inline -> State WriterState Doc +inlineToHaddock opts (Span (ident,_,_) ils) = do + contents <- inlineListToHaddock opts ils + if not (null ident) && null ils + then return $ "#" <> text ident <> "#" + else return contents +inlineToHaddock opts (Emph lst) = do + contents <- inlineListToHaddock opts lst + return $ "/" <> contents <> "/" +inlineToHaddock opts (Strong lst) = do + contents <- inlineListToHaddock opts lst + return $ "__" <> contents <> "__" +inlineToHaddock opts (Strikeout lst) = do + contents <- inlineListToHaddock opts lst + -- not supported in haddock, but we fake it: + return $ "~~" <> contents <> "~~" +-- not supported in haddock: +inlineToHaddock opts (Superscript lst) = inlineListToHaddock opts lst +-- not supported in haddock: +inlineToHaddock opts (Subscript lst) = inlineListToHaddock opts lst +-- not supported in haddock: +inlineToHaddock opts (SmallCaps lst) = inlineListToHaddock opts lst +inlineToHaddock opts (Quoted SingleQuote lst) = do + contents <- inlineListToHaddock opts lst + return $ "‘" <> contents <> "’" +inlineToHaddock opts (Quoted DoubleQuote lst) = do + contents <- inlineListToHaddock opts lst + return $ "“" <> contents <> "”" +inlineToHaddock _ (Code _ str) = + return $ "@" <> text (escapeString str) <> "@" +inlineToHaddock _ (Str str) = do + return $ text $ escapeString str +inlineToHaddock opts (Math mt str) = do + let adjust x = case mt of + DisplayMath -> cr <> x <> cr + InlineMath -> x + adjust `fmap` (inlineListToHaddock opts $ readTeXMath' mt str) +inlineToHaddock _ (RawInline f str) + | f == "haddock" = return $ text str + | otherwise = return empty +-- no line break in haddock (see above on CodeBlock) +inlineToHaddock _ (LineBreak) = return cr +inlineToHaddock _ Space = return space +inlineToHaddock opts (Cite _ lst) = inlineListToHaddock opts lst +inlineToHaddock opts (Link txt (src, _)) = do + linktext <- inlineListToHaddock opts txt + let useAuto = isURI src && + case txt of + [Str s] | escapeURI s == src -> True + _ -> False + return $ nowrap $ "<" <> text src <> + (if useAuto then empty else space <> linktext) <> ">" +inlineToHaddock opts (Image alternate (source, tit)) = do + linkhaddock <- inlineToHaddock opts (Link alternate (source, tit)) + return $ "<" <> linkhaddock <> ">" +-- haddock doesn't have notes, but we can fake it: +inlineToHaddock opts (Note contents) = do + modify (\st -> st{ stNotes = contents : stNotes st }) + st <- get + let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st) + return $ "[" <> ref <> "]" -- cgit v1.2.3 From ff6a2baeb9940276fbbaf486a5711378d13cc1e1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 Jun 2014 17:49:59 -0700 Subject: More polish on Haddock reader/writer. --- src/Text/Pandoc/Readers/Haddock.hs | 46 +++++++++++++++++++++++++++++++++----- src/Text/Pandoc/Writers/Haddock.hs | 23 +++++-------------- 2 files changed, 47 insertions(+), 22 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs index f184eabdb..a3dfb7c3c 100644 --- a/src/Text/Pandoc/Readers/Haddock.hs +++ b/src/Text/Pandoc/Readers/Haddock.hs @@ -45,7 +45,9 @@ docHToBlocks d' = DocString _ -> inlineFallback DocParagraph (DocHeader h) -> docHToBlocks (DocHeader h) DocParagraph (DocAName h) -> B.plain $ docHToInlines False $ DocAName h - DocParagraph ils -> B.para $ docHToInlines False ils + DocParagraph x -> let (ils, rest) = getInlines x + in (B.para $ docHToInlines False ils) + <> docHToBlocks rest DocIdentifier _ -> inlineFallback DocIdentifierUnchecked _ -> inlineFallback DocModule s -> B.plain $ docHToInlines False $ DocModule s @@ -60,7 +62,7 @@ docHToBlocks d' = DocDefList items -> B.definitionList (map (\(d,t) -> (docHToInlines False d, [consolidatePlains $ docHToBlocks t])) items) - DocCodeBlock (DocString s) -> B.codeBlockWith ("",["haskell"],[]) s + DocCodeBlock (DocString s) -> B.codeBlockWith ("",[],[]) s DocCodeBlock d -> B.para $ docHToInlines True d DocHyperlink _ -> inlineFallback DocPic _ -> inlineFallback @@ -92,9 +94,9 @@ docHToInlines isCode d' = $ map B.code $ splitBy (=='\n') s | otherwise -> B.text s DocParagraph _ -> mempty - DocIdentifier (_,s,_) -> B.codeWith ("",["haskell"],[]) s - DocIdentifierUnchecked s -> B.codeWith ("",["haskell"],[]) s - DocModule s -> B.codeWith ("",["haskell"],[]) s + DocIdentifier (_,s,_) -> B.codeWith ("",["haskell","identifier"],[]) s + DocIdentifierUnchecked s -> B.codeWith ("",["haskell","identifier"],[]) s + DocModule s -> B.codeWith ("",["haskell","module"],[]) s DocWarning _ -> mempty -- TODO DocEmphasis d -> B.emph (docHToInlines isCode d) DocMonospaced (DocString s) -> B.code s @@ -113,6 +115,40 @@ docHToInlines isCode d' = DocProperty _ -> mempty DocExamples _ -> mempty +getInlines :: DocH String Identifier -> (DocH String Identifier, DocH String Identifier) +getInlines (DocAppend x y) = if isInline x + then let (a, b) = getInlines y + in (DocAppend x a, b) + else (DocEmpty, DocAppend x y) +getInlines x = if isInline x + then (x, DocEmpty) + else (DocEmpty, x) + +isInline :: DocH String Identifier -> Bool +isInline d' = + case d' of + DocEmpty -> True + DocAppend d1 _ -> isInline d1 + DocString _ -> True + DocParagraph _ -> False + DocIdentifier _ -> True + DocIdentifierUnchecked _ -> True + DocModule _ -> True + DocWarning _ -> True + DocEmphasis _ -> True + DocMonospaced _ -> True + DocBold _ -> True + DocHeader _ -> False + DocUnorderedList _ -> False + DocOrderedList _ -> False + DocDefList _ -> False + DocCodeBlock _ -> False + DocHyperlink _ -> True + DocPic _ -> True + DocAName _ -> True + DocProperty _ -> False + DocExamples _ -> False + -- | Create an 'Example', stripping superfluous characters as appropriate makeExample :: String -> String -> [String] -> Blocks makeExample prompt expression result = diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs index 4d6b8e69f..36f57c2b7 100644 --- a/src/Text/Pandoc/Writers/Haddock.hs +++ b/src/Text/Pandoc/Writers/Haddock.hs @@ -80,22 +80,11 @@ pandocToHaddock opts (Pandoc meta blocks) = do -- | Return haddock representation of notes. notesToHaddock :: WriterOptions -> [[Block]] -> State WriterState Doc notesToHaddock opts notes = - mapM (\(num, note) -> noteToHaddock opts num note) (zip [1..] notes) >>= - return . vsep - --- | Return haddock representation of a note. -noteToHaddock :: WriterOptions -> Int -> [Block] -> State WriterState Doc -noteToHaddock opts num blocks = do - contents <- blockListToHaddock opts blocks - let num' = text $ writerIdentifierPrefix opts ++ show num - let marker = text "[" <> num' <> text "]" - let markerSize = 4 + offset num' - let spacer = case writerTabStop opts - markerSize of - n | n > 0 -> text $ replicate n ' ' - _ -> text " " - return $ if isEnabled Ext_footnotes opts - then hang (writerTabStop opts) (marker <> spacer) contents - else marker <> spacer <> contents + if null notes + then return empty + else do + contents <- blockToHaddock opts $ OrderedList (1,DefaultStyle,DefaultDelim) notes + return $ text "#notes#" <> blankline <> contents -- | Escape special characters for Haddock. escapeString :: String -> String @@ -354,4 +343,4 @@ inlineToHaddock opts (Note contents) = do modify (\st -> st{ stNotes = contents : stNotes st }) st <- get let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st) - return $ "[" <> ref <> "]" + return $ "<#notes [" <> ref <> "]>" -- cgit v1.2.3 From c4182b39ca009f02fc4e0768056d37d64b93df7c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 Jun 2014 18:08:41 -0700 Subject: Small fix to haddock "tables". --- src/Text/Pandoc/Writers/Haddock.hs | 4 ++-- tests/tables.haddock | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs index 36f57c2b7..1939d3a6d 100644 --- a/src/Text/Pandoc/Writers/Haddock.hs +++ b/src/Text/Pandoc/Writers/Haddock.hs @@ -129,7 +129,7 @@ blockToHaddock opts (BlockQuote blocks) = -- Haddock doesn't have tables. Use haddock tables in code. blockToHaddock opts (Table caption aligns widths headers rows) = do caption' <- inlineListToHaddock opts caption - let caption'' = if null caption || not (isEnabled Ext_table_captions opts) + let caption'' = if null caption then empty else blankline <> caption' <> blankline rawHeaders <- mapM (blockListToHaddock opts) headers @@ -148,7 +148,7 @@ blockToHaddock opts (Table caption aligns widths headers rows) = do | otherwise -> fmap (id,) $ gridTable opts (all null headers) aligns widths rawHeaders rawRows - return $ prefixed "> " $ nst $ tbl $$ blankline $$ caption'' $$ blankline + return $ (prefixed "> " $ nst $ tbl $$ blankline $$ caption'') $$ blankline blockToHaddock opts (BulletList items) = do contents <- mapM (bulletListItemToHaddock opts) items return $ cat contents <> blankline diff --git a/tests/tables.haddock b/tests/tables.haddock index e054dc072..413ec97ad 100644 --- a/tests/tables.haddock +++ b/tests/tables.haddock @@ -6,6 +6,8 @@ Simple table with caption: > 123 123 123 123 > 1 1 1 1 > +> Demonstration of simple table syntax. + Simple table without caption: > Right Left Center Default @@ -13,7 +15,7 @@ Simple table without caption: > 12 12 12 12 > 123 123 123 123 > 1 1 1 1 -> + Simple table indented two spaces: > Right Left Center Default @@ -22,6 +24,8 @@ Simple table indented two spaces: > 123 123 123 123 > 1 1 1 1 > +> Demonstration of simple table syntax. + Multiline table with caption: > -------------------------------------------------------------- @@ -36,6 +40,8 @@ Multiline table with caption: > rows. > -------------------------------------------------------------- > +> Here\'s the caption. It may span multiple lines. + Multiline table without caption: > -------------------------------------------------------------- @@ -49,7 +55,7 @@ Multiline table without caption: > the blank line between > rows. > -------------------------------------------------------------- -> + Table without column headers: > ----- ----- ----- ----- @@ -57,7 +63,7 @@ Table without column headers: > 123 123 123 123 > 1 1 1 1 > ----- ----- ----- ----- -> + Multiline table without column headers: > ----------- ---------- ------------ -------------------------- @@ -68,5 +74,4 @@ Multiline table without column headers: > the blank line between > rows. > ----------- ---------- ------------ -------------------------- -> -- cgit v1.2.3 From de7b3a3d08264d6aa755436583d53f9a61252fa2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 18 Jun 2014 18:11:01 -0700 Subject: Haddock writer: Only use Decimal list style. --- src/Text/Pandoc/Writers/Haddock.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs index 1939d3a6d..59d979ea8 100644 --- a/src/Text/Pandoc/Writers/Haddock.hs +++ b/src/Text/Pandoc/Writers/Haddock.hs @@ -152,8 +152,8 @@ blockToHaddock opts (Table caption aligns widths headers rows) = do blockToHaddock opts (BulletList items) = do contents <- mapM (bulletListItemToHaddock opts) items return $ cat contents <> blankline -blockToHaddock opts (OrderedList (start,sty,delim) items) = do - let attribs = (start, sty, delim) +blockToHaddock opts (OrderedList (start,_,delim) items) = do + let attribs = (start, Decimal, delim) let markers = orderedListMarkers attribs let markers' = map (\m -> if length m < 3 then m ++ replicate (3 - length m) ' ' -- cgit v1.2.3 From 00281559bf9c955ece6b18d48ef487fdc5f4406e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 19 Jun 2014 00:28:23 -0700 Subject: Haddock writer: Use _____ for hrule. Avoids interpretation as list. --- src/Text/Pandoc/Writers/Haddock.hs | 4 ++-- tests/writer.haddock | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs index 59d979ea8..1c82839d0 100644 --- a/src/Text/Pandoc/Writers/Haddock.hs +++ b/src/Text/Pandoc/Writers/Haddock.hs @@ -112,8 +112,8 @@ blockToHaddock _ (RawBlock f str) | f == "haddock" = do return $ text str <> text "\n" | otherwise = return empty -blockToHaddock _ HorizontalRule = - return $ blankline <> text "--------------" <> blankline +blockToHaddock opts HorizontalRule = + return $ blankline <> text (replicate (writerColumns opts) '_') <> blankline blockToHaddock opts (Header level (ident,_,_) inlines) = do contents <- inlineListToHaddock opts inlines let attr' = if null ident diff --git a/tests/writer.haddock b/tests/writer.haddock index 129242153..0772331e3 100644 --- a/tests/writer.haddock +++ b/tests/writer.haddock @@ -1,7 +1,7 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite. --------------- +______________________________________________________________________________ = Headers #headers# @@ -34,7 +34,7 @@ with no blank line with no blank line --------------- +______________________________________________________________________________ = Paragraphs #paragraphs# @@ -50,7 +50,7 @@ Here’s one with a bullet. * criminey. There should be a hard line break here. --------------- +______________________________________________________________________________ = Block Quotes #block-quotes# @@ -80,7 +80,7 @@ This should not be a block quote: 2 > 1. And a following paragraph. --------------- +______________________________________________________________________________ = Code Blocks #code-blocks# @@ -101,7 +101,7 @@ And: > > These should not be escaped: \$ \\ \> \[ \{ --------------- +______________________________________________________________________________ = Lists #lists# @@ -264,7 +264,7 @@ M.A. 2007 B. Williams --------------- +______________________________________________________________________________ = Definition Lists #definition-lists# @@ -397,7 +397,7 @@ Code: Hr’s: --------------- +______________________________________________________________________________ = Inline Markup #inline-markup# @@ -427,7 +427,7 @@ Subscripts: H2O, H23O, Hmany of themO. These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d. --------------- +______________________________________________________________________________ = Smart quotes, ellipses, dashes #smart-quotes-ellipses-dashes# @@ -449,7 +449,7 @@ Dashes between numbers: 5–7, 255–66, 1987–1999. Ellipses…and…and…. --------------- +______________________________________________________________________________ = LaTeX #latex# @@ -474,7 +474,7 @@ These shouldn’t be math: Here’s a LaTeX table: --------------- +______________________________________________________________________________ = Special Characters #special-characters# @@ -529,7 +529,7 @@ Plus: + Minus: - --------------- +______________________________________________________________________________ = Links #links# @@ -610,7 +610,7 @@ Auto-links should not occur here: @\@ > or here: --------------- +______________________________________________________________________________ = Images #images# @@ -621,7 +621,7 @@ From “Voyage dans la Lune” by Georges Melies (1902): Here is a movie <> icon. --------------- +______________________________________________________________________________ = Footnotes #footnotes# -- cgit v1.2.3 From 557b302731411057cf12e62c87d98752f713d5d0 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 19 Jun 2014 23:31:17 -0700 Subject: Docx writer: Use Compact style for empty table cells. Otherwise we get overly tall lines when there are empty table cells and the other cells are compact. Closes #1353. --- src/Text/Pandoc/Writers/Docx.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index 4e64a79df..31e64f14e 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -571,10 +571,12 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do [ mknode "w:tcBorders" [] $ mknode "w:bottom" [("w:val","single")] () , mknode "w:vAlign" [("w:val","bottom")] () ] + let emptyCell = [mknode "w:p" [] [mknode "w:pPr" [] $ + [mknode "w:pStyle" [("w:val","Compact")] ()]]] let mkcell border contents = mknode "w:tc" [] $ [ borderProps | border ] ++ if null contents - then [mknode "w:p" [] ()] + then emptyCell else contents let mkrow border cells = mknode "w:tr" [] $ map (mkcell border) cells let textwidth = 7920 -- 5.5 in in twips, 1/20 pt -- cgit v1.2.3 From 12efffa85a257dbe81137f97334b2c6a7e072777 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 20 Jun 2014 10:24:30 -0700 Subject: LaTeX writer: Fixed strikeout + highlighted code. Closes #1294. Previously strikeout highlighted code caused an error. --- src/Text/Pandoc/Writers/LaTeX.hs | 11 ++++++++++- tests/Tests/Writers/LaTeX.hs | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index c221b318e..ed735242f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -678,7 +678,9 @@ inlineToLaTeX (Emph lst) = inlineToLaTeX (Strong lst) = inlineListToLaTeX lst >>= return . inCmd "textbf" inlineToLaTeX (Strikeout lst) = do - contents <- inlineListToLaTeX lst + -- we need to protect VERB in an mbox or we get an error + -- see #1294 + contents <- inlineListToLaTeX $ protectCode lst modify $ \s -> s{ stStrikeout = True } return $ inCmd "sout" contents inlineToLaTeX (Superscript lst) = @@ -784,6 +786,13 @@ inlineToLaTeX (Note contents) = do -- note: a \n before } needed when note ends with a Verbatim environment else "\\footnote" <> braces noteContents +protectCode :: [Inline] -> [Inline] +protectCode [] = [] +protectCode (x@(Code ("",[],[]) _) : xs) = x : protectCode xs +protectCode (x@(Code _ _) : xs) = ltx "\\mbox{" : x : ltx "}" : xs + where ltx = RawInline (Format "latex") +protectCode (x : xs) = x : protectCode xs + citationsToNatbib :: [Citation] -> State WriterState Doc citationsToNatbib (one:[]) = citeCommand c p s k diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index 8a9519e2e..6db6542a0 100644 --- a/tests/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs @@ -8,7 +8,7 @@ import Tests.Helpers import Tests.Arbitrary() latex :: (ToString a, ToPandoc a) => a -> String -latex = writeLaTeX def . toPandoc +latex = writeLaTeX def{ writerHighlight = True } . toPandoc latexListing :: (ToString a, ToPandoc a) => a -> String latexListing = writeLaTeX def{ writerListings = True } . toPandoc @@ -54,4 +54,14 @@ tests = [ testGroup "code blocks" (text "Header 1" <> note (plain $ text "note")) =?> "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n" ] + , testGroup "inline code" + [ "struck out and highlighted" =: + strikeout (codeWith ("",["haskell"],[]) "foo" <> space + <> str "bar") =?> + "\\sout{\\mbox{\\VERB|\\NormalTok{foo}|} bar}" + , "struck out and not highlighted" =: + strikeout (code "foo" <> space + <> str "bar") =?> + "\\sout{\\texttt{foo} bar}" + ] ] -- cgit v1.2.3 From d81b4358ea8d0da615c01a468196fd0592934af6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 20 Jun 2014 11:26:38 -0700 Subject: LaTeX writer: Correctly handle figures in notes. Notes can't contain figures in LaTeX, so we fake it to avoid an error. Closes #1053. --- src/Text/Pandoc/Writers/LaTeX.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ed735242f..f2f7438c4 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -311,12 +311,14 @@ blockToLaTeX (Plain lst) = inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst -- title beginning with fig: indicates that the image is a figure blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do - capt <- if null txt - then return empty - else (\c -> "\\caption" <> braces c) `fmap` inlineListToLaTeX txt + inNote <- gets stInNote + capt <- inlineListToLaTeX txt img <- inlineToLaTeX (Image txt (src,tit)) - return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$ - capt $$ "\\end{figure}" + return $ if inNote + -- can't have figures in notes + then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}" + else "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$ + ("\\caption" <> braces capt) $$ "\\end{figure}" -- . . . indicates pause in beamer slides blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do beamer <- writerBeamer `fmap` gets stOptions -- cgit v1.2.3 From 87ab01637e1dc0f583277828bc458567a72e38ce Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 23 Jun 2014 12:51:10 -0700 Subject: LaTeX writer: Use `\textquotesingle` for `'` in inline code. Otherwise we get curly quotes in the PDF output. Closes #1364. --- src/Text/Pandoc/Writers/LaTeX.hs | 1 + tests/Tests/Writers/LaTeX.hs | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index f2f7438c4..100bf900d 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -220,6 +220,7 @@ stringToLaTeX ctx (x:xs) = do '>' -> "\\textgreater{}" ++ rest '[' -> "{[}" ++ rest -- to avoid interpretation as ']' -> "{]}" ++ rest -- optional arguments + '\'' | ctx == CodeString -> "\\textquotesingle{}" ++ rest '\160' -> "~" ++ rest '\x2026' -> "\\ldots{}" ++ rest '\x2018' | ligatures -> "`" ++ rest diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs index 6db6542a0..c32ded36d 100644 --- a/tests/Tests/Writers/LaTeX.hs +++ b/tests/Tests/Writers/LaTeX.hs @@ -63,5 +63,7 @@ tests = [ testGroup "code blocks" strikeout (code "foo" <> space <> str "bar") =?> "\\sout{\\texttt{foo} bar}" + , "single quotes" =: + code "dog's" =?> "\\texttt{dog\\textquotesingle{}s}" ] ] -- cgit v1.2.3