Force inline code blocks to honor export options.
`exportsCode` is moved from `Blocks.hs` to `Shared.hs` and exported accordingly.
This commit is contained in:
parent
3d6aa51b6d
commit
6e8f31dab1
4 changed files with 16 additions and 6 deletions
|
@ -40,7 +40,7 @@ import Text.Pandoc.Readers.Org.Meta (metaExport, metaKey, metaLine)
|
|||
import Text.Pandoc.Readers.Org.ParserState
|
||||
import Text.Pandoc.Readers.Org.Parsing
|
||||
import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
|
||||
originalLang, translateLang)
|
||||
originalLang, translateLang, exportsCode)
|
||||
|
||||
import Text.Pandoc.Builder (Blocks, Inlines)
|
||||
import Text.Pandoc.Class (PandocMonad)
|
||||
|
@ -314,9 +314,6 @@ codeBlock blockAttrs blockType = do
|
|||
labelledBlock :: F Inlines -> F Blocks
|
||||
labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
|
||||
|
||||
exportsCode :: [(String, String)] -> Bool
|
||||
exportsCode = maybe True (`elem` ["code", "both"]) . lookup "exports"
|
||||
|
||||
exportsResults :: [(String, String)] -> Bool
|
||||
exportsResults = maybe False (`elem` ["results", "both"]) . lookup "exports"
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker)
|
|||
import Text.Pandoc.Readers.Org.ParserState
|
||||
import Text.Pandoc.Readers.Org.Parsing
|
||||
import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,
|
||||
originalLang, translateLang)
|
||||
originalLang, translateLang, exportsCode)
|
||||
|
||||
import Text.Pandoc.Builder (Inlines)
|
||||
import qualified Text.Pandoc.Builder as B
|
||||
|
@ -529,7 +529,8 @@ inlineCodeBlock = try $ do
|
|||
inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
|
||||
let attrClasses = [translateLang lang]
|
||||
let attrKeyVal = originalLang lang <> opts
|
||||
returnF $ B.codeWith ("", attrClasses, attrKeyVal) inlineCode
|
||||
let codeInlineBlck = B.codeWith ("", attrClasses, attrKeyVal) inlineCode
|
||||
returnF $ (if exportsCode opts then codeInlineBlck else mempty)
|
||||
where
|
||||
inlineBlockOption :: PandocMonad m => OrgParser m (String, String)
|
||||
inlineBlockOption = try $ do
|
||||
|
|
|
@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Org.Shared
|
|||
, isImageFilename
|
||||
, originalLang
|
||||
, translateLang
|
||||
, exportsCode
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
|
@ -96,3 +97,6 @@ translateLang cs =
|
|||
"sh" -> "bash"
|
||||
"sqlite" -> "sql"
|
||||
_ -> cs
|
||||
|
||||
exportsCode :: [(String, String)] -> Bool
|
||||
exportsCode = maybe True (`elem` ["code", "both"]) . lookup "exports"
|
||||
|
|
8
test/command/4885.md
Normal file
8
test/command/4885.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
```
|
||||
% pandoc -f org -t markdown
|
||||
This won't show the command.
|
||||
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}$$
|
||||
^D
|
||||
This won\'t show the command.
|
||||
$$\int_{0}^{\infty }{\sin \left({{e^{x}}\over{\pi}}\right)\;dx}$$
|
||||
```
|
Loading…
Add table
Reference in a new issue