Org reader: allow an initial :PROPERTIES: drawer to add to metadata.
Closes #7520.
This commit is contained in:
parent
64d55d5a7d
commit
c712d13b67
3 changed files with 33 additions and 3 deletions
|
@ -41,6 +41,7 @@ documentTree :: PandocMonad m
|
|||
-> OrgParser m (F Inlines)
|
||||
-> OrgParser m (F Headline)
|
||||
documentTree blocks inline = do
|
||||
properties <- option mempty propertiesDrawer
|
||||
initialBlocks <- blocks
|
||||
headlines <- sequence <$> manyTill (headline blocks inline 1) eof
|
||||
title <- fmap docTitle . orgStateMeta <$> getState
|
||||
|
@ -54,7 +55,7 @@ documentTree blocks inline = do
|
|||
, headlineText = B.fromList title'
|
||||
, headlineTags = mempty
|
||||
, headlinePlanning = emptyPlanning
|
||||
, headlineProperties = mempty
|
||||
, headlineProperties = properties
|
||||
, headlineContents = initialBlocks'
|
||||
, headlineChildren = headlines'
|
||||
}
|
||||
|
@ -163,8 +164,15 @@ unprunedHeadlineToBlocks hdln st =
|
|||
in if not usingSelectedTags ||
|
||||
any (`Set.member` orgStateSelectTags st) (headlineTags rootNode')
|
||||
then do headlineBlocks <- headlineToBlocks rootNode'
|
||||
-- add metadata from root node :PROPERTIES:
|
||||
updateState $ \s ->
|
||||
s{ orgStateMeta = foldr
|
||||
(\(PropertyKey k, PropertyValue v) m ->
|
||||
B.setMeta k v <$> m)
|
||||
(orgStateMeta s)
|
||||
(headlineProperties rootNode') }
|
||||
-- ignore first headline, it's the document's title
|
||||
return . drop 1 . B.toList $ headlineBlocks
|
||||
return $ drop 1 $ B.toList headlineBlocks
|
||||
else do headlineBlocks <- mconcat <$> mapM headlineToBlocks
|
||||
(headlineChildren rootNode')
|
||||
return . B.toList $ headlineBlocks
|
||||
|
|
|
@ -238,7 +238,7 @@ tests =
|
|||
, " :setting: foo"
|
||||
, " :END:"
|
||||
] =?>
|
||||
(mempty::Blocks)
|
||||
(setMeta "setting" ("foo" :: T.Text) (doc mempty))
|
||||
|
||||
, "Logbook drawer" =:
|
||||
T.unlines [ " :LogBook:"
|
||||
|
|
22
test/command/7520.md
Normal file
22
test/command/7520.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
```
|
||||
% pandoc -f org -t native -s
|
||||
:PROPERTIES:
|
||||
:ID: d5b18943-98a3-4b2a-a545-41d17bf50f3e
|
||||
:END:
|
||||
#+title: Common Ground
|
||||
^D
|
||||
Pandoc
|
||||
Meta
|
||||
{ unMeta =
|
||||
fromList
|
||||
[ ( "id"
|
||||
, MetaString "d5b18943-98a3-4b2a-a545-41d17bf50f3e"
|
||||
)
|
||||
, ( "title"
|
||||
, MetaInlines [ Str "Common" , Space , Str "Ground" ]
|
||||
)
|
||||
]
|
||||
}
|
||||
[]
|
||||
|
||||
```
|
Loading…
Reference in a new issue