aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-09-22 19:56:22 -0700
committerJohn MacFarlane <[email protected]>2022-09-22 19:56:22 -0700
commitbb8a0464644dc0238d3314e5f2470cbdd1636b83 (patch)
tree7099f7658aa1612203ab7515a7e2c1474cf141cc /src
parent8ad64a831808d7d062279c9e0429a1b21a7075a9 (diff)
Org writer: pass through unknown languages in code blocks.
Previously we whitelisted the language for begin_src, and produced begin_example if the language was not found on the whitelist. Closes #8278.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Org.hs56
1 files changed, 4 insertions, 52 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
index 936e2aa87..739ddf32f 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -18,7 +18,7 @@ Org-Mode: <http://orgmode.org>
module Text.Pandoc.Writers.Org (writeOrg) where
import Control.Monad.State.Strict
import Data.Char (isAlphaNum, isDigit)
-import Data.List (intersect, intersperse, partition, transpose)
+import Data.List (intersperse, partition, transpose)
import Data.List.NonEmpty (nonEmpty)
import Data.Text (Text)
import qualified Data.Text as T
@@ -166,12 +166,11 @@ blockToOrg (CodeBlock (ident,classes,kvs) str) = do
then " +n" <> startnum
else " -n" <> startnum
else ""
- let at = map pandocLangToOrg classes `intersect` orgLangIdentifiers
- let lang = case at of
+ let lang = case filter (`notElem` ["example","code"]) classes of
[] -> Nothing
l:_ -> if "code" `elem` classes -- check for ipynb code cell
- then Just ("jupyter-" <> l)
- else Just l
+ then Just ("jupyter-" <> pandocLangToOrg l)
+ else Just (pandocLangToOrg l)
let args = mconcat $
[ " :" <> k <> " " <> v
| (k, v) <- kvs, k `notElem` ["startFrom", "org-language"]]
@@ -528,53 +527,6 @@ pandocLangToOrg cs =
"bash" -> "sh"
_ -> cs
--- | List of language identifiers recognized by org-mode.
--- See <https://orgmode.org/manual/Languages.html>.
-orgLangIdentifiers :: [Text]
-orgLangIdentifiers =
- [ "asymptote"
- , "lisp"
- , "awk"
- , "lua"
- , "C"
- , "matlab"
- , "C++"
- , "mscgen"
- , "clojure"
- , "ocaml"
- , "css"
- , "octave"
- , "D"
- , "org"
- , "ditaa"
- , "oz"
- , "calc"
- , "perl"
- , "emacs-lisp"
- , "plantuml"
- , "eshell"
- , "processing"
- , "fortran"
- , "python"
- , "gnuplot"
- , "R"
- , "screen"
- , "ruby"
- , "dot"
- , "sass"
- , "haskell"
- , "scheme"
- , "java"
- , "sed"
- , "js"
- , "sh"
- , "latex"
- , "sql"
- , "ledger"
- , "sqlite"
- , "lilypond"
- , "vala" ]
-
-- taken from oc-csl.el in the org source tree:
locmap :: LocatorMap
locmap = LocatorMap $ M.fromList