aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/RST.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-10-22Use simpleFigure in Readers.Aner Lucero1-2/+2
2021-09-13RST reader: handle escaped colons in reference definitions.John MacFarlane1-1/+2
Cloess #7568.
2021-08-20RST reader: Fix `:literal:` includes.John MacFarlane1-5/+2
These should create code blocks, not insert raw RST. Closes #7513.
2021-07-09RST reader: fix regression with code includes.John MacFarlane1-1/+5
With the recent changes to include infrastructure, included code blocks were getting an extra newline. Closes #7436. Added regression test.
2021-05-09RST reader: seek include files in the directory...John MacFarlane1-1/+3
...of the file containing the include directive, as RST requires. Closes #6632.
2021-05-09RST reader: use `insertIncludedFile` from T.P.Parsing...John MacFarlane1-58/+36
instead of reproducing much of its code.
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane1-36/+40
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-04-28Smarter smart quotes.John MacFarlane1-18/+1
Treat a leading " with no closing " as a left curly quote. This supports the practice, in fiction, of continuing paragraphs quoting the same speaker without an end quote. It also helps with quotes that break over lines in line blocks. Closes #7216.
2021-03-09RST reader: fix logic for ending comments.John MacFarlane1-1/+2
Previously comments sometimes got extended too far. Closes #7134.
2021-02-11Use getTimestamp instead of getCurrentTime in writers.John MacFarlane1-2/+2
Setting SOURCE_DATE_EPOCH will allow reproducible builds. Partially addresses #7093. This does not suffice to fully enable reproducible in EPUB, since a unique id is being generated for each build.
2021-01-31RST reader: fix handling of header in CSV tables.John MacFarlane1-4/+5
The interpretation of this line is not affected by the delim option. Closes #7064.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-09-25RST reader: apply `.. class::` directly to following Header.John MacFarlane1-1/+6
rather than creating a surrounding Div. Closes #6699.
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres1-4/+4
* 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-07-21RST reader: fix csv tables with multiline cells.John MacFarlane1-1/+6
Closes #6549.
2020-07-12RST reader: fix spurious newlines in some attributes from directives.John MacFarlane1-1/+2
2020-07-12RST reader: avoid extra newline in included code blocks.John MacFarlane1-2/+2
2020-06-17RST reader: pass arbitrary attributes through in code blocks.John MacFarlane1-12/+12
Exceptions: name (which becomes the id), class (which becomes the classes), and number-lines (which is treated specially to fit with pandoc highlighting). Closes #6465.
2020-04-15Use the new builders, modify readers to preserve empty headersdespresc1-7/+13
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 removal of the RowSpan, ColSpan, RowHeadColumns accessorsdespresc1-1/+1
2020-04-15Adapt to the newest Table type, fix some previous adaptation issuesdespresc1-22/+19
- 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 typedespresc1-15/+35
2020-04-12RST reader: handle "date::" directive.John MacFarlane1-1/+10
Closes #6276.
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-13Add highlight directive to the rST reader (#6140)Lucas Escot1-4/+11
2020-02-07Apply linter suggestions. Add fix_spacing to lint target in Makefile.John MacFarlane1-8/+6
2020-02-07Various minor cleanups and refactoring (#6117)Joseph C. Sible1-1/+1
* Use concatMap instead of reimplementing it * Replace an unnecessary multi-way if with a regular if * Use sortOn instead of sortBy and comparing * Use guards instead of lots of indents for if and else * Remove redundant do blocks * Extract common functions from both branches of maybe Whenever both the Nothing and the Just branch of maybe do the same function, do that function on the result of maybe instead. * Use fmap instead of reimplementing it from maybe * Use negative forms instead of negating the positive forms * Use mapMaybe instead of mapping and then using catMaybes * Use zipWith instead of mapping over the result of zip * Use unwords instead of reimplementing it * Use <$ instead of <$> and const * Replace case of Bool with if and else * Use find instead of listToMaybe and filter * Use zipWithM instead of mapM and zip * Inline lambda wrappers into the real functions * We get zipWithM from Text.Pandoc.Writers.Shared * Use maybe instead of fromMaybe and fmap I'm not sure how this one slipped past me. * Increase a bit of indentation
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-242/+244
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-11-02RST reader: avoid spurious warning...John MacFarlane1-1/+1
when resolving links to internal anchors ending with `_`. Closes #5763.
2019-09-29RST reader: don't strip final underscore from absolute URI.John MacFarlane1-3/+7
Partially addresses #5763.
2019-09-28Use Prelude.fail to avoid ambiguity with fail from GHC.Base.John MacFarlane1-1/+1
2019-09-22RST reader: Fixed parsing of indented blocks.John MacFarlane1-6/+9
We were requiring consistent indentation, but this isn't required by RST, as long as each nonblank line of the block has *some* indentation. Closes #5753.
2019-08-23RST reader: use title, not admonition-title, for admonition title.John MacFarlane1-1/+1
This puts RST reader into alignment with docbook reader.
2019-07-10RST reader: keep `name` property in `imgAttr`. (#5637)Brian Leung1-1/+1
Closes #5619.
2019-03-01Remove license boilerplate.John MacFarlane1-18/+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-2/+2
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.
2019-01-09RST reader: change treatment of `number-lines` directives. (#5207)Brian Leung1-15/+15
Directives of this type without numeric inputs should not have a `startFrom` attribute; with a blank value, the writers can produce extra whitespace.
2019-01-08Removed superfluous sourceCode class on code blocks.John MacFarlane1-7/+4
* These were added by the RST reader and, for literate Haskell, by the Markdown and LaTeX readers. There is no point to this class, and it is not applied consistently by all readers. See #5047. * Reverse order of `literate` and `haskell` classes on code blocks when parsing literate Haskell. Better if `haskell` comes first.
2019-01-08RST reader: handle sourcecode directive as synonynm for code.John MacFarlane1-1/+1
Closes #5204.
2018-12-31Remove unused HasHeaderMap (#5175)Alexander1-1/+0
It is updated by some readers, but never actually used.
2018-10-07RST reader: don't allow single-dash separator in headerless table.John MacFarlane1-1/+3
Closes #4382.
2018-10-07RST reader: pass through fields in unknown directives as div attributes.John MacFarlane1-17/+20
This commit also adds support for `class` and `name` attributes to directives in general. Closes #4715.
2018-09-20RST reader: fix bug with internal link targets.John MacFarlane1-1/+1
They were gobbling up indented content underneath. Closes #4919.
2018-09-18parse rST inlines containing newlines closing #4912danse1-1/+1
this eliminates a regression error introduced after pandoc 2.1.1, affecting rST inline parsing. see the issue for details
2018-08-29RSTR reader: don't skip link definitions after comments.John MacFarlane1-0/+1
Closes #4860.
2018-08-05RST reader: improve parsing of inline interpreted text roles.John MacFarlane1-12/+28
* Use a Span with class "title-reference" for the default title-reference role. * Use B.text to split up contents into Spaces, SoftBreaks, and Strs for title-reference. * Use Code with class "interpreted-text" instead of Span and Str for unknown roles. (The RST writer has also been modified to round-trip this properly.) * Disallow blank lines in interpreted text. * Backslash-escape now works in interpreted text. * Backticks followed by alphanumerics no longer end interpreted text. Closes #4811.
2018-07-24RST reader: remove support for nested inlines.danse1-17/+15
RST does not allow nested emphasis, links, or other inline constructs. Closes #4581, double parsing of links with URLs as link text. This supersedes the earlier fix for #4581 in 6419819b46c0d69c7024ba8aa4a6381cb311341c. Fixes #4561, a bug parsing with URLs inside emphasis. Closes #4792.
2018-07-21RST reader: fix double-link bug.John MacFarlane1-1/+8
Link labels containing raw URLs were parsed as autolinks, but links within links are not allowed. Closes #4581.