Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pandoc
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jgm
pandoc
Commits
2530422b
Commit
2530422b
authored
3 weeks ago
by
John MacFarlane
Browse files
Options
Downloads
Patches
Plain Diff
Give better position information when YAML metadata parsing fails...
with a YAML exception. See #10231.
parent
dbe2495a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Text/Pandoc/Readers/Metadata.hs
+4
-2
4 additions, 2 deletions
src/Text/Pandoc/Readers/Metadata.hs
with
4 additions
and
2 deletions
src/Text/Pandoc/Readers/Metadata.hs
+
4
−
2
View file @
2530422b
...
...
@@ -44,9 +44,9 @@ yamlBsToMeta :: (PandocMonad m, HasLastStrPosition st)
->
B
.
ByteString
->
ParsecT
Sources
st
m
(
Future
st
Meta
)
yamlBsToMeta
pMetaValue
bstr
=
do
pos
<-
getPosition
case
decodeAllWithWarnings
bstr
of
Right
(
warnings
,
xs
)
->
do
pos
<-
getPosition
mapM_
(
\
(
Yaml
.
DuplicateKey
jpath
)
->
report
(
YamlWarning
pos
$
"Duplicate key: "
<>
T
.
pack
(
formatRelativePath
jpath
)))
...
...
@@ -57,7 +57,9 @@ yamlBsToMeta pMetaValue bstr = do
[]
->
return
.
return
$
mempty
_
->
Prelude
.
fail
"expected YAML object"
Left
err'
->
do
let
msg
=
T
.
pack
$
Yaml
.
prettyPrintParseException
err'
let
msg
=
T
.
pack
$
"Error parsing YAML metadata at "
<>
show
pos
<>
":
\n
"
<>
Yaml
.
prettyPrintParseException
err'
throwError
$
PandocParseError
$
if
"did not find expected key"
`
T
.
isInfixOf
`
msg
then
msg
<>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment