aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX
AgeCommit message (Collapse)AuthorFilesLines
2021-05-19LaTeX reader: better support for `\xspace`.John MacFarlane1-2/+19
Previously we only supported it in inline contexts; now we support it in all contexts, including math. Partially addresses #7299.
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane3-5/+24
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-17Update to released unicode-collation, latest citeproc dev version.John MacFarlane1-1/+1
Update citeproc test.
2021-04-17Remove Text.Pandoc.BCP47 module.John MacFarlane1-119/+122
[API change] Use Lang from UnicodeCollation.Lang instead. This is a richer implementation of BCP 47.
2021-03-07LaTeX reader: handle table cells containing `&` in `\verb`.John MacFarlane1-1/+6
Closes #7129.
2021-03-03Revert "Add T.P.Readers.LaTeX.Include."John MacFarlane2-79/+2
This reverts commit b569b0226d4bd5e0699077089d54fb03d4394b7d. Memory usage improvement in compilation wasn't very significant.
2021-03-03Add T.P.Readers.LaTeX.Include.John MacFarlane2-2/+79
2021-03-03Remove T.P.Readers.LaTeX.Accent.John MacFarlane2-81/+68
Incorporate accentCommands into T.P.Readers.LaTeX.Inline.
2021-03-03Move enquote commands to T.P.LaTeX.Lang.John MacFarlane2-4/+32
2021-03-03Moved more into T.P.Readers.LaTeX.Lang.John MacFarlane2-4/+91
2021-03-03Split out T.P.Readers.LaTeX.Inline.John MacFarlane1-0/+275
2021-03-01Factor out T.P.Readers.LaTeX.Macro.John MacFarlane1-0/+153
2021-02-28Change T.P.Readers.LaTeX.SIunitx to export a command map...John MacFarlane1-7/+14
instead of individual commands.
2021-02-28T.P.Readers.LaTeX: Don't export tokenize, untokenize.John MacFarlane1-0/+9
[API change] These were only exported for testing, which seems the wrong thing to do. They don't belong in the public API and are not really usable as they are, without access to the Tok type which is not exported. Removed the tokenize/untokenize roundtrip test. We put a quickcheck property in the comments which may be used when this code is touched (if it is).
2021-02-28Factor out T.P.Readers.LaTeX.Math.John MacFarlane1-0/+221
2021-02-28Move setDefaultLanguage to T.P.Readers.LaTeX.Lang.John MacFarlane1-2/+20
2021-02-28Factor out T.P.Readers.LaTeX.Citation.John MacFarlane2-0/+215
2021-02-27Factor out T.P.Readers.LaTeX.Table.John MacFarlane2-0/+406
2021-02-27Split off T.P.Readers.LaTeX.Accent.John MacFarlane1-0/+78
To help reduce memory demands compiling the main LaTeX reader.
2021-02-21LaTeX reader: further optimizations in satisfyTok.John MacFarlane1-5/+5
Benchmarks show 2/3 of the run time and 2/3 of the allocation of the Feb. 10 benchmarks.
2021-02-21LaTeX reader: removed sExpanded in state.John MacFarlane1-7/+2
This isn't actually needed and checking it doesn't change anything. Also remove an unnecessary `doMacros` before `satisfyTok`, which does it anyway.
2021-02-21LaTeX reader: further performance optimization.John MacFarlane1-23/+19
Avoid unnecessary 'doMacros'.
2021-02-20LaTeX reader: Another small improvement to macro handling.John MacFarlane1-4/+3
2021-02-20LaTeX reader: avoid macro resolution code if no macros defined.John MacFarlane1-16/+19
2021-02-20T.P.Readers.LaTeX.Parsing: improve braced'.John MacFarlane1-16/+13
Remove the parameter, have it parse the opening brace, and make it more efficient.
2021-02-12LaTeX reader improvements.John MacFarlane1-18/+66
* Rewrote `withRaw` so it doesn't rely on fragile assumptions about token positions (which break when macros are expanded). This requires the addition of `sEnableWithRaw` and `sRawTokens` in `LaTeXState`, and a new combinator `disablingWithRaw` to disable collecting of raw tokens in certain contexts. * Add `parseFromToks` to T.P.Readers.LaTeX.Parsing. * Fix parsing of single character tokens so it doesn't mess up the new raw token collecting. * These changes slightly increase allocations and have a small performance impact, but it's minor. Closes #7092.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel3-3/+3
2021-01-04LaTeX reader: handle filecontents environment.John MacFarlane1-0/+2
Closes #7003.
2020-11-16Move getNextNumber from Readers.LaTeX to Readers.LaTeX.Parsing.John MacFarlane1-0/+26
2020-11-16Improve fix to siunitx numbers with minus.John MacFarlane1-1/+1
- use real minus sign - use tests contributed by Igor Pashev.
2020-11-16LaTeX reader: Fix negative numbers in siunitx commands.John MacFarlane1-2/+4
The commit a157e1a broke negative numbers, e.g. `\SI{-33}{\celcius}` or `\num{-3}`. This fixes the regression.
2020-11-02LaTeX reader: fix bug parsing macro arguments.John MacFarlane1-1/+5
If `\cL` is defined as `\mathcal{L}`, and `\til` as `\tilde{#1}`, then `\til\cL` should expand to `\tilde{\mathcal{L}}`, but pandoc was expanding it to `\tilde\mathcal{L}`. This is fixed by parsing the arguments in "verbatim mode" when the macro expands arguments at the point of use. Closes #6796.
2020-10-08LaTeX reader: Fix parsing of "show name" in newtheorem.John MacFarlane1-1/+1
Previously we were just treating it as a string and ignoring accents and formatting. See #6734.
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres3-12/+10
* 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-09-10Improved uncertainty handling in slunitx.John MacFarlane1-6/+11
2020-09-10LaTeX reader: support parenthesized uncertainties in siunitx.John MacFarlane1-2/+14
2020-09-02Support numrange, numlist for siunitx.John MacFarlane1-8/+24
See #6658.
2020-09-02Support some missing siunitx commands.John MacFarlane1-0/+8
2020-09-02LaTeX reader: Support siunitx `\ang`.John MacFarlane1-0/+12
See #6658.
2020-09-02LaTeX reader: support `\si` and improve other siunitx commands.John MacFarlane1-8/+22
2020-09-02LaTeX reader: support `\num` from siunitx.John MacFarlane1-5/+38
2020-09-02LaTeX reader: Support squared, cubed, tothe in siunitx.John MacFarlane1-12/+22
Closes #6657.
2020-09-02LaTeX reader: Factored out siunitx stuff into separate module.John MacFarlane1-0/+241
2020-07-22LaTeX reader: SUpport ams `\theoremstyle`.John MacFarlane1-2/+10
2020-07-22LaTeX reader: support theorem environments and `\newtheorem`.John MacFarlane1-0/+2
Includes numbering and labels and refs. Note that numbering support is not complete; we don't reset numbers with sections for example.
2020-07-22LaTeX reader: support ams proof environment.John MacFarlane1-0/+10
2020-07-22Moved more from LaTeX reader to LaTeX.Parsing.John MacFarlane1-0/+67
2020-07-20Move some code from T.P.R.LaTeX. to T.P.R.LaTeX.Parsing.John MacFarlane1-0/+64
We need to reduce the size of the LaTeX reader to ease compilation on resource-limited systems. More can be done in this vein.
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 Krewinkel3-6/+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.