git.iko.soy/typeable/pandoc
on master help sign in
Force inline code blocks to honor export options.
6e8f31dleungbk
src/Text/Pandoc/Readers/Org/Blocks.hs+1−4
@@ -40,7 +40,7 @@ import Text.Pandoc.Readers.Org.Meta (metaExport, metaKey, metaLine)
40import Text.Pandoc.Readers.Org.ParserState
40import Text.Pandoc.Readers.Org.ParserState
41import Text.Pandoc.Readers.Org.Parsing
41import Text.Pandoc.Readers.Org.Parsing
42import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
42import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
43− originalLang, translateLang)
43+ originalLang, translateLang, exportsCode)
44
44
45import Text.Pandoc.Builder (Blocks, Inlines)
45import Text.Pandoc.Builder (Blocks, Inlines)
46import Text.Pandoc.Class (PandocMonad)
46import Text.Pandoc.Class (PandocMonad)
@@ -314,9 +314,6 @@ codeBlock blockAttrs blockType = do
314 labelledBlock :: F Inlines -> F Blocks
314 labelledBlock :: F Inlines -> F Blocks
315 labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
315 labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
316
316
317− exportsCode :: [(String, String)] -> Bool
318− exportsCode = maybe True (`elem` ["code", "both"]) . lookup "exports"
319−
320 exportsResults :: [(String, String)] -> Bool
317 exportsResults :: [(String, String)] -> Bool
321 exportsResults = maybe False (`elem` ["results", "both"]) . lookup "exports"
318 exportsResults = maybe False (`elem` ["results", "both"]) . lookup "exports"
322
319
src/Text/Pandoc/Readers/Org/Inlines.hs+3−2
@@ -39,7 +39,7 @@ import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker)
39import Text.Pandoc.Readers.Org.ParserState
39import Text.Pandoc.Readers.Org.ParserState
40import Text.Pandoc.Readers.Org.Parsing
40import Text.Pandoc.Readers.Org.Parsing
41import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
41import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
42− originalLang, translateLang)
42+ originalLang, translateLang, exportsCode)
43
43
44import Text.Pandoc.Builder (Inlines)
44import Text.Pandoc.Builder (Inlines)
45import qualified Text.Pandoc.Builder as B
45import qualified Text.Pandoc.Builder as B
@@ -529,7 +529,8 @@ inlineCodeBlock = try $ do
529 inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
529 inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
530 let attrClasses = [translateLang lang]
530 let attrClasses = [translateLang lang]
531 let attrKeyVal = originalLang lang <> opts
531 let attrKeyVal = originalLang lang <> opts
532− returnF $ B.codeWith ("", attrClasses, attrKeyVal) inlineCode
532+ let codeInlineBlck = B.codeWith ("", attrClasses, attrKeyVal) inlineCode
533+ returnF $ (if exportsCode opts then codeInlineBlck else mempty)
533 where
534 where
534 inlineBlockOption :: PandocMonad m => OrgParser m (String, String)
535 inlineBlockOption :: PandocMonad m => OrgParser m (String, String)
535 inlineBlockOption = try $ do
536 inlineBlockOption = try $ do
src/Text/Pandoc/Readers/Org/Shared.hs+4
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Org.Shared
32 , isImageFilename
32 , isImageFilename
33 , originalLang
33 , originalLang
34 , translateLang
34 , translateLang
35+ , exportsCode
35 ) where
36 ) where
36
37
37import Prelude
38import Prelude
@@ -96,3 +97,6 @@ translateLang cs =
96 "sh" -> "bash"
97 "sh" -> "bash"
97 "sqlite" -> "sql"
98 "sqlite" -> "sql"
98 _ -> cs
99 _ -> cs
100+
101+exportsCode :: [(String, String)] -> Bool
102+exportsCode = maybe True (`elem` ["code", "both"]) . lookup "exports"
test/command/4885.mdnew file+8
@@ -0,0 +1,8 @@
1+```
2+% pandoc -f org -t markdown
3+This won't show the command.
4+src_maxima[:exports none :results raw]{tex('integrate(sin((e^x)/pi),x,0,inf));} $$\int_{0}^{\infty }{\sin \left({{e^{x}}\over{\pi}}\right)\;dx}$$
5+^D
6+This won\'t show the command.
7+$$\int_{0}^{\infty }{\sin \left({{e^{x}}\over{\pi}}\right)\;dx}$$
8+```