git.iko.soy/typeable/pandoc
on master help sign in
Force inline code blocks to honor export options.

`exportsCode` is moved from `Blocks.hs` to `Shared.hs` and exported accordingly.

commit6e8f31dab16472cb7cf14aac88cf2e383bdbc5ec authorleungbk <bkleung89@gmail.com> dateTue 25 Sep 2018, 18:21 (8 years ago) parent3d6aa51
4 files changed+16−6
src/Text/Pandoc/Readers/Org/Blocks.hs+1−4 src/Text/Pandoc/Readers/Org/Inlines.hs+3−2 src/Text/Pandoc/Readers/Org/Shared.hs+4 test/command/4885.md+8
src/Text/Pandoc/Readers/Org/Blocks.hs+1−4
@@ -40,7 +40,7 @@ import Text.Pandoc.Readers.Org.Meta (metaExport, metaKey, metaLine)
4040import Text.Pandoc.Readers.Org.ParserState
4141import Text.Pandoc.Readers.Org.Parsing
4242import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
43− originalLang, translateLang)
43+ originalLang, translateLang, exportsCode)
4444
4545import Text.Pandoc.Builder (Blocks, Inlines)
4646import Text.Pandoc.Class (PandocMonad)
@@ -314,9 +314,6 @@ codeBlock blockAttrs blockType = do
314314 labelledBlock :: F Inlines -> F Blocks
315315 labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
316316
317− exportsCode :: [(String, String)] -> Bool
318− exportsCode = maybe True (`elem` ["code", "both"]) . lookup "exports"
319−
320317 exportsResults :: [(String, String)] -> Bool
321318 exportsResults = maybe False (`elem` ["results", "both"]) . lookup "exports"
322319
src/Text/Pandoc/Readers/Org/Inlines.hs+3−2
@@ -39,7 +39,7 @@ import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker)
3939import Text.Pandoc.Readers.Org.ParserState
4040import Text.Pandoc.Readers.Org.Parsing
4141import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
42− originalLang, translateLang)
42+ originalLang, translateLang, exportsCode)
4343
4444import Text.Pandoc.Builder (Inlines)
4545import qualified Text.Pandoc.Builder as B
@@ -529,7 +529,8 @@ inlineCodeBlock = try $ do
529529 inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
530530 let attrClasses = [translateLang lang]
531531 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)
533534 where
534535 inlineBlockOption :: PandocMonad m => OrgParser m (String, String)
535536 inlineBlockOption = try $ do
src/Text/Pandoc/Readers/Org/Shared.hs+4
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Org.Shared
3232 , isImageFilename
3333 , originalLang
3434 , translateLang
35+ , exportsCode
3536 ) where
3637
3738import Prelude
@@ -96,3 +97,6 @@ translateLang cs =
9697 "sh" -> "bash"
9798 "sqlite" -> "sql"
9899 _ -> 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+```