aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Metadata.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-11-21yamlBsToRefs: allow multiple YAML documents.John MacFarlane1-2/+2
Some people use `---` as the end delimiter in YAML bibliography files, which causes the `yaml` library to emit an error unless we explicitly allow multiple YAML documents (and just consider the first). In T.P.Readers.Metadata
2021-11-09Accept empty `--metadata-file`.John MacFarlane1-0/+1
Closes #7675. This is a regression from 2.15 behavior.
2021-10-27Switch back from HsYAML to yaml.John MacFarlane1-110/+58
Reasons: - Performance: HsYAML is around 20 times slower in parsing large YAML bibliographies (#6084). - An issue was submitted to HsYAML, but it hasn't gotten any attention. HsYAML seems borderline unmaintained; it hasn't had a commit in over a year. - Unfortunately this goes back on our attempts to free ourselves from C dependencies (#4535). But I don't see a better alternative until a better pure Haskell parser is available. Closes #6084. Notes: - We've removed the FromYAML instances for all types that had them, since this is a HsYAML-specific typeclass [API change]. (The yaml package just uses From/ToJSON.) - Unlike HsYAML (in the configuration we were using), yaml parses 'Y', 'N', 'Yes', 'No', 'On', 'Off' as boolean values. Users may need to quote these when they are meant to be interpreted as strings. Similarly, 'null' is parsed as a YAML null value (and will be treated as an empty string by pandoc rather than the string 'null'). Quoting it will force it to be interpreted as a string. - Some tests had to be adjusted accordingly. - Pandoc now behaves better when the YAML metadata contains escaping errors: instead of just falling back on treating the section as a table, it raises a YAML parsing error.
2021-06-22Fix regression with comment-only YAML metadata blocks.John MacFarlane1-0/+3
Closes #7400.
2021-05-12Fix source position reporting for YAML bibliographies.John MacFarlane1-2/+6
Closes #7273.
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane1-13/+13
Previously, when multiple file arguments were provided, pandoc simply concatenated them and passed the contents to the readers, which took a Text argument. As a result, the readers had no way of knowing which file was the source of any particular bit of text. This meant that we couldn't report accurate source positions on errors or include accurate source positions as attributes in the AST. More seriously, it meant that we couldn't resolve resource paths relative to the files containing them (see e.g. #5501, #6632, #6384, #3752). Add Text.Pandoc.Sources (exported module), with a `Sources` type and a `ToSources` class. A `Sources` wraps a list of `(SourcePos, Text)` pairs. [API change] A parsec `Stream` instance is provided for `Sources`. The module also exports versions of parsec's `satisfy` and other Char parsers that track source positions accurately from a `Sources` stream (or any instance of the new `UpdateSourcePos` class). Text.Pandoc.Parsing now exports these modified Char parsers instead of the ones parsec provides. Modified parsers to use a `Sources` as stream [API change]. The readers that previously took a `Text` argument have been modified to take any instance of `ToSources`. So, they may still be used with a `Text`, but they can also be used with a `Sources` object. In Text.Pandoc.Error, modified the constructor PandocParsecError to take a `Sources` rather than a `Text` as first argument, so parse error locations can be accurately reported. T.P.Error: showPos, do not print "-" as source name.
2021-03-20Move yamlMetaBlock from Markdown reader to T.P.Readers.Metadata.John MacFarlane1-0/+20
2021-03-20T.P.Readers.Metadata: made `yamlBsToMeta`, `yamlBsToRefs` polymorphic...John MacFarlane1-15/+15
on the parser state, instead of requiring ParserState. [API change]
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-11-10Remove redundant bracket.John MacFarlane1-1/+1
2020-11-10Fix corner case in YAML metadata parsing.John MacFarlane1-1/+4
Previously YAML metadata would sometimes not get recognized if a field ended with a newline followed by spaces. Closes #6823.
2020-11-07Lint code in PRs and when committing to master (#6790)Albert Krewinkel1-1/+1
* Remove unused LANGUAGE pragmata * Apply HLint suggestions * Configure HLint to ignore some warnings * Lint code when committing to master
2020-10-08Qualify some uses of fail to avoid ambiguity.John MacFarlane1-6/+6
2020-10-07Remove redundant import.John MacFarlane1-1/+0
2020-10-07Raise informative errors when YAML metadata parsing fails.John MacFarlane1-26/+14
Closes #6730. Previously the command would succeed, returning empty metadata, with no errors or warnings. API changes: - Remove now unused CouldNotParseYamlMetadata constructor for LogMessage (T.P.Logging). - Add 'Maybe FilePath' parameter to yamlToMeta in T.P.Readers.Markdown.
2020-10-05Fixed regresison in last commit.John MacFarlane1-21/+42
Parsing of YAML bibliographies was broken; this fixes it.
2020-10-05Add yamlToRefs, yamlBsToRefs.John MacFarlane1-1/+44
T.P.Readers.Markdown now exports yamlToRefs. [API change] T.P.Readers.Metadata exports yamlBsToRefs. [API change] These allow specifying an id filter so we parse only references that are used in the document. Improves timing with a 3M yaml references file from 36s to 17s.
2020-06-29Clean up T.P.R.MetadataNikolay Yakimov1-36/+23
2020-06-29Unify defaults and markdown metadata parsersNikolay Yakimov1-13/+15
2020-06-28Remove obsolete RelaxedPolyRec extension (#6487)Nikolay Yakimov1-1/+0
2020-03-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel1-1/+1
This should speed-up recompilation after changes in `Text.Pandoc.Class`, as the number of modules affected by a change will be smaller in general. It also offers faster insights into the parts of `T.P.Class` used within a module.
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel1-2/+0
* Use implicit Prelude The previous behavior was introduced as a fix for #4464. It seems that this change alone did not fix the issue, and `stack ghci` and `cabal repl` only work with GHC 8.4.1 or newer, as no custom Prelude is loaded for these versions. Given this, it seems cleaner to revert to the implicit Prelude. * PandocMonad: remove outdated check for base version Only base versions 4.9 and later are supported, the check for `MIN_VERSION_base(4,8,0)` is therefore unnecessary. * Always use custom prelude Previously, the custom prelude was used only with older GHC versions, as a workaround for problems with ghci. The ghci problems are resolved by replacing package `base` with `base-noprelude`, allowing for consistent use of the custom prelude across all GHC versions.
2020-03-13Update copyright year (#6186)Albert Krewinkel1-1/+1
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-17Revert "Allow specifying string value in metadata using `!!literal` tag."John MacFarlane1-6/+4
This reverts commit 3493d6afaa6586c46898cf8bdb0c45bb70d31f28. This might be worth considering in the future, but let's not do it yet...the additional complexity needs a better justification.
2020-02-17Allow specifying string value in metadata using `!!literal` tag.John MacFarlane1-4/+6
This is experimental. Normally metadata values are interpreted as markdown, but if the !!literal tag is used they will be interpreted as plain strings. We need to consider whether this can still be implemented if we switch back from HsYAML to yaml for performance reasons.
2020-02-07Apply linter suggestions. Add fix_spacing to lint target in Makefile.John MacFarlane1-9/+6
2020-02-07Resolve HLint warningsAlbert Krewinkel1-5/+1
All warnings are either fixed or, if more appropriate, HLint is configured to ignore them. HLint suggestions remain. * Ignore "Use camelCase" warnings in Lua and legacy code * Fix or ignore remaining HLint warnings * Remove redundant brackets * Remove redundant `return`s * Remove redundant as-pattern * Fuse mapM_/map * Use `.` to shorten code * Remove redundant `fmap` * Remove unused LANGUAGE pragmas * Hoist `not` in Text.Pandoc.App * Use fewer imports for `Text.DocTemplates` * Remove redundant `do`s * Remove redundant `$`s * Jira reader: remove unnecessary parentheses
2019-11-24Add unexported Text.Pandoc.Readers.Metadata.John MacFarlane1-0/+140
For YAML metadata parsing. A step in the direction of #5914. No API change.