aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Logging.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-10-27Switch back from HsYAML to yaml.John MacFarlane1-8/+0
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-09-08Logging: add NotUTF8Encoded constructor to LogMessage.John MacFarlane1-0/+7
[API change]
2021-08-17Rename TemplateWarning -> PowerpointTemplateWarning.John MacFarlane1-5/+5
@undergroundquizscene - I think TemplateWarning is apt to be confusing, since this actually doesn't have anything to do with what we call 'templates' in pandoc. Hence the change to a powerpoint-specific name.
2021-08-17Add TemplateWarning log message type [API change]Emily Bourke1-0/+6
This is a general warning to use for messages about templates.
2021-05-25Logging: remove single quotes around paths in messages.John MacFarlane1-6/+6
We weren't doing it consistently and it seems unnecessary.
2021-05-25Logging: add LoadedResource constructor to LogMessage.John MacFarlane1-0/+7
[API change] This is for INFO-level messages telling where image data has been loaded from. (This can vary because of the resource path.)
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane1-3/+5
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-10HTML writer: Add warnings on duplicate attribute values.John MacFarlane1-0/+8
This prevents emitting invalid HTML. Ultimately it would be good to prevent this in the types themselves, but this is better for now. T.P.Logging: Add DuplicateAttribute constructor to LogMessage. [API change]
2021-03-05Logging: Add EnvironmentVariableUndefined constructor to LogMessage.John MacFarlane1-0/+6
[API change]
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-11-14Markdown writer: default to using ATX headings.Aner Lucero1-36/+49
Previously we used Setext (underlined) headings by default. The default is now ATX (`##` style). * Add the `--markdown-headings=atx|setext` option. * Deprecate `--atx-headers`. * Add constructor 'ATXHeadingInLHS` constructor to `LogMessage` [API change]. * Support `markdown-headings` in defaults files. * Document new options in MANUAL. Closes #6662.
2020-10-07Raise informative errors when YAML metadata parsing fails.John MacFarlane1-10/+0
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-09-21Add built-in citation support using new citeproc library.John MacFarlane1-0/+5
This deprecates the use of the external pandoc-citeproc filter; citation processing is now built in to pandoc. * Add dependency on citeproc library. * Add Text.Pandoc.Citeproc module (and some associated unexported modules under Text.Pandoc.Citeproc). Exports `processCitations`. [API change] * Add data files needed for Text.Pandoc.Citeproc: default.csl in the data directory, and a citeproc directory that is just used at compile-time. Note that we've added file-embed as a mandatory rather than a conditional depedency, because of the biblatex localization files. We might eventually want to use readDataFile for this, but it would take some code reorganization. * Text.Pandoc.Loging: Add `CiteprocWarning` to `LogMessage` and use it in `processCitations`. [API change] * Add tests from the pandoc-citeproc package as command tests (including some tests pandoc-citeproc did not pass). * Remove instructions for building pandoc-citeproc from CI and release binary build instructions. We will no longer distribute pandoc-citeproc. * Markdown reader: tweak abbreviation support. Don't insert a nonbreaking space after a potential abbreviation if it comes right before a note or citation. This messes up several things, including citeproc's moving of note citations. * Add `csljson` as and input and output format. This allows pandoc to convert between `csljson` and other bibliography formats, and to generate formatted versions of CSL JSON bibliographies. * Add module Text.Pandoc.Writers.CslJson, exporting `writeCslJson`. [API change] * Add module Text.Pandoc.Readers.CslJson, exporting `readCslJson`. [API change] * Added `bibtex`, `biblatex` as input formats. This allows pandoc to convert between BibLaTeX and BibTeX and other bibliography formats, and to generated formatted versions of BibTeX/BibLaTeX bibliographies. * Add module Text.Pandoc.Readers.BibTeX, exporting `readBibTeX` and `readBibLaTeX`. [API change] * Make "standalone" implicit if output format is a bibliography format. This is needed because pandoc readers for bibliography formats put the bibliographic information in the `references` field of metadata; and unless standalone is specified, metadata gets ignored. (TODO: This needs improvement. We should trigger standalone for the reader when the input format is bibliographic, and for the writer when the output format is markdown.) * Carry over `citationNoteNum` to `citationNoteNumber`. This was just ignored in pandoc-citeproc. * Text.Pandoc.Filter: Add `CiteprocFilter` constructor to Filter. [API change] This runs the processCitations transformation. We need to treat it like a filter so it can be placed in the sequence of filter runs (after some, before others). In FromYAML, this is parsed from `citeproc` or `{type: citeproc}`, so this special filter may be specified either way in a defaults file (or by `citeproc: true`, though this gives no control of positioning relative to other filters). TODO: we need to add something to the manual section on defaults files for this. * Add deprecation warning if `upandoc-citeproc` filter is used. * Add `--citeproc/-C` option to trigger citation processing. This behaves like a filter and will be positioned relative to filters as they appear on the command line. * Rewrote the manual on citatations, adding a dedicated Citations section which also includes some information formerly found in the pandoc-citeproc man page. * Look for CSL styles in the `csl` subdirectory of the pandoc user data directory. This changes the old pandoc-citeproc behavior, which looked in `~/.csl`. Users can simply symlink `~/.csl` to the `csl` subdirectory of their pandoc user data directory if they want the old behavior. * Add support for CSL bibliography entry formatting to LaTeX, HTML, Ms writers. Added CSL-related CSS to styles.html.
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres1-2/+2
* Fix hlint suggestions, update hlint.yaml Most suggestions were redundant brackets. Some required LambdaCase. The .hlint.yaml file had a small typo, and didn't ignore camelCase suggestions in certain modules.
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-04Add timing info for filters in `--verbose` mode.John MacFarlane1-1/+12
+ Add RunningFilter, FilterCompleted constructors to LogMessage + When verbose mode is specified (verbosity == INFO), print a notice when running a filter and when a filter completes (including timing). Closes #6112.
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-180/+179
PR #5884. + Use pandoc-types 1.20 and texmath 0.12. + Text is now used instead of String, with a few exceptions. + In the MediaBag module, some of the types using Strings were switched to use FilePath instead (not Text). + In the Parsing module, new parsers `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`, `many1Till`, `manyUntil`, `mantyUntilChar` have been added: these are like their unsuffixed counterparts but pack some or all of their output. + `glob` in Text.Pandoc.Class still takes String since it seems to be intended as an interface to Glob, which uses strings. It seems to be used only once in the package, in the EPUB writer, so that is not hard to change.
2019-10-10Improve parsing of --defaults.John MacFarlane1-0/+9
- Add FromYAML instances to Opt and to all subsidiary types. - Remove the use of HsYAML-aeson, which doesn't give good position information on errors. - Rename some fields in Opt to better match cli options or reflect what the ycontain [API change]: + optMetadataFile -> optMetadataFiles + optPDFEngineArgs -> optPDFEngineOpts + optWrapText -> optWrap - Add IpynbOutput enumerated type to Text.Pandoc.App.Opts. Use this instead fo a string for optIpynbOutput. - Add FromYAML instance for Filter in Text.Pandoc.Filters. With these changes parsing of defaults files should be complete and should give decent error messages. Now (unlike before) we get an error if an unknown field is used.
2019-09-27LogMessage: change UnknownExtension -> CouldNotDeduceFormatJohn MacFarlane1-4/+4
2019-09-19Clarify warning for missing title.John MacFarlane1-3/+3
Closes #5760.
2019-09-08Emit warning on `-f latex -o out.pdf` (#5736)Mauro Bieg1-0/+6
add UnusualConversion to LogMessage [API change]
2019-07-14Logging: Added UnknownExtensions constructor to LogMessage.John MacFarlane1-1/+10
[API change] Issue this warning when we're falling back to markdown or html because we don't recognize the extension of the input or output files.
2019-06-09Logging: Added IgnoredElement constructor for LogMessage.John MacFarlane1-0/+6
SkippedContent doesn't work for some of the XML-based readers, which don't have access to source positions.
2019-05-13Org reader: omit, but warn about unknown export optionsAlbert Krewinkel1-0/+6
Unknown export options are properly ignored and omitted from the output.
2019-03-01Remove license boilerplate.John MacFarlane1-17/+0
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel1-1/+1
Quite a few modules were missing copyright notices. This commit adds copyright notices everywhere via haddock module headers. The old license boilerplate comment is redundant with this and has been removed. Update copyright years to 2019. Closes #4592.
2018-10-08Add helpful suggestion to missing title warning.John MacFarlane1-1/+2
Tell users what to add to the command line to avoid the warning. Closes #4909.
2018-05-04catch IO errors when writing media files, closes #4559 (#4619)Francesco Occhipinti1-0/+6
If we do not catch these errors, any malformed entry in a media bag could cause the loss of a whole document output. An example of malformed entry is an entry with an empty file path.
2018-04-28FB2 reader: replace some errors with warningsAlexander Krotov1-0/+7
Now FB2 reader can read writer.fb2, which does not validate (yet).
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane1-0/+2
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-1/+1
2017-11-04Logging: issue INFO, not WARNING, if LaTeX .sty file can't be read.John MacFarlane1-1/+4
Normally this is not a situation requiring a fix from the user, so a warning is inappropriate.
2017-11-01hlintAlexander Krotov1-7/+7
2017-10-29Source code reformatting.John MacFarlane1-1/+1
2017-10-27Don't rely on syb when we don't need to.John MacFarlane1-1/+1
2017-10-23Downgraded SkippedContent and DocxParserWarning from WARNING to INFOJohn MacFarlane1-2/+2
2017-08-18LaTeX reader: implement \newtoggle, \iftoggle, \toggletrue|falseJohn MacFarlane1-0/+9
from etoolbox. Closes #3853.
2017-08-11Added support for translations (localization) (see #3559).John MacFarlane1-0/+14
* readDataFile, readDefaultDataFile, getReferenceDocx, getReferenceODT have been removed from Shared and moved into Class. They are now defined in terms of PandocMonad primitives, rather than being primitve methods of the class. * toLang has been moved from BCP47 to Class. * NoTranslation and CouldNotLoudTranslations have been added to LogMessage. * New module, Text.Pandoc.Translations, exporting Term, Translations, readTranslations. * New functions in Class: translateTerm, setTranslations. Note that nothing is loaded from data files until translateTerm is used; setTranslation just sets the language to be used. * Added two translation data files in data/translations. * LaTeX reader: Support `\setmainlanguage` or `\setdefaultlanguage` (polyglossia) and `\figurename`.
2017-08-07Logging: Added Deprecated constructor to LogMessage.John MacFarlane1-5/+9
2017-08-07Added Deprecated warning to LogMessage.John MacFarlane1-0/+7
2017-08-07Revert "Logging: Made SkippedContent an INFO level message..."John MacFarlane1-1/+1
This reverts commit 8995281691b56d711c44fb0c5cae2fc675d12eb9.
2017-08-07Logging: Made SkippedContent an INFO level message...John MacFarlane1-1/+1
rather than WARNING.
2017-07-06Logging: added MacroAlreadyDefined.John MacFarlane1-0/+9
2017-06-25Fixed log message for InvalidLang.John MacFarlane1-1/+1
2017-06-25Added InvalidLang to LogMessage.John MacFarlane1-0/+7
2017-06-19Separated tracing from logging.John MacFarlane1-11/+1
Formerly tracing was just log messages with a DEBUG log level. We now make these things independent. Tracing can be turned on or off in PandocMonad using `setTrace`; it is independent of logging. * Removed `DEBUG` from `Verbosity`. * Removed `ParserTrace` from `LogMessage`. * Added `trace`, `setTrace` to `PandocMonad`.
2017-06-18In producing PDFs, warn if the font is missing some characters.John MacFarlane1-0/+6
* Added `MissingCharacter` to `LogMessage` in Text.Pandoc.Logging. * Parse the (xe)latex log for missing character warnings and issue the warning. Closes #3742.
2017-06-12Changed "extracting..." warning to a regular log message.John MacFarlane1-0/+6
This makes it sensitive to proper verbosity settings. (It is now treated as INFO rather than WARNING, so one doesn't get these messages for creation of tmp images while making a pdf.) API changes: * Removed extractMediaBag from Text.Pandoc.MediaBag. * Added Extracting as constructor for LogMessage.
2017-05-25Markdown reader: warn for notes defined but not used.John MacFarlane1-0/+10
Closes #1718. Parsing.ParserState: Make stateNotes' a Map, add stateNoteRefs.