aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-04-06 18:24:54 -0700
committerJohn MacFarlane <[email protected]>2024-04-06 18:24:54 -0700
commitc0768e87cf329b4ba6ee6e0da5eed8bfb5a92d4a (patch)
tree72ebcd704eb5bcf043fe53564c0f1bc5b1e882ef
parent5e507024b9bb83fc04747f6251e92fa1d15c6aea (diff)
Org reader: Fix treatment of `id` property under heading.
Cloess #9639.
-rw-r--r--src/Text/Pandoc/Readers/Org/DocumentTree.hs8
-rw-r--r--test/command/9639.md11
2 files changed, 16 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Org/DocumentTree.hs b/src/Text/Pandoc/Readers/Org/DocumentTree.hs
index 488e90082..2835b5967 100644
--- a/src/Text/Pandoc/Readers/Org/DocumentTree.hs
+++ b/src/Text/Pandoc/Readers/Org/DocumentTree.hs
@@ -16,7 +16,7 @@ module Text.Pandoc.Readers.Org.DocumentTree
) where
import Control.Arrow ((***), first)
-import Control.Monad (guard)
+import Control.Monad (guard, mplus)
import Data.List (intersperse)
import Data.Maybe (mapMaybe)
import Data.Text (Text)
@@ -317,10 +317,12 @@ propertiesToAttr properties =
let
toTextPair = fromKey *** fromValue
customIdKey = toPropertyKey "custom_id"
+ idKey = toPropertyKey "id"
classKey = toPropertyKey "class"
unnumberedKey = toPropertyKey "unnumbered"
- specialProperties = [customIdKey, classKey, unnumberedKey]
- id' = maybe mempty fromValue . lookup customIdKey $ properties
+ specialProperties = [customIdKey, idKey, classKey, unnumberedKey]
+ id' = maybe mempty fromValue $
+ (lookup customIdKey properties `mplus` lookup idKey properties)
cls = maybe mempty fromValue . lookup classKey $ properties
kvs' = map toTextPair . filter ((`notElem` specialProperties) . fst)
$ properties
diff --git a/test/command/9639.md b/test/command/9639.md
new file mode 100644
index 000000000..e7107a559
--- /dev/null
+++ b/test/command/9639.md
@@ -0,0 +1,11 @@
+```
+% pandoc -f org -t native
+#+title: repro
+
+* heading-name
+:PROPERTIES:
+:ID: 123abc
+:END:
+^D
+[ Header 1 ( "123abc" , [] , [] ) [ Str "heading-name" ] ]
+```