aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/JATS.hs
AgeCommit message (Collapse)Author
12 daysDocBook/JATS reader: don't export surrounding space from inline elements.John MacFarlane
Previously we would export leading and trailing space inside elements like emphasis or ulink so they appeared outside the resulting pandoc Inline (Emph or Link). This is not really motivated; DocBook and XML in general treats leading and trailing whitespace in this context as significant. These spaces may casue problems for some output formats, e.g. asciidoc, but these issues should be addressed in the corresponding writers, as they are in the Markdown writer, using Text.Pandoc.Writers.Shared.delimited. Closes #11398.
2025-12-12Fix imports to avoid warning about foldl'.John MacFarlane
`foldl'` is exported by Prelude by base 4.20+. So we need to do some qualified importing to avoid warnings about redundant imports.
2024-11-04JATS writer: correct spelling of suppress attribute (#10350)Andreas Deininger
2024-07-03Avoid 'head' in JATS reader, DocBook writer.John MacFarlane
2023-10-27Fix spacing.John MacFarlane
2023-10-26Modify JATS reader to handle BITS too (#9138)Julia Diaz
Add provision for title-group, book, book-part-wrapper, book-meta, book-part-meta, book-title, book-title-group, index, toc, legend, title, collection-meta
2023-10-17JATS reader: fix handling of alt-text (#9134)Julia Diaz
Previously we were looking for an attribute that doesn't exist in JATS; alt-text is provided by a child element. Closes #9130.
2023-09-04JATS reader: fix conversion of date to ISO 8601 format.John MacFarlane
See #8865.
2023-09-04JATS reader: Ignore `<processing-meta>` element (#9057)Julia Diaz
2023-08-31Fix spacing errors.John MacFarlane
2023-08-30JATS reader: Multilevel support for `<permissions>` metadata (#9037)Julia Diaz
This revises the earlier support for `<permissions>`: now metadata objects with multiple fields are created, matching the structure in JATS.
2023-08-28Add support for <permissions> metadataJulia Diaz
2023-08-26Correct name of JATS element attribJulia Diaz
2023-08-22Fix spacing errors.John MacFarlane
2023-08-10Fix display of block elements in JATS reader (PR #8971)Julia Diaz
A number of block elements, like disp-quote, list, and disp-formula, were always treated as inlines if appearing inside paragraphs, even if their usage granted a separate block. The function isElementBlock has been refined to prevent this, and a number of specific parse cases have been added to parseBlock. Also, some minimal cleanup of the test file, in order for it to pass XML validation against the JATS DTD 1.3 (it was not compliant with the current or any previous versions of JATS). Closes #8889.
2023-06-24Fix spacing issues.John MacFarlane
2023-06-08Add footer and multiple body parsing to JATS table reader (#8795)Noah Malmed
Closes #8765.
2023-06-07Parse references title from ref-list in JATS reader.John MacFarlane
Closes #8365.
2023-06-06Fix whitespace.John MacFarlane
2023-06-06Improve title and label parsing in the JATS reader (#8840)Noah Malmed
Closes #8718.
2023-04-05Add rowspan, colspan and alignment to cells in jats table reader (#8726)Noah Malmed
Partially addresses #8408
2023-03-05JATS reader: avoid generating duplicate figure captions.John MacFarlane
Closes #8669.
2023-01-13Support complex figures. [API change]Albert Krewinkel
Thanks and credit go to Aner Lucero, who laid the groundwork for this feature in the 2021 GSoC project. He contributed many changes, including modifications to the readers for HTML, JATS, and LaTeX, and to the HTML and JATS writers. Shared (Albert Krewinkel): - The new function `figureDiv`, exported from `Text.Pandoc.Shared`, offers a standardized way to convert a figure into a Div element. Readers (Aner Lucero): - HTML reader: `<figure>` elements are parsed as figures, with the caption taken from the respective `<figcaption>` elements. - JATS reader: The `<fig>` and `<caption>` elements are parsed into figure elements, even if the contents is more complex. - LaTeX reader: support for figures with non-image contents and for subfigures. - Markdown reader: paragraphs containing just an image are treated as figures if the `implicit_figures` extension is enabled. The identifier is used as the figure's identifier and the image description is also used as figure caption; all other attributes are treated as belonging to the image. Writers (Aner Lucero, Albert Krewinkel): - DokuWiki, Haddock, Jira, Man, MediaWiki, Ms, Muse, PPTX, RTF, TEI, ZimWiki writers: Figures are rendered like Div elements. - Asciidoc writer: The figure contents is unwrapped; each image in the the figure becomes a separate figure. - Classic custom writers: Figures are passed to the global function `Figure(caption, contents, attr)`, where `caption` and `contents` are strings and `attr` is a table of key-value pairs. - ConTeXt writer: Figures are wrapped in a "placefigure" environment with `\startplacefigure`/`\endplacefigure`, adding the features caption and listing title as properties. Subfigures are place in a single row with the `\startfloatcombination` environment. - DocBook writer: Uses `mediaobject` elements, unless the figure contains subfigures or tables, in which case the figure content is unwrapped. - Docx writer: figures with multiple content blocks are rendered as tables with style `FigureTable`; like before, single-image figures are still output as paragraphs with style `Figure` or `Captioned Figure`, depending on whether a caption is attached. - DokuWiki writer: Caption and "alt-text" are no longer combined. The alt text of a figure will now be lost in the conversion. - FB2 writer: The figure caption is added as alt text to the images in the figure; pre-existing alt texts are kept. - ICML writer: Only single-image figures are supported. The contents of figures with additional elements gets unwrapped. - HTML writer: the alt text is no longer constructed from the caption, as was the case with implicit figures. This reduces duplication, but comes at the risk of images that are missing alt texts. Authors should take care to provide alt texts for all images. Some readers, most notably the Markdown reader with the `implicit_figures` extension, add a caption that's identical to the image description. The writer checks for this and adds an `aria-hidden` attribute to the `<figcaption>` element in that case. - JATS writer: The `<fig>` and `<caption>` elements are used write figures. - LaTeX writer: complex figures, e.g. with non-image contents and subfigures, are supported. The `subfigure` template variable is set if the document contains subfigures, triggering the conditional loading of the *subcaption* package. Contants of figures that contain tables are become unwrapped, as longtable environments are not allowed within figures. - Markdown writer: figures are output as implicit figures if possible, via HTML if the `raw_html` extension is enabled, and as Div elements otherwise. - OpenDocument writer: A separate paragraph is generated for each block element in a figure, each with style `FigureWithCaption`. Behavior for single-image figures therefore remains unchanged. - Org writer: Only the first element in a figure is given a caption; additional block elements in the figure are appended without any caption being added. - RST writer: Single-image figures are supported as before; the contents of more complex images become nested in a container of type `float`. - Texinfo writer: Figures are rendered as float with type `figure`. - Textile writer: Figures are rendered with the help of HTML elements. - XWiki: Figures are placed in a group. Co-authored-by: Aner Lucero <[email protected]>
2022-10-31First stab at mtl 2.3 compliance.John MacFarlane
This will no doubt produce a bunch of warnings and hence CI failures, which we'll need to work around with explicit imports.
2022-10-29Re-export lookupEntity from Text.Pandoc.XML [API change].John MacFarlane
2022-09-01JATS reader: handle uri element in references.John MacFarlane
Closes #8270.
2022-05-31JATS reader: support edition in references.John MacFarlane
Closes #8087. Note: we strip off any non-digits, since CSL wants "4" rather than "4th ed."
2022-04-06JATS reader: strip `ref-` prefix from ref id in xref.John MacFarlane
This completes commit 807a574e9d33fcf66928388e342cc1436eb2346e. Closes #8007.
2022-03-29JATS reader: handle pub-date.John MacFarlane
Closes #8000.
2022-03-28JATS reader: strip 'ref-' from ref id in constructing CSL id.John MacFarlane
This allows better round-tripping, because the JATS writer adds the `ref-` prefix to the citation id to get the ref element's id.
2022-03-28JATS reader: improve refs parsing.John MacFarlane
Handle issn and isbn; use simpler form for issued date.
2022-03-28JATS reader: support PMID, DOI, issue in citations.John MacFarlane
Closes #7995.
2022-02-12JATS reader: improve handling of fn-group elements (#7914)Albert Krewinkel
Footnotes in `<fn-group>` elements are collected and re-inserted into the document as proper footnotes in the place where they are referenced. Fixes: #6348
2021-11-20Capture `alt-text` in JATS figures (#7703)Albert Krewinkel
Co-authored-by: Aner Lucero <[email protected]>
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane
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-24Fix DocBook reader mathml regression...John MacFarlane
...caused by the switch in XML libraries. Also fixed a similar issue in JATS. Closes #7173.
2021-02-18DocBook, JATS, OPML readers: performance optimization.John MacFarlane
With the new XML parser, we can avoid the expensive tree normalization step we used to do. This gives a significant speed boost in docbook and JATS parsing (e.g. 9.7 to 6 ms).
2021-02-16Rename Text.Pandoc.XMLParser -> Text.Pandoc.XML.Light...John MacFarlane
..and add new definitions isomorphic to xml-light's, but with Text instead of String. This allows us to keep most of the code in existing readers that use xml-light, but avoid lots of unnecessary allocation. We also add versions of the functions from xml-light's Text.XML.Light.Output and Text.XML.Light.Proc that operate on our modified XML types, and functions that convert xml-light types to our types (since some of our dependencies, like texmath, use xml-light). Update golden tests for docx and pptx. OOXML test: Use `showContent` instead of `ppContent` in `displayDiff`. Docx: Do a manual traversal to unwrap sdt and smartTag. This is faster, and needed to pass the tests. Benchmarks: A = prior to 8ca191604dcd13af27c11d2da225da646ebce6fc (Feb 8) B = as of 8ca191604dcd13af27c11d2da225da646ebce6fc (Feb 8) C = this commit | Reader | A | B | C | | ------- | ----- | ------ | ----- | | docbook | 18 ms | 12 ms | 10 ms | | opml | 65 ms | 62 ms | 35 ms | | jats | 15 ms | 11 ms | 9 ms | | docx | 72 ms | 69 ms | 44 ms | | odt | 78 ms | 41 ms | 28 ms | | epub | 64 ms | 61 ms | 56 ms | | fb2 | 14 ms | 5 ms | 4 ms |
2021-02-10Add new unexported module T.P.XMLParser.John MacFarlane
This exports functions that uses xml-conduit's parser to produce an xml-light Element or [Content]. This allows existing pandoc code to use a better parser without much modification. The new parser is used in all places where xml-light's parser was previously used. Benchmarks show a significant performance improvement in parsing XML-based formats (especially ODT and FB2). Note that the xml-light types use String, so the conversion from xml-conduit types involves a lot of extra allocation. It would be desirable to avoid that in the future by gradually switching to using xml-conduit directly. This can be done module by module. The new parser also reports errors, which we report when possible. A new constructor PandocXMLError has been added to PandocError in T.P.Error [API change]. Closes #7091, which was the main stimulus. These changes revealed the need for some changes in the tests. The docbook-reader.docbook test lacked definitions for the entities it used; these have been added. And the docx golden tests have been updated, because the new parser does not preserve the order of attributes. Add entity defs to docbook-reader.docbook. Update golden tests for docx.
2020-10-08Extend fix to #6719 to JATS readerJohn MacFarlane
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres
* 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-06-28JATS reader: parse abstract element into metadata field of same name (#6482)Albert Krewinkel
Closes: #6480
2020-04-28Support new Underline element in readers and writers (#6277)Vaibhav Sagar
Deprecate `underlineSpan` in Shared in favor of `Text.Pandoc.Builder.underline`.
2020-04-15Use the new builders, modify readers to preserve empty headersdespresc
The Builder.simpleTable now only adds a row to the TableHead when the given header row is not null. This uncovered an inconsistency in the readers: some would unconditionally emit a header filled with empty cells, even if the header was not present. Now every reader has the conditional behaviour. Only the XWiki writer depended on the header row being always present; it now pads its head as necessary.
2020-04-15Adapt to the newest Table type, fix some previous adaptation issuesdespresc
- Writers.Native is now adapted to the new Table type. - Inline captions should now be conditionally wrapped in a Plain, not a Para block. - The toLegacyTable function now lives in Writers.Shared.
2020-04-15Implement the new Table typedespresc
2020-04-15JATS reader: handle "label" element in section title.John MacFarlane
Closes #6288.
2020-03-29Clean up some fmaps (#6226)Joseph C. Sible
* Avoid fmapping when we're just binding right after anyway * Clean up unnecessary fmaps in the LaTeX reader
2020-03-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel
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 Krewinkel
* 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.