parent
4a2a068a8b
commit
a965111680
4 changed files with 55 additions and 8 deletions
|
@ -246,6 +246,7 @@ extra-source-files:
|
|||
test/command/bar.tex
|
||||
test/command/bar-endinput.tex
|
||||
test/command/yaml-metadata.yaml
|
||||
test/command/7813-meta.yaml
|
||||
test/command/3510-subdoc.org
|
||||
test/command/3510-export.latex
|
||||
test/command/3510-src.hs
|
||||
|
|
|
@ -81,8 +81,12 @@ yamlToMeta opts mbfp bstr = do
|
|||
oldPos <- getPosition
|
||||
setPosition $ initialPos (fromMaybe "" mbfp)
|
||||
meta <- yamlBsToMeta (fmap B.toMetaValue <$> parseBlocks) bstr
|
||||
checkNotes
|
||||
setPosition oldPos
|
||||
return $ runF meta defaultParserState
|
||||
st <- getState
|
||||
let result = runF meta st
|
||||
reportLogMessages
|
||||
return result
|
||||
parsed <- readWithM parser def{ stateOptions = opts } ("" :: Text)
|
||||
case parsed of
|
||||
Right result -> return result
|
||||
|
@ -103,7 +107,11 @@ yamlToRefs idpred opts mbfp bstr = do
|
|||
Nothing -> return ()
|
||||
Just fp -> setPosition $ initialPos fp
|
||||
refs <- yamlBsToRefs (fmap B.toMetaValue <$> parseBlocks) idpred bstr
|
||||
return $ runF refs defaultParserState
|
||||
checkNotes
|
||||
st <- getState
|
||||
let result = runF refs st
|
||||
reportLogMessages
|
||||
return result
|
||||
parsed <- readWithM parser def{ stateOptions = opts } ("" :: Text)
|
||||
case parsed of
|
||||
Right result -> return result
|
||||
|
@ -308,7 +316,17 @@ parseMarkdown = do
|
|||
optional titleBlock
|
||||
blocks <- parseBlocks
|
||||
st <- getState
|
||||
-- check for notes with no corresponding note references
|
||||
checkNotes
|
||||
let doc = runF (do Pandoc _ bs <- B.doc <$> blocks
|
||||
meta <- stateMeta' st
|
||||
return $ Pandoc meta bs) st
|
||||
reportLogMessages
|
||||
return doc
|
||||
|
||||
-- check for notes with no corresponding note references
|
||||
checkNotes :: PandocMonad m => MarkdownParser m ()
|
||||
checkNotes = do
|
||||
st <- getState
|
||||
let notesUsed = stateNoteRefs st
|
||||
let notesDefined = M.keys (stateNotes' st)
|
||||
mapM_ (\n -> unless (n `Set.member` notesUsed) $
|
||||
|
@ -317,11 +335,7 @@ parseMarkdown = do
|
|||
Nothing -> throwError $
|
||||
PandocShouldNeverHappenError "note not found")
|
||||
notesDefined
|
||||
let doc = runF (do Pandoc _ bs <- B.doc <$> blocks
|
||||
meta <- stateMeta' st
|
||||
return $ Pandoc meta bs) st
|
||||
reportLogMessages
|
||||
return doc
|
||||
|
||||
|
||||
referenceKey :: PandocMonad m => MarkdownParser m (F Blocks)
|
||||
referenceKey = try $ do
|
||||
|
|
6
test/command/7813-meta.yaml
Normal file
6
test/command/7813-meta.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
abstract: |
|
||||
a footnote[^1] in abstract.
|
||||
|
||||
[^1]: content
|
||||
...
|
26
test/command/7813.md
Normal file
26
test/command/7813.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
```
|
||||
% pandoc --metadata-file command/7813-meta.yaml -t native -s
|
||||
Hi
|
||||
^D
|
||||
Pandoc
|
||||
Meta
|
||||
{ unMeta =
|
||||
fromList
|
||||
[ ( "abstract"
|
||||
, MetaBlocks
|
||||
[ Para
|
||||
[ Str "a"
|
||||
, Space
|
||||
, Str "footnote"
|
||||
, Note [ Para [ Str "content" ] ]
|
||||
, Space
|
||||
, Str "in"
|
||||
, Space
|
||||
, Str "abstract."
|
||||
]
|
||||
]
|
||||
)
|
||||
]
|
||||
}
|
||||
[ Para [ Str "Hi" ] ]
|
||||
```
|
Loading…
Add table
Reference in a new issue