Org reader: treat *emacs-jupyter* src blocks as code cells.

This improves support for notebook-like org files that are intended to be used
with emacs-jupyter package.

Closes: #8236
This commit is contained in:
Albert Krewinkel 2022-08-21 21:44:41 +02:00
parent e483bc9ff7
commit 5d66166088
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 20 additions and 1 deletions

View file

@ -311,7 +311,11 @@ codeBlock blockAttrs blockType = do
content <- rawBlockContent blockType
resultsContent <- option mempty babelResultsBlock
let identifier = fromMaybe mempty $ blockAttrName blockAttrs
let codeBlk = B.codeBlockWith (identifier, classes, kv) content
let classes' = case classes of
c:cs | Just c' <- T.stripPrefix "jupyter-" c ->
c' : "code" : cs
_ -> classes
let codeBlk = B.codeBlockWith (identifier, classes', kv) content
let wrap = maybe pure addCaption (blockAttrCaption blockAttrs)
return $
(if exportsCode kv then wrap codeBlk else mempty) <>

15
test/command/8236.md Normal file
View file

@ -0,0 +1,15 @@
```
% pandoc -f org -t native
#+begin_src jupyter-python :session py :display plain
import pandas as pd
df = pd.read_csv('weight.csv', parse_dates=['Date'], index_col=0)
#+end_src
^D
[ CodeBlock
( ""
, [ "python" , "code" ]
, [ ( "session" , "py" ) , ( "display" , "plain" ) ]
)
"import pandas as pd\ndf = pd.read_csv('weight.csv', parse_dates=['Date'], index_col=0)\n"
]
```