aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Man.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-05-09Change reader types, allowing better tracking of source positions.John MacFarlane1-11/+18
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.
2020-11-18Man reader: improve handling of .IP.John MacFarlane1-5/+19
We now better handle `.IP` when it is used with non-bullet, non-numbered lists, creating a definition list. We also skip blank lines like groff itself. Closes #6858.
2020-10-07Remove redundant import.John MacFarlane1-1/+1
2020-09-13Fix hlint suggestions, update hlint.yaml (#6680)Christian Despres1-1/+1
* 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-04-15Use the new builders, modify readers to preserve empty headersdespresc1-2/+7
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 issuesdespresc1-3/+2
- 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-4/+3
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-1/+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-07Resolve HLint warningsAlbert Krewinkel1-4/+4
All warnings are either fixed or, if more appropriate, HLint is configured to ignore them. HLint suggestions remain. * Ignore "Use camelCase" warnings in Lua and legacy code * Fix or ignore remaining HLint warnings * Remove redundant brackets * Remove redundant `return`s * Remove redundant as-pattern * Fuse mapM_/map * Use `.` to shorten code * Remove redundant `fmap` * Remove unused LANGUAGE pragmas * Hoist `not` in Text.Pandoc.App * Use fewer imports for `Text.DocTemplates` * Remove redundant `do`s * Remove redundant `$`s * Jira reader: remove unnecessary parentheses
2020-02-07Various minor cleanups and refactoring (#6117)Joseph C. Sible1-13/+13
* 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-15/+17
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-09-28Use Prelude.fail to avoid ambiguity with fail from GHC.Base.John MacFarlane1-2/+2
2019-07-02Fix redundant constraint warnings. (#5625)Pete Ryland1-2/+1
2019-03-01Remove license boilerplate.John MacFarlane1-21/+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-22Man reader: fix typo. (#5245)Brian Leung1-3/+3
2018-11-29Man reader: use mapLeft from Shared.John MacFarlane1-6/+1
2018-11-02Man reader: allow .SS to have blank contents.John MacFarlane1-1/+1
2018-10-30Roff reader: rename RoffToken constructors so they're shorter.John MacFarlane1-36/+36
2018-10-30Roff reader: renamed constructors for RoffToken...John MacFarlane1-36/+36
to more closely match nomenclature from man 7 groff.
2018-10-30Roff reader: removed MacroKind alias.John MacFarlane1-1/+1
2018-10-29Roff reader: improved escape parsing.John MacFarlane1-2/+0
Closes #5032. This also removes the FontSize constructor from LinePart. We don't need this yet.
2018-10-28Man reader: improved code blocks as continuation in list items.John MacFarlane1-5/+7
2018-10-28Man reader: allow both .in and .IP to indent code block.John MacFarlane1-1/+2
2018-10-28Man reader: skip .in used for indentation of code.John MacFarlane1-1/+2
2018-10-28Man reader: .PP in code blocks as blank line.John MacFarlane1-0/+1
2018-10-28Man reader: handle inline macros like .BI in code blocks.John MacFarlane1-38/+58
The font changes are discarded, but at least we keep the text.
2018-10-28Hlint changes.John MacFarlane1-6/+5
2018-10-27Man reader: allow block-level content in table cells.John MacFarlane1-8/+25
Closes #5028.
2018-10-27Revert "Roff reader: use LineParts abstraction."John MacFarlane1-9/+7
This reverts commit 42ba3c0a0b15fddd51e6a4b79882ddaeccf0eb3d.
2018-10-27Roff reader: use LineParts abstraction.John MacFarlane1-7/+9
This didn't really help performance in the end.
2018-10-27Roff tokenizer: check for first-column before parsing macro.John MacFarlane1-2/+2
Also add SourcePos as argument to lexRoff, so we can pass in current source pos when parsing a table cell. Closes #5025.
2018-10-27Man reader: don't throw an error if a table cell can't be parsed...John MacFarlane1-1/+1
as inlines. Instead, just have the parser fail. See #5026.
2018-10-27Man reader: allow .nf to be implicitly closed by eof.John MacFarlane1-3/+5
2018-10-26Rename Groff -> Roff.John MacFarlane1-19/+19
Module T.P.Readers.Groff -> T.P.Readers.Roff Module T.P.Writers.Groff -> T.P.Writers.Roff Module T.P.GroffChar -> T.P.RoffChar GroffTokens -> RoffTokens GroffToken -> RoffToken.
2018-10-26Groff tokenizer: introduce TableRow type, handle .T&.John MacFarlane1-11/+12
Closes #5020.
2018-10-25Man reader: allow empty simple table cells.John MacFarlane1-2/+4
2018-10-25Man reader: be more forgiving when parsing tables.John MacFarlane1-3/+4
We now look only at the last row of the format specifiers, if there is more than one row. (This is the default.)
2018-10-25Man reader: support tables.John MacFarlane1-15/+16
Closes #4982.
2018-10-25Man reader: handle tables.John MacFarlane1-17/+63
This still needs a bit of work. In particular, we should try to produce Plain cells when possible. See #4982.
2018-10-25Groff tokenizer: Add structured repr of table options.John MacFarlane1-1/+1
2018-10-25Implemented groff table lexing.John MacFarlane1-23/+28
We don't yet actually parse the tables in man, but most of the hard work is done. Also: Export lexGroff from T.P.Readers.Groff, instead of lower-level definitions. Rename things in T.P.Readers.Groff as `*Groff` rather than `*Man`.
2018-10-25Groff reader: got `\f[]` working properly.John MacFarlane1-0/+1
2018-10-25Man reader: fixed nested emphasis.John MacFarlane1-7/+44
2018-10-24T.P.Readers.Groff: use FontSpec, not list of FontKind.John MacFarlane1-8/+7
2018-10-24Man reader: improve source posiiton info.John MacFarlane1-1/+2
2018-10-24T.P.Readers.Groff: improve LinePart.John MacFarlane1-28/+15
Separate font change and font size change tokens. With this change, emphasis no longer works. This needs to be implemented in the parser, not the lexer.
2018-10-24Added Text.Pandoc.Readers.Groff.John MacFarlane1-465/+6
This is an internal module that exports a tokenizer for groff formats. Closes #4998.