summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org
AgeCommit message (Collapse)Author
2024-02-19Org reader/writer: support admonitions.John MacFarlane
Closes #9475.
2023-12-20Org reader: parse caption and label for grid tables.John MacFarlane
Closes #9279.
2023-09-06Org reader: factor out orgAnchor -> Org.Parsing.John MacFarlane
A purely internal change. We will use this both in inline and block parsing.
2023-08-30Fix compiler warning by removing redundant definition.John MacFarlane
2023-08-30Org reader: don't parse alphabetical lists...John MacFarlane
...unless the `fancy_lists` extension is enabled. Closes #9042.
2023-08-26Org reader: allow escaping commas in macro argumentsAmneesh Singh
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2023-08-18Org reader: allow example lines to end immediately after the colonBrian Leung
See the regexp at https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-element.el?h=d1e4b9351941aa9241ab3aa0a34256376b7eca94#n2420.
2023-04-05Org reader: treat `#+NAME` as synonym for `#+LABEL`.Albert Krewinkel
Closes: #8578
2023-04-01Org reader: require abstract environment to use lowercaseAlbert Krewinkel
2023-03-22Org reader: Allow zero width space as an escape characterChristian Christiansen
Allow the character U+200B to be used as an escape character as described in the Org-mode documentation https://orgmode.org/manual/Escape-Character.html Closes issue #8716.
2023-03-01Org reader: accept empty tablesAlbert Krewinkel
Fixes: #8659
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 <4rgento@gmail.com>
2023-01-10Update copyright years, it's 2023!Albert Krewinkel
2022-10-29T.P.Parsing.General: change `characterReference`, `charsInBalanced`.John MacFarlane
`characterReference` now returns a Text (as it should, because some named references don't correspond to a single Char), and uses the `lookupEntity` function from commonmark-hs instead of the slow one from tagsoup. `charsInBalanced` now takes a Text parser rather than a Char parser as argument. [API change]
2022-10-19Text.Pandoc.Shared: remove `elemText`, `notElemText`. [API change]John MacFarlane
2022-10-16T.P.Parsing: Remove gratuitious renaming of Parsec types.John MacFarlane
We were exporting Parser, ParserT as synonyms of Parsec, ParsecT. There is no good reason for this and it can cause confusion. Also, when possible, we replace imports of Text.Parsec with T.P.Parsing. The idea is to make it easier, at some point, to switch to megaparsec or another parsing engine if we want to. T.P.Parsing new exports: Stream(..), updatePosString, SourceName, Parsec, ParsecT [API change]. Removed exports: Parser, ParserT [API change].
2022-10-10Org reader: make #+pandoc-emphasis-pre work as expected. (#8360)Amir Dekel
So far, `orgStateLastPreCharPos` wasn't updated appropriately after each parsing to native Str (by the parser `str`). In addition to solving this, the guard `notAfterString` in `emphasisStart` is removed to allow emphasis after Str at the first place.
2022-10-03Rename T.P.Readers.LaTeX.Types -> T.P.TeX.John MacFarlane
2022-10-03Rename T.P.Network.HTTP -> T.P.URI.John MacFarlane
This is still an unexported internal module. Export `urlEncode`, `escapeURI`, `isURI`, `schemes`, `uriPathToPath`. Re-export `escapeURI` and `isURI` from T.P.Shared (as they were exported before); drop exports of `schemes` and `uriPathToPath` [API change]. With this change, T.P.Class no longer depends on T.P.Shared.
2022-09-19Org reader: Allow org-ref v2 citations with `&` prefix.John MacFarlane
Closes #8302.
2022-08-21Org reader: treat *emacs-jupyter* src blocks as code cells.Albert Krewinkel
This improves support for notebook-like org files that are intended to be used with emacs-jupyter package. Closes: #8236
2022-08-17Org reader: treat "abstract" block as metadataAlbert Krewinkel
A block of type "abstract" is assumed to define the document's abstract. It is transferred from the main text to the metadata. Closes: #8204
2022-08-03Org reader: add missing `/` to Windows file URI; fixes prev commitAlbert Krewinkel
2022-08-02Org reader: recognize absolute paths on WindowsAlbert Krewinkel
Fixes: #8201
2022-07-30Support rowspans and colspans in grid tables (#8202)Albert Krewinkel
* Add tests for zero-width and fullwidth chars in grid tables * T.P.Parsing: simplify `gridTableWith'`, `gridTableWith` [API Change] The functions `gridTableWith` and `gridTableWith'` no longer takes a boolean argument that toggles whether a table head should be parsed: both, tables with heads and without heads, are always accepted now. * Support colspans, rowspans, and multirow headers in grid tables. Grid tables in Markdown, reStructuredText, and Org can now contain cells spanning over multiple columns and/or multiple rows; table headers containing multiple rows are supported as well. Note: the markdown writer does not yet support these more complex grid table features.
2022-06-19Org reader: Fix Post / Pre mixup when setting emphasis chars (#8134)Amir Dekel
2022-06-08org reader: recognize {webp,jxl} files as imagesYI
2022-05-20Org reader: support line selection in INCLUDE directives. (#8060)Brian Leung
2022-05-02Org reader: allow attrs for Org tables. (#8049)Brian Leung
Tables with attributes are no longer wrapped in Div elements; attributes are added directly to the table element.
2022-03-10Org reader: allow multiple `#+bibliography:`.John MacFarlane
2022-03-10Org reader: parse `#+print_bibliography:` as Div with id `refs`.John MacFarlane
2022-03-04Org reader: handle `#+bibliography:` as metadata...John MacFarlane
so that it can work with citeproc.
2022-02-21Org reader: More flexible LaTeX environmentsLucas V. R
Looking at the definition of `org-element-latex-environment-parser`, one sees that Org allows arbitrary arguments to LaTeX environments. In fact, it parses every char just after `\begin{xxx}` until `\end{xxx}` as content for the environment, so all the following examples are valid environments: ```org \begin{equation} e = mc^2 \end{equations} ``` ```org \begin{tikzcd}[ampersand replacement=\&] A \& B \\ C \& D \arrow[from=1-1, to=1-2] \arrow["f", from=2-1, to=2-2] \end{tikzcd} ```
2022-02-06Org reader: allow comments above property drawerLucas V. R
The Org Manual page at https://orgmode.org/manual/Property-Syntax.html says (as of 2022-02-03): "Property blocks defined before first headline needs to be located at the top of the buffer, allowing only comments above." This commit allows comments above.
2022-02-06Org reader: allow ":" in property drawer keysLucas V. R
Any non-space character is allowed as property drawer key, including ":" itself (so it is not really a delimiter). The real delimiter is a space character, so in a drawer like :PROPERTIES: ::k:ey:: value :END: ":k:ey:" is a key with value "value". This usage can be seen in the Org Manual at https://orgmode.org/manual/Using-Header-Arguments.html, where the Org snippet * Heading :PROPERTIES: :header-args:clojure: :session *clojure-1* :header-args:R: :session *R* :END: is listed as an example.
2022-01-17Fix some haddock errors.John MacFarlane
2022-01-09Org reader: support alphabetical (fancy) listsLucas Viana
This adds support for alphabetical lists in org by enabling the extension Ext_fancy_lists, mimicking the behaviour of Org Mode when org-list-allow-alphabetical is enabled. Enabling Ext_fancy_lists will also make Pandoc differentiate between the delimiters of ordered lists (periods or closing parentheses). Org does this differentiation by default when exporting to some formats (e.g. plain text) but does not in others (e.g. html and latex), so I decided to copy Pandoc's markdown reader behaviour.
2022-01-06Org reader: support counter cookies in listsLucas Viana
This adds support for counter cookies in org lists. Such cookies are used to override the item counter in ordered lists. In org it is possible to set the counter at any list item, but since Pandoc AST does not support this, we restrict the usage to setting an offset for the entire ordered list, by using the cookie in the first list item. Note that even though unordered lists do not have counters, Org Mode still parses such cookies in unordered lists and suppresses them in the output, so we do the same. Also, even though org-list-allow-alphabetical is disabled in Emacs by default, for some reason alphabetical cookies are always parsed and used in Org Mode regardlessly of whether this option is enabled or the list style is decimal, so we do the same. E.g. 2. test 3. test Is parsed as an ordered list starting at 1, as before. This also conforms to Org Mode behaviour. 1. [@2] test 2. test Is now parsed as an ordered list starting at 2, so that it conforms to Org Mode behaviour. Note that when parsing 1. [@2] test 2. [@9] test the second cookie is silenced and the entire list starts at 2. This is because the current Pandoc AST does not support expressing a change in the counter at a specific item.
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2022-01-01Org reader: allow trailing spaces after key/value pairs in directivesAlbert Krewinkel
Ensures that spaces at the end of attribute directives like `#+ATTR_HTML: :width 100%` (note the trailing spaces) are accepted.
2021-12-14Org reader: parse official org-cite citations.John MacFarlane
We also support the older org-ref style as a fallback. We no longer support the "markdown-style" citations. See #7329.
2021-12-14Org reader: remove support for "Berkeley style" citations.John MacFarlane
See #7329.
2021-10-22Org reader: allow an initial :PROPERTIES: drawer to add to metadata.John MacFarlane
Closes #7520.
2021-10-22Use simpleFigure in Readers.Aner Lucero
2021-09-10Org reader: don't parse a list as first item in a list item.John MacFarlane
Closes #7557.
2021-08-03Stop using the HTTP package. (#7456)mt_caret
We only depend on the urlEncode function in the package, which is also provided by http-types. The HTTP package also depends on the network package, which has difficulty building on ghcjs. Add internal module Text.Pandoc.Network.HTTP, exporting `urlEncode`.
2021-05-13Implement curly-brace syntax for Markdown citation keys.John MacFarlane
The change provides a way to use citation keys that contain special characters not usable with the standard citation key syntax. Example: `@{foo_bar{x}'}` for the key `foo_bar{x}`. Closes #6026. The change requires adding a new parameter to the `citeKey` parser from Text.Pandoc.Parsing [API change]. Markdown reader: recognize @{..} syntax for citatinos. Markdown writer: use @{..} syntax for citations when needed. Update manual with curly-brace syntax for citations. Closes #6026.
2021-05-09Org reader: Resolve org includes relative to ...John MacFarlane
...the directory containing the file containing the INCLUDE directive. Closes #5501.
2021-05-09T.P.Parsing: improve include file functions.John MacFarlane
Remove old `insertIncludedFileF`. [API change] Give `insertIncludedFile` a more general type, allowing it to be used where `insertIncludedFileF` was.
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.