Commit graph

891 commits

Author SHA1 Message Date
Albert Krewinkel
096cbe6987 Lua: allow access to pandoc state (#5015)
* Lua: allow access to pandoc state

Lua filters and custom writers now have read-only access to most fields
of pandoc's internal state via the global variable `PANDOC_STATE`.

* Lua: allow iterating through fields of PANDOC_STATE

* Lua filters doc: describe CommonState

* Lua filters doc: mention global variable PANDOC_STATE

* Lua: add access to logs

Log messages can currently only be printed, but not decomposed.
2018-10-25 22:12:14 -07:00
Alexander Krotov
07fc850172 Muse writer: add support for grid tables 2018-10-25 18:35:02 +03:00
John MacFarlane
3a9f807052 GroffChar: added @ to list of standard escapes.
Because we use it as a delimiter for tables (in man)
and for math (in ms).
2018-10-24 08:59:10 -07:00
Alexander Krotov
f859162554 Vimwiki reader: test empty preformatted text 2018-10-24 15:07:05 +03:00
John MacFarlane
8efb8975ed Groff writer character escaping changes.
T.P.GroffChar:  replaced `essentialEscapes` with `manEscapes`,
which includes all the escapes mentioned in the groff_man manual.

T.P.Writers.Groff: removed escapeCode; changed parameter on
escapeString from Bool to new type `EscapeMode`.
Rewrote `escapeString`.
2018-10-23 21:44:07 -07:00
John MacFarlane
bda1c0da81 Man reader: Handle optional argument in ME, UE macros.
Closes #4995.
2018-10-22 23:56:02 -07:00
John MacFarlane
261cbad0ef Groff writers escaping changes.
- Improve escaping of accented characters with `--ascii`.
  Combining accents are now handled properly.
- Don't escape spaces and tabs in code blocks. This doesn't
  seem to be necessary.
2018-10-22 23:48:12 -07:00
Brian Leung
7eea5c62ed LaTeX reader: add support for nolinkurl command. (#4992) 2018-10-22 23:36:44 -07:00
Alexander Krotov
4275d58a9f Muse writer: do not insert newline before lists 2018-10-23 03:38:59 +03:00
John MacFarlane
0327226d4c Man reader: don't parse \[ul] as unicode escape. 2018-10-22 12:05:34 -07:00
John MacFarlane
4625150f4c Man reader: fix code block tests.
They incorporated a spurious newline which needs to be
removed.
2018-10-21 23:01:58 -07:00
John MacFarlane
382763a7db Man reader: support .ds, .ds1; also fix macro arguments.
Closes #4997.
2018-10-21 22:00:50 -07:00
Alexander Krotov
875e33ecf6 Muse reader: allow footnotes to start with empty line
A space character was required after footnote marker, now newline is allowed.
2018-10-22 03:05:17 +03:00
John MacFarlane
1238a57456 Man reader: Moved handling of B, I, BI, IB, etc. to parsing phase.
Ultimately groff lexing should not handle man-specific macros.
This approach also gives more correct results for the test case.
2018-10-21 12:43:44 -07:00
John MacFarlane
25248c7a37 Man reader: move macro resolution to lexer phase.
We also introduce a new type ManTokens (a sequence of tokens)
and remove MComment.  This allows lexers to return empty strings
of tokens, or multiple tokens (as when macros are resolved).

One test still fails.  This needs to be fixed by moving handling
of .BI, .I, etc. to the parsing phase.
2018-10-21 12:08:54 -07:00
Alexander Krotov
a98e2b7c42 Muse writer: use lightweight markup after </em> tag 2018-10-21 20:23:10 +03:00
John MacFarlane
9593b375d7 Man reader: support UR/UE, MT/ME for links.
Closes #4989.
2018-10-20 22:55:20 -07:00
John MacFarlane
2b7a541dd0 Man reader: Fixed handling of nested fonts.
Closes #4978.
2018-10-20 22:41:39 -07:00
Alexander Krotov
8df59952bf Muse reader: allow empty headers
Previously empty headers caused parser to terminate without parsing the rest of the document.
2018-10-21 06:42:00 +03:00
John MacFarlane
f202279902 Man reader: Fix .B, .I, .BR, etc. 2018-10-20 16:40:44 -07:00
John MacFarlane
a9fc71118f Man reader: major restructuring, support macros.
- Improved support for custom macro definitions.
- LinePart type has been added. RoffStr is now one
  constructor of LinePart (the other being MacroArg).
- MComment has lost its argument.
- MEndMacro has been removed.
- MStr has been removed (we now simply use LinePart).
- Macros now store a list of tokens.
- Each macro argument is a [LinePart], instead of a LinePart.
- .BR now behaves as documented in man (and doesn't create a link).
2018-10-20 15:57:34 -07:00
John MacFarlane
8d4027da4d Man reader: block quotes (using RS..RE). 2018-10-20 10:07:28 -07:00
John MacFarlane
1b19e79650 Man reader: parse TP as definition lists.
Closes #4981.
2018-10-20 10:00:50 -07:00
John MacFarlane
62566c8182 Man reader: handle shift in list style.
Closes #4987.
2018-10-20 09:30:37 -07:00
Jesse Rosenthal
11e681edac Powerpoint tests: test raw openxml
Output files confirmed not to be corrupt, and with content as
expected, on PowerPoint 2013 on Windows 10 (virtualbox on linux).
2018-10-20 09:00:23 -04:00
John MacFarlane
c60ac7c9ab Man reader: improve treatment of .TH.
This should just add to metadata (title, date, section),
and not produce a level-1 header. (That might be done
in the template, depending on the output format.)
2018-10-19 23:55:01 -07:00
John MacFarlane
7dd06e96d7 Man reader: Improved header parsing.
- .SH should be level 1, .SS level 2.
- The header title can come on the next line.
2018-10-19 23:27:04 -07:00
John MacFarlane
13e443d7cc Man writer: avoid unnecessary .RS/.RE pair in defn lists.
When the definition is just one paragraph, we don't need
the `.RS\n.RE`.
2018-10-19 23:01:02 -07:00
John MacFarlane
f5704fac97 Man reader: properly handle multi-block list items.
Closes #4985.
2018-10-19 22:54:05 -07:00
John MacFarlane
790ada8946 Man reader: Added more tests for escapes.
Closes #4983.
2018-10-19 15:36:43 -07:00
John MacFarlane
56c4a11f97 Man reader: minor improvements.
use `trimInlines` for Para content to avoid leading and
trailing spaces.

Fix handling of \" in middle of line.

Add more tests for escapes.
2018-10-19 15:17:53 -07:00
John MacFarlane
e6772360f6 More man reader test updates. 2018-10-19 14:59:11 -07:00
John MacFarlane
2ee9cdcc60 Update tests for last change to man reader. 2018-10-19 14:27:13 -07:00
John MacFarlane
400e87df1d Update man reader tests. 2018-10-18 23:54:13 -07:00
John MacFarlane
7d5b25d6d6 GroffChar: fixed interpretation of \-.
It is the ascii - sign, not the unicode hyphen.
2018-10-18 23:54:13 -07:00
John MacFarlane
94c73e84d5 Merge branch 'Yanpas-groff_reader' 2018-10-18 20:58:46 -07:00
John MacFarlane
efbb329f1a Groff escaping changes.
- `--ascii` is now turned on automatically for man output, for
  portability.  All man output will be escaped to ASCII.
- In T.P.Writers.Groff, `escapeChar`, `escapeString`, and
  `escapeCode` now take a boolean parameter that selects
  ascii-only output.  This is used by the Ms writer for
  `--ascii`, instead of doing an extra pass after writing
  the document.
- In ms output without `--ascii`, unicode is used whenever
  possible (e.g. for double quotes).
- A few escapes are changed: e.g. `\[rs]` instead of `\\` for
  backslash, and `\ga]` instead of `` \` `` for backtick.
2018-10-18 10:21:34 -07:00
John MacFarlane
24f388e1a7 man/ms writers: use \[at] for escaped @. 2018-10-17 17:39:42 -07:00
John MacFarlane
f48960b75f Move common groff functions to Text.Pandoc.Writers.Groff
(unexported module).  These are used in both the man and ms
writers.

Moved groffEscape out of Text.Pandoc.Writers.Shared [cancels earlier
API change from adding it, which was after last release].

This fixes strong/code combination on man (should be `\f[CB]` not
`\f[BC]`), mentioned in #4973.

Updated tests.

Closes #4975.
2018-10-17 17:26:37 -07:00
Alexander Krotov
b3feaba6af Man writer: use \f[R] instead of \f[] to reset font
Fixes #4973
2018-10-17 18:29:07 +03:00
Alexander Krotov
6fc812485e Muse reader: allow examples to be indented with tabs 2018-10-17 18:17:30 +03:00
Alexander Krotov
1071732719 Muse reader: remove indentation from examples indicated by {{{ and }}} 2018-10-17 13:57:05 +03:00
John MacFarlane
5c42101ee9 Merge branch 'groff_reader' of https://github.com/Yanpas/pandoc into Yanpas-groff_reader 2018-10-16 18:39:20 -07:00
Yan Pas
7741cdbf04 added old-style test 2018-10-17 00:21:52 +03:00
John MacFarlane
885cbfd420 Only override --quickcheck-tests=N if N is not default value (100).
Some of the round-trip tests are set to do a maximum of 25
trials when the default value is given.

Closes #4956.
2018-10-15 22:15:43 -07:00
Yan Pas
ce27bf9a02 builders 2018-10-16 03:12:06 +03:00
John MacFarlane
6f6ad0514d LaTeX reader: make macroDef polymorphic and allow in inline context.
Otherwise we can't parse something like
```
\lowercase{\def\x{Foo}}
```
I have actually seen tex like this in the wild.
2018-10-15 11:46:31 -07:00
John MacFarlane
22f81f78bd Added failing test case for macros. 2018-10-15 00:37:17 -07:00
John MacFarlane
88faa45f1d Markdown writer: ensure blank between raw block and normal content.
Otherwise a raw block can prevent a paragraph from being
recognized as such.

Closes #4629.
2018-10-14 17:12:06 -07:00
John MacFarlane
cf8224045b Markdown reader: Fix awkward soft break movements before abbreviations.
Closes #4635.
2018-10-14 13:02:36 -07:00