git.iko.soy/typeable/pandoc
on master help sign in
Adjustments for new Format newtype.
commitcbfa9321066212b912583481015224f3c944ae21 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 10 Aug 2013, 17:23 (13 years ago) parente9de0f0
19 files changed+106−76
src/Text/Pandoc/Readers/HTML.hs+2−2 src/Text/Pandoc/Readers/LaTeX.hs+1−1 src/Text/Pandoc/Readers/RST.hs+1 src/Text/Pandoc/Readers/Textile.hs+3−3 src/Text/Pandoc/Writers/AsciiDoc.hs+6−2 src/Text/Pandoc/Writers/Custom.hs+6 src/Text/Pandoc/Writers/Docbook.hs+5−4 src/Text/Pandoc/Writers/Docx.hs+5−5 src/Text/Pandoc/Writers/EPUB.hs+3−3 src/Text/Pandoc/Writers/HTML.hs+8−5 src/Text/Pandoc/Writers/LaTeX.hs+8−5 src/Text/Pandoc/Writers/Man.hs+6−4 src/Text/Pandoc/Writers/MediaWiki.hs+8−6 src/Text/Pandoc/Writers/OpenDocument.hs+7−5 src/Text/Pandoc/Writers/RST.hs+9−6 src/Text/Pandoc/Writers/RTF.hs+7−5 src/Text/Pandoc/Writers/Texinfo.hs+11−8 src/Text/Pandoc/Writers/Textile.hs+6−8 tests/Tests/Arbitrary.hs+4−4
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -182,7 +182,7 @@ pRawHtmlBlock = do
182182 raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag
183183 parseRaw <- getOption readerParseRaw
184184 if parseRaw && not (null raw)
185− then return [RawBlock "html" raw]
185+ then return [RawBlock (Format "html") raw]
186186 else return []
187187
188188pHtmlBlock :: String -> TagParser String
@@ -408,7 +408,7 @@ pRawHtmlInline = do
408408 result <- pSatisfy (tagComment (const True)) <|> pSatisfy isInlineTag
409409 parseRaw <- getOption readerParseRaw
410410 if parseRaw
411− then return [RawInline "html" $ renderTags' [result]]
411+ then return [RawInline (Format "html") $ renderTags' [result]]
412412 else return []
413413
414414pInlinesInTags :: String -> ([Inline] -> Inline)
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE ScopedTypeVariables #-}
1+{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-}
22{-
33Copyright (C) 2006-2012 John MacFarlane <jgm@berkeley.edu>
44
src/Text/Pandoc/Readers/RST.hs+1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE OverloadedStrings #-}
12{-
23Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
34
src/Text/Pandoc/Readers/Textile.hs+3−3
@@ -290,13 +290,13 @@ rawHtmlBlock :: Parser [Char] ParserState Block
290290rawHtmlBlock = try $ do
291291 (_,b) <- htmlTag isBlockTag
292292 optional blanklines
293− return $ RawBlock "html" b
293+ return $ RawBlock (Format "html") b
294294
295295-- | Raw block of LaTeX content
296296rawLaTeXBlock' :: Parser [Char] ParserState Block
297297rawLaTeXBlock' = do
298298 guardEnabled Ext_raw_tex
299− RawBlock "latex" <$> (rawLaTeXBlock <* spaces)
299+ RawBlock (Format "latex") <$> (rawLaTeXBlock <* spaces)
300300
301301
302302-- | In textile, paragraphs are separated by blank lines.
@@ -487,7 +487,7 @@ endline = try $ do
487487 return LineBreak
488488
489489rawHtmlInline :: Parser [Char] ParserState Inline
490−rawHtmlInline = RawInline "html" . snd <$> htmlTag isInlineTag
490+rawHtmlInline = RawInline (Format "html") . snd <$> htmlTag isInlineTag
491491
492492-- | Raw LaTeX Inline
493493rawLaTeXInline' :: Parser [Char] ParserState Inline
src/Text/Pandoc/Writers/AsciiDoc.hs+6−2
@@ -132,7 +132,9 @@ blockToAsciiDoc opts (Para inlines) = do
132132 then text "\\"
133133 else empty
134134 return $ esc <> contents <> blankline
135−blockToAsciiDoc _ (RawBlock _ _) = return empty
135+blockToAsciiDoc _ (RawBlock f s)
136+ | f == "asciidoc" = return $ text s
137+ | otherwise = return empty
136138blockToAsciiDoc _ HorizontalRule =
137139 return $ blankline <> text "'''''" <> blankline
138140blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
@@ -347,7 +349,9 @@ inlineToAsciiDoc _ (Math InlineMath str) =
347349 return $ "latexmath:[$" <> text str <> "$]"
348350inlineToAsciiDoc _ (Math DisplayMath str) =
349351 return $ "latexmath:[\\[" <> text str <> "\\]]"
350−inlineToAsciiDoc _ (RawInline _ _) = return empty
352+inlineToAsciiDoc _ (RawInline f s)
353+ | f == "asciidoc" = return $ text s
354+ | otherwise = return empty
351355inlineToAsciiDoc _ (LineBreak) = return $ " +" <> cr
352356inlineToAsciiDoc _ Space = return space
353357inlineToAsciiDoc opts (Cite _ lst) = inlineListToAsciiDoc opts lst
src/Text/Pandoc/Writers/Custom.hs+6
@@ -33,6 +33,7 @@ module Text.Pandoc.Writers.Custom ( writeCustom ) where
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Options
3535import Data.List ( intersperse )
36+import Data.Char ( toLower )
3637import Scripting.Lua (LuaState, StackValue, callfunc)
3738import qualified Scripting.Lua as Lua
3839import Text.Pandoc.UTF8 (fromString, toString)
@@ -78,6 +79,11 @@ instance StackValue a => StackValue [a] where
7879 return (Just lst)
7980 valuetype _ = Lua.TTABLE
8081
82+instance StackValue Format where
83+ push lua (Format f) = Lua.push lua (map toLower f)
84+ peek l n = fmap Format `fmap` Lua.peek l n
85+ valuetype _ = Lua.TSTRING
86+
8187instance (StackValue a, StackValue b) => StackValue (M.Map a b) where
8288 push lua m = do
8389 let xs = M.toList m
src/Text/Pandoc/Writers/Docbook.hs+5−4
@@ -1,3 +1,4 @@
1+{-# LANGUAGE OverloadedStrings #-}
12{-
23Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
34
@@ -199,10 +200,10 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
199200 in inTags True "orderedlist" attribs items
200201blockToDocbook opts (DefinitionList lst) =
201202 inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
202−blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block
203−-- we allow html for compatibility with earlier versions of pandoc
204−blockToDocbook _ (RawBlock "html" str) = text str -- raw XML block
205−blockToDocbook _ (RawBlock _ _) = empty
203+blockToDocbook _ (RawBlock f str)
204+ | f == "docbook" = text str -- raw XML block
205+ | f == "html" = text str -- allow html for backwards compatibility
206+ | otherwise = empty
206207blockToDocbook _ HorizontalRule = empty -- not semantic
207208blockToDocbook opts (Table caption aligns widths headers rows) =
208209 let captionDoc = if null caption
src/Text/Pandoc/Writers/Docx.hs+5−5
@@ -460,8 +460,8 @@ blockToOpenXML opts (Para lst) = do
460460 contents <- inlinesToOpenXML opts lst
461461 return [mknode "w:p" [] (paraProps ++ contents)]
462462blockToOpenXML _ (RawBlock format str)
463− | format == "openxml" = return [ x | Elem x <- parseXML str ]
464− | otherwise = return []
463+ | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
464+ | otherwise = return []
465465blockToOpenXML opts (BlockQuote blocks) =
466466 withParaProp (pStyle "BlockQuote") $ blocksToOpenXML opts blocks
467467blockToOpenXML opts (CodeBlock attrs str) =
@@ -653,8 +653,8 @@ inlineToOpenXML opts (Strikeout lst) =
653653 $ inlinesToOpenXML opts lst
654654inlineToOpenXML _ LineBreak = return [br]
655655inlineToOpenXML _ (RawInline f str)
656− | f == "openxml" = return [ x | Elem x <- parseXML str ]
657− | otherwise = return []
656+ | f == Format "openxml" = return [ x | Elem x <- parseXML str ]
657+ | otherwise = return []
658658inlineToOpenXML opts (Quoted quoteType lst) =
659659 inlinesToOpenXML opts $ [Str open] ++ lst ++ [Str close]
660660 where (open, close) = case quoteType of
@@ -688,7 +688,7 @@ inlineToOpenXML opts (Note bs) = do
688688 let notemarker = mknode "w:r" []
689689 [ mknode "w:rPr" [] (rStyle "FootnoteRef")
690690 , mknode "w:footnoteRef" [] () ]
691− let notemarkerXml = RawInline "openxml" $ ppElement notemarker
691+ let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
692692 let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
693693 insertNoteRef (Para ils : xs) = Para (notemarkerXml : ils) : xs
694694 insertNoteRef xs = Para [notemarkerXml] : xs
src/Text/Pandoc/Writers/EPUB.hs+3−3
@@ -103,7 +103,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
103103 Just img -> do
104104 let coverImage = "cover-image" ++ takeExtension img
105105 let cpContent = renderHtml $ writeHtml opts'
106− (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])
106+ (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])
107107 imgContent <- B.readFile img
108108 return ( [mkEntry "cover.xhtml" cpContent]
109109 , [mkEntry coverImage imgContent] )
@@ -422,7 +422,7 @@ transformInline opts sourceDir picsRef (Image lab (src,tit))
422422 | isAbsoluteURI src = do
423423 raw <- makeSelfContained Nothing
424424 $ writeHtmlInline opts (Image lab (src,tit))
425− return $ RawInline "html" raw
425+ return $ RawInline (Format "html") raw
426426 | otherwise = do
427427 let src' = unEscapeString src
428428 pics <- readIORef picsRef
@@ -438,7 +438,7 @@ transformInline opts sourceDir picsRef (Image lab (src,tit))
438438transformInline opts _ _ (x@(Math _ _))
439439 | WebTeX _ <- writerHTMLMathMethod opts = do
440440 raw <- makeSelfContained Nothing $ writeHtmlInline opts x
441− return $ RawInline "html" raw
441+ return $ RawInline (Format "html") raw
442442transformInline _ _ _ x = return x
443443
444444writeHtmlInline :: WriterOptions -> Inline -> String
src/Text/Pandoc/Writers/HTML.hs+8−5
@@ -410,8 +410,9 @@ blockToHtml opts (Para lst) = do
410410blockToHtml opts (Div attr bs) = do
411411 contents <- blockListToHtml opts bs
412412 return $ addAttrs opts attr $ H.div $ nl opts >> contents >> nl opts
413−blockToHtml _ (RawBlock "html" str) = return $ preEscapedString str
414−blockToHtml _ (RawBlock _ _) = return mempty
413+blockToHtml _ (RawBlock f str)
414+ | f == Format "html" = return $ preEscapedString str
415+ | otherwise = return mempty
415416blockToHtml opts (HorizontalRule) = return $ if writerHtml5 opts then H5.hr else H.hr
416417blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
417418 let tolhs = isEnabled Ext_literate_haskell opts &&
@@ -678,12 +679,14 @@ inlineToHtml opts inline =
678679 return $ case t of
679680 InlineMath -> m
680681 DisplayMath -> brtag >> m >> brtag )
681− (RawInline "latex" str) -> case writerHTMLMathMethod opts of
682+ (RawInline f str)
683+ | f == Format "latex" ->
684+ case writerHTMLMathMethod opts of
682685 LaTeXMathML _ -> do modify (\st -> st {stMath = True})
683686 return $ toHtml str
684687 _ -> return mempty
685− (RawInline "html" str) -> return $ preEscapedString str
686− (RawInline _ _) -> return mempty
688+ | f == Format "html" -> return $ preEscapedString str
689+ | otherwise -> return mempty
687690 (Link [Str str] (s,_)) | "mailto:" `isPrefixOf` s &&
688691 s == escapeURI ("mailto" ++ str) ->
689692 -- autolink
src/Text/Pandoc/Writers/LaTeX.hs+8−5
@@ -356,8 +356,10 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
356356 Nothing -> rawCodeBlock
357357 Just h -> modify (\st -> st{ stHighlighting = True }) >>
358358 return (flush $ text h)
359−blockToLaTeX (RawBlock "latex" x) = return $ text x
360−blockToLaTeX (RawBlock _ _) = return empty
359+blockToLaTeX (RawBlock f x)
360+ | f == Format "latex" || f == Format "tex"
361+ = return $ text x
362+ | otherwise = return empty
361363blockToLaTeX (BulletList []) = return empty -- otherwise latex error
362364blockToLaTeX (BulletList lst) = do
363365 incremental <- gets stIncremental
@@ -630,9 +632,10 @@ inlineToLaTeX (Math InlineMath str) =
630632 return $ char '$' <> text str <> char '$'
631633inlineToLaTeX (Math DisplayMath str) =
632634 return $ "\\[" <> text str <> "\\]"
633−inlineToLaTeX (RawInline "latex" str) = return $ text str
634−inlineToLaTeX (RawInline "tex" str) = return $ text str
635−inlineToLaTeX (RawInline _ _) = return empty
635+inlineToLaTeX (RawInline f str)
636+ | f == Format "latex" || f == Format "tex"
637+ = return $ text str
638+ | otherwise = return empty
636639inlineToLaTeX (LineBreak) = return "\\\\"
637640inlineToLaTeX Space = return space
638641inlineToLaTeX (Link txt ('#':ident, _)) = do
src/Text/Pandoc/Writers/Man.hs+6−4
@@ -167,8 +167,9 @@ blockToMan opts (Para inlines) = do
167167 contents <- liftM vcat $ mapM (inlineListToMan opts) $
168168 splitSentences inlines
169169 return $ text ".PP" $$ contents
170−blockToMan _ (RawBlock "man" str) = return $ text str
171−blockToMan _ (RawBlock _ _) = return empty
170+blockToMan _ (RawBlock f str)
171+ | f == Format "man" = return $ text str
172+ | otherwise = return empty
172173blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *"
173174blockToMan opts (Header level _ inlines) = do
174175 contents <- inlineListToMan opts inlines
@@ -333,8 +334,9 @@ inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str
333334inlineToMan opts (Math DisplayMath str) = do
334335 contents <- inlineListToMan opts $ readTeXMath str
335336 return $ cr <> text ".RS" $$ contents $$ text ".RE"
336−inlineToMan _ (RawInline "man" str) = return $ text str
337−inlineToMan _ (RawInline _ _) = return empty
337+inlineToMan _ (RawInline f str)
338+ | f == Format "man" = return $ text str
339+ | otherwise = return empty
338340inlineToMan _ (LineBreak) = return $
339341 cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr
340342inlineToMan _ Space = return space
src/Text/Pandoc/Writers/MediaWiki.hs+8−6
@@ -107,9 +107,10 @@ blockToMediaWiki opts (Para inlines) = do
107107 then "<p>" ++ contents ++ "</p>"
108108 else contents ++ if null listLevel then "\n" else ""
109109
110−blockToMediaWiki _ (RawBlock "mediawiki" str) = return str
111−blockToMediaWiki _ (RawBlock "html" str) = return str
112−blockToMediaWiki _ (RawBlock _ _) = return ""
110+blockToMediaWiki _ (RawBlock f str)
111+ | f == Format "mediawiki" = return str
112+ | f == Format "html" = return str
113+ | otherwise = return ""
113114
114115blockToMediaWiki _ HorizontalRule = return "\n-----\n"
115116
@@ -374,9 +375,10 @@ inlineToMediaWiki _ (Str str) = return $ escapeString str
374375inlineToMediaWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
375376 -- note: str should NOT be escaped
376377
377−inlineToMediaWiki _ (RawInline "mediawiki" str) = return str
378−inlineToMediaWiki _ (RawInline "html" str) = return str
379−inlineToMediaWiki _ (RawInline _ _) = return ""
378+inlineToMediaWiki _ (RawInline f str)
379+ | f == Format "mediawiki" = return str
380+ | f == Format "html" = return str
381+ | otherwise = return ""
380382
381383inlineToMediaWiki _ (LineBreak) = return "<br />"
382384
src/Text/Pandoc/Writers/OpenDocument.hs+7−5
@@ -1,4 +1,4 @@
1−{-# LANGUAGE PatternGuards #-}
1+{-# LANGUAGE PatternGuards, OverloadedStrings #-}
22{-
33Copyright (C) 2008-2010 Andrea Rossato <andrea.rossato@ing.unitn.it>
44and John MacFarlane.
@@ -296,7 +296,9 @@ blockToOpenDocument o bs
296296 | Table c a w h r <- bs = setFirstPara >> table c a w h r
297297 | HorizontalRule <- bs = setFirstPara >> return (selfClosingTag "text:p"
298298 [ ("text:style-name", "Horizontal_20_Line") ])
299− | RawBlock _ _ <- bs = return empty
299+ | RawBlock f s <- bs = if f == "opendocument"
300+ then preformatted s
301+ else return empty
300302 | Null <- bs = return empty
301303 | otherwise = return empty
302304 where
@@ -374,9 +376,9 @@ inlineToOpenDocument o ils
374376 | Code _ s <- ils = preformatted s
375377 | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s)
376378 | Cite _ l <- ils = inlinesToOpenDocument o l
377− | RawInline "opendocument" s <- ils = preformatted s
378− | RawInline "html" s <- ils = preformatted s -- for backwards compat.
379− | RawInline _ _ <- ils = return empty
379+ | RawInline f s <- ils = if f == "opendocument" || f == "html"
380+ then preformatted s
381+ else return empty
380382 | Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l
381383 | Image _ (s,t) <- ils = return $ mkImg s t
382384 | Note l <- ils = mkNote l
src/Text/Pandoc/Writers/RST.hs+9−6
@@ -42,7 +42,7 @@ import Network.URI (isAbsoluteURI)
4242import Text.Pandoc.Pretty
4343import Control.Monad.State
4444import Control.Applicative ( (<$>) )
45−import Data.Char (isSpace)
45+import Data.Char (isSpace, toLower)
4646
4747type Refs = [([Inline], Target)]
4848
@@ -176,9 +176,11 @@ blockToRST (Para inlines)
176176 | otherwise = do
177177 contents <- inlineListToRST inlines
178178 return $ contents <> blankline
179−blockToRST (RawBlock f str) =
180− return $ blankline <> ".. raw:: " <> text f $+$
181− (nest 3 $ text str) $$ blankline
179+blockToRST (RawBlock f str)
180+ | f == "rst" = return $ text str
181+ | otherwise = return $ blankline <> ".. raw:: " <>
182+ text (map toLower $ unFormat f) $+$
183+ (nest 3 $ text str) $$ blankline
182184blockToRST HorizontalRule =
183185 return $ blankline $$ "--------------" $$ blankline
184186blockToRST (Header level _ inlines) = do
@@ -374,8 +376,9 @@ inlineToRST (Math t str) = do
374376 then blankline $$ ".. math::" $$
375377 blankline $$ nest 3 (text str) $$ blankline
376378 else blankline $$ (".. math:: " <> text str) $$ blankline
377−inlineToRST (RawInline "rst" x) = return $ text x
378−inlineToRST (RawInline _ _) = return empty
379+inlineToRST (RawInline f x)
380+ | f == "rst" = return $ text x
381+ | otherwise = return empty
379382inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para)
380383inlineToRST Space = return space
381384-- autolink
src/Text/Pandoc/Writers/RTF.hs+7−5
@@ -62,7 +62,7 @@ rtfEmbedImage x@(Image _ (src,_)) = do
6262 let raw = "{\\pict" ++ filetype ++ " " ++ concat bytes ++ "}"
6363 return $ if B.null imgdata
6464 then x
65− else RawInline "rtf" raw
65+ else RawInline (Format "rtf") raw
6666 else return x
6767rtfEmbedImage x = return x
6868
@@ -218,8 +218,9 @@ blockToRTF indent alignment (BlockQuote lst) =
218218 concatMap (blockToRTF (indent + indentIncrement) alignment) lst
219219blockToRTF indent _ (CodeBlock _ str) =
220220 rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
221−blockToRTF _ _ (RawBlock "rtf" str) = str
222−blockToRTF _ _ (RawBlock _ _) = ""
221+blockToRTF _ _ (RawBlock f str)
222+ | f == Format "rtf" = str
223+ | otherwise = ""
223224blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
224225 concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
225226blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
@@ -325,8 +326,9 @@ inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
325326inlineToRTF (Str str) = stringToRTF str
326327inlineToRTF (Math _ str) = inlineListToRTF $ readTeXMath str
327328inlineToRTF (Cite _ lst) = inlineListToRTF lst
328−inlineToRTF (RawInline "rtf" str) = str
329−inlineToRTF (RawInline _ _) = ""
329+inlineToRTF (RawInline f str)
330+ | f == Format "rtf" = str
331+ | otherwise = ""
330332inlineToRTF (LineBreak) = "\\line "
331333inlineToRTF Space = " "
332334inlineToRTF (Link text (src, _)) =
src/Text/Pandoc/Writers/Texinfo.hs+11−8
@@ -1,3 +1,4 @@
1+{-# LANGUAGE OverloadedStrings #-}
12{-
23Copyright (C) 2008-2010 John MacFarlane and Peter Wang
34
@@ -152,10 +153,11 @@ blockToTexinfo (CodeBlock _ str) = do
152153 flush (text str) $$
153154 text "@end verbatim" <> blankline
154155
155−blockToTexinfo (RawBlock "texinfo" str) = return $ text str
156−blockToTexinfo (RawBlock "latex" str) =
157− return $ text "@tex" $$ text str $$ text "@end tex"
158−blockToTexinfo (RawBlock _ _) = return empty
156+blockToTexinfo (RawBlock f str)
157+ | f == "texinfo" = return $ text str
158+ | f == "latex" || f == "tex" =
159+ return $ text "@tex" $$ text str $$ text "@end tex"
160+ | otherwise = return empty
159161
160162blockToTexinfo (BulletList lst) = do
161163 items <- mapM listItemToTexinfo lst
@@ -418,10 +420,11 @@ inlineToTexinfo (Cite _ lst) =
418420 inlineListToTexinfo lst
419421inlineToTexinfo (Str str) = return $ text (stringToTexinfo str)
420422inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str
421−inlineToTexinfo (RawInline f str) | f == "latex" || f == "tex" =
422− return $ text "@tex" $$ text str $$ text "@end tex"
423−inlineToTexinfo (RawInline "texinfo" str) = return $ text str
424−inlineToTexinfo (RawInline _ _) = return empty
423+inlineToTexinfo (RawInline f str)
424+ | f == "latex" || f == "tex" =
425+ return $ text "@tex" $$ text str $$ text "@end tex"
426+ | f == "texinfo" = return $ text str
427+ | otherwise = return empty
425428inlineToTexinfo (LineBreak) = return $ text "@*"
426429inlineToTexinfo Space = return $ char ' '
427430
src/Text/Pandoc/Writers/Textile.hs+6−8
@@ -121,10 +121,9 @@ blockToTextile opts (Para inlines) = do
121121 then "<p>" ++ contents ++ "</p>"
122122 else contents ++ if null listLevel then "\n" else ""
123123
124−blockToTextile _ (RawBlock f str) =
125− if f == "html" || f == "textile"
126− then return str
127− else return ""
124+blockToTextile _ (RawBlock f str)
125+ | f == Format "html" || f == Format "textile" = return str
126+ | otherwise = return ""
128127
129128blockToTextile _ HorizontalRule = return "<hr />\n"
130129
@@ -401,10 +400,9 @@ inlineToTextile _ (Str str) = return $ escapeStringForTextile str
401400inlineToTextile _ (Math _ str) =
402401 return $ "<span class=\"math\">" ++ escapeStringForXML str ++ "</math>"
403402
404−inlineToTextile _ (RawInline f str) =
405− if f == "html" || f == "textile"
406− then return str
407− else return ""
403+inlineToTextile _ (RawInline f str)
404+ | f == Format "html" || f == Format "textile" = return str
405+ | otherwise = return ""
408406
409407inlineToTextile _ (LineBreak) = return "\n"
410408
tests/Tests/Arbitrary.hs+4−4
@@ -41,8 +41,8 @@ arbInline :: Int -> Gen Inline
4141arbInline n = frequency $ [ (60, liftM Str realString)
4242 , (60, return Space)
4343 , (10, liftM2 Code arbAttr realString)
44− , (5, elements [ RawInline "html" "<a id=\"eek\">"
45− , RawInline "latex" "\\my{command}" ])
44+ , (5, elements [ RawInline (Format "html") "<a id=\"eek\">"
45+ , RawInline (Format "latex") "\\my{command}" ])
4646 ] ++ [ x | x <- nesters, n > 1]
4747 where nesters = [ (10, liftM Emph $ arbInlines (n-1))
4848 , (10, liftM Strong $ arbInlines (n-1))
@@ -74,9 +74,9 @@ arbBlock :: Int -> Gen Block
7474arbBlock n = frequency $ [ (10, liftM Plain $ arbInlines (n-1))
7575 , (15, liftM Para $ arbInlines (n-1))
7676 , (5, liftM2 CodeBlock arbAttr realString)
77− , (2, elements [ RawBlock "html"
77+ , (2, elements [ RawBlock (Format "html")
7878 "<div>\n*&amp;*\n</div>"
79− , RawBlock "latex"
79+ , RawBlock (Format "latex")
8080 "\\begin[opt]{env}\nhi\n{\\end{env}"
8181 ])
8282 , (5, do x1 <- choose (1 :: Int, 6)