aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX
AgeCommit message (Collapse)AuthorFilesLines
2021-11-24LaTeX reader: Fix semantics of `\ref`.John MacFarlane1-5/+3
We were including the ams environment type in addition to the number. This is proper behavior for `\cref` but not for `\ref`. To support `\cref` we need to store the environment label separately.
2021-11-24LaTeX reader: improve references.John MacFarlane3-3/+22
- Resolve references to theorem environments. - Remove Span caused by "label" in figure, table, and theorem environments; this had an id that duplicated the environments' id. See #813.
2021-11-24LaTeX reader: omit visible content for `\label{...}`.John MacFarlane1-2/+1
Previously we included the text of the label in square brackets, but this is undesirable in many cases. See discussion in <https://github.com/jgm/pandoc/issues/813#issuecomment-978232426>.
2021-11-15LaTeX reader: add rudimentary support for `\autoref` (#7693)Albert Krewinkel1-0/+1
2021-10-11LaTeX reader: Implement siunitx v3 commands.John MacFarlane1-1/+5
We support `\unit`, `\qty`, `\qtyrange`, and `\qtylist` as synonynms of `\si`, `\SI`, `\SIrange`, and `\SIlist`. Closes #7614.
2021-10-10LaTeX reader: Properly handle `\^` followed by group closing.John MacFarlane1-3/+3
Closes #7615.
2021-09-19LaTeX reader: Recognize that `\vadjust` sometimes takes "pre".John MacFarlane1-0/+7
Closes #7531.
2021-08-21LaTeX-parser: restrict \endinput to current fileSimon Schuster1-0/+4
2021-08-13LaTeX reader: proper implicit grouping around environment macros.John MacFarlane1-1/+2
2021-08-11Fix some lint issues.John MacFarlane2-6/+5
2021-08-11LaTeX reader: Support `\global` before `\def`, `\let`, etc.John MacFarlane1-2/+10
See #7494.
2021-08-11Fix scope for LaTeX macros.John MacFarlane3-55/+100
They should by default scope over the group in which they are defined (except `\gdef` and `\xdef`, which are global). In addition, environments must be treated as groups. We handle this by making sMacros in the LaTeX parser state a STACK of macro tables. Opening a group adds a table to the stack, closing one removes one. Only the top of the stack is queried. This commit adds a parameter for scope to the Macro constructor (not exported). Closes #7494.
2021-08-11LaTeX reader: improve handling of plain TeX macro primitives.John MacFarlane2-6/+29
- Fixed semantics for `\let`. - Implement `\edef`, `\gdef`, and `\xdef`. - Add comment noting that currently `\def` and `\edef` set global macros (so are equivalent to `\gdef` and `\xdef`). This should be fixed by scoping macro definitions to groups, in a future commit. Closes #7474.
2021-07-17LaTeX reader: avoid trailing hyphen in translating languages.John MacFarlane1-2/+2
Previously `\foreignlanguage{english}` turned into `<span lang="en-">`. The same issue affected Arabic. Closes #7447.
2021-07-16LaTeX reader: Support `\cline` in LaTeX tables.John MacFarlane1-0/+1
Closes #7442.
2021-07-11Improved parsing of raw LaTeX from Text streams (rawLaTeXParser).John MacFarlane1-5/+34
We now use source positions from the token stream to tell us how much of the text stream to consume. Getting this to work required a few other changes to make token source positions accurate. Closes #7434.
2021-05-27LaTeX reader: improve `\def` and implement `\newif`.John MacFarlane2-15/+63
- Improve parsing of `\def` macros. We previously set "verbatim mode" even for parsing the initial `\def`; this caused problems for things like ``` \def\foo{\def\bar{BAR}} \foo \bar ``` - Implement `\newif`. - Add tests.
2021-05-20LaTeX reader: More siunitx improvements. Closes #6658.John MacFarlane2-46/+95
There's still one slight divergence from the siunitx behavior: we get 'kg m/A/s' instead of 'kg m/(A s)'. At the moment I'm not going to worry about that.
2021-05-20LaTeX/siunitx: fix parsing of `\cubic` etc. See #6658.John MacFarlane1-35/+50
2021-05-20LaTeX reader sinuitx: fix + sign on ang.John MacFarlane1-3/+6
2021-05-20LaTeX reader siunitx: add leading 0 to numbers starting with .John MacFarlane1-2/+5
2021-05-20LaTeX reader: Fix parsing of `+-` in siunitx numbers.John MacFarlane1-4/+7
See #6658.
2021-05-20LaTeX reader: support `\pm` in `SI{..}`.John MacFarlane1-1/+3
Closes #6620.
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