Commit graph

430 commits

Author SHA1 Message Date
Albert Krewinkel
c65b514ed1
List.lua: add _VERSION to module, drop unused var 2017-11-29 21:13:10 +01:00
Albert Krewinkel
0105a3c293 Add basic lua List module (#4099)
The List module is automatically loaded, but not assigned to a global
variable. It can be included in filters by calling `List = require
'List'`.

Lists of blocks, lists of inlines, and lists of classes are now given
`List` as a metatable, making working with them more convenient. E.g.,
it is now possible to concatenate lists of inlines using Lua's
concatenation operator `..` (requires at least one of the operants to
have `List` as a metatable):

    function Emph (emph)
      local s = {pandoc.Space(), pandoc.Str 'emphasized'}
      return pandoc.Span(emph.content .. s)
    end

Closes: #4081
2017-11-28 17:20:01 -07:00
Albert Krewinkel
849900c516 data/pandoc.lua: enable table-like behavior of attributes (#4080)
Attribute lists are represented as associative lists in Lua. Pure
associative lists are awkward to work with. A metatable is attached to
attribute lists, allowing to access and use the associative list as if
the attributes were stored in as normal key-value pair in table.

Note that this changes the way `pairs` works on attribute lists. Instead
of producing integer keys and two-element tables, the resulting iterator
function now returns the key and value of those pairs.  Use `ipairs` to
get the old behavior.

Warning: the new iteration mechanism only works if pandoc has been
compiled with Lua 5.2 or later (current default: 5.3).

The `pandoc.Attr` function is altered to allow passing attributes as
key-values in a normal table. This is more convenient than having to
construct the associative list which is used internally.

Closes #4071
2017-11-20 09:37:40 -08:00
John MacFarlane
c9407f85a0 LaTeX template: include natbib/biblatex after polyglossia.
Otherwise we seem to get an error; biblatex wants polyglossia
language to be defined.

Closes #4073.
2017-11-14 20:50:13 -08:00
John MacFarlane
cf7d66c097 Fixed URIs in jats.csl.
They were being rendered twice, leading to invalid XML.
2017-11-11 16:23:41 -08:00
John MacFarlane
8d31e00010 Removed etc. from abbreviations file.
Reason:  often etc. ends a sentence, and we want the . to
be treated as a sentence-ending period.
2017-11-09 23:23:51 -05:00
Wandmalfarbe
62244713f5 Added a few abbreviations and sorted the list. (#3984) 2017-11-03 12:48:58 -04:00
John MacFarlane
642d603666 Improved support for columns in HTML.
* Move as much as possible to the CSS in the template.
* Ensure that all the HTML-based templates (including epub)
  contain the CSS for columns.
* Columns default to 50% width unless they are given a width
  attribute.

Closes #4028.
2017-11-02 20:57:05 -07:00
mb21
8d7ce0fdf0 HTML Writer: consistently use dashed class-names
see #3556
2017-10-31 10:40:16 +01:00
Albert Krewinkel
db715dc9d7
pandoc.lua: define default list attributes
The second argument of the OrderedList constructor, which should define
the list's attributes, is made optional. Default attributes are used if
the parameter is omitted.
2017-10-25 16:41:03 +02:00
Albert Krewinkel
cab4f982f3
pandoc.lua: destructure attr for Link and Image
Make Attr values accessible through through the keys `identifier`,
`classes` and `attributes`.  This is already used in other elements with
attributes and is now fixed for Link and Image.
2017-10-17 21:45:27 +02:00
Albert Krewinkel
12f8efe012
pandoc.lua: throw better error when pipe command fails
A table containing the error code, command, and command output is thrown
instead of just a string error message.
2017-10-05 11:41:59 +02:00
John MacFarlane
6dbf8bab07 Merge pull request #3951 from greut/patch-1
Load Google Font using HTTPS by default
2017-10-03 16:43:55 -04:00
Albert Krewinkel
371f9b7084
pandoc.lua: use wrapper funciton for pipe command
The pipe command is wrapped in a lua function, throwing a lua error if
the command returns with an error. A wrapper is needed as Haskell
functions exposed to lua may not throw lua errors due to limitations of
hslua.

The error handling is written such that a table can be returned as an
error object in the future. This is potentially useful when finer
control is required while catching the error in lua code. Current
limitations of hslua require error objects to be strings.
2017-10-03 20:45:11 +02:00
Yoan Blanc
66135ab970 Load Google Font using HTTPS by default
Otherwise they won't show up in current version of firefox/chromium.
2017-10-03 10:55:52 -05:00
Albert Krewinkel
9b750f7d87
Lua.PandocModule: promote addFunction to top level
This reduces some boilerplate.
2017-10-03 13:13:45 +02:00
John MacFarlane
2e2795412d Move 'tables in footnotes' fix out of beamer part of default.latex.
This caused an error in beamer.

Footnotes already work in tables in beamer, without this code.
2017-09-12 08:31:59 -07:00
Mauro Bieg
c7e3c1ec17 Support for PDF generation via weasyprint and prince (#3909)
* Rename --latex-engine to --pdf-engine
* In `Text.Pandoc.Options.WriterOptions`, rename `writerLaTeXEngine` to `writerPdfEngine` and `writerLaTeXArgs` to `writerPdfArgs`.
 * Add support for `weasyprint` and `prince`, in addition to `wkhtmltopdf`, for PDF generation via HTML (closes #3906).
* `Text.Pandoc.PDF.html2pdf`: use stdin instead of intermediate HTML file
2017-09-11 20:18:42 -07:00
Andrew Dunning
621e43e0ec Write euro symbol directly in LaTeX
The textcomp package allows pdfLaTeX to parse `€` directly, making the \euro command unneeded. Closes #3801.
2017-09-08 22:26:32 +01:00
John MacFarlane
3421f3eac7 Removed old beamer template.
We now use the default.latex template for both latex and beamer.
It contains conditionals for the beamer-specific things.

`pandoc -D beamer` will return this template.
2017-09-08 10:48:02 -07:00
Andrew Dunning
331a0a0c25 Use starred versions of xcolor names
Prevents changes to documents defined using the dvipsnames list (e.g. `Blue` gives a different result with svgnames enabled).
2017-09-08 10:32:36 +01:00
Andrew Dunning
51bb7453e4 Merge branch 'master' into patch-1 2017-09-08 07:06:50 +01:00
John MacFarlane
732005456e LaTeX template: load polyglossia after header-includes.
It needs to be loaded as late as possible.

Closes #3898.
2017-09-07 22:16:23 -07:00
John MacFarlane
f802990d45 Merge pull request #3885 from tarleb/lua-module-docs
Lua module documentation
2017-09-07 21:40:02 -07:00
Andrew Dunning
3654c4373a Use xcolor for colorlinks option
Beamer loads `xcolor` rather than `color`, and thus the `dvipsnames` option doesn't take effect. This also provides a wider range of colour selections with the `svgnames` option. Closes #3877.
2017-09-07 22:06:51 +01:00
Albert Krewinkel
1a4658c573
data/pandoc.lua: fix typos in documentation 2017-08-31 16:57:14 +02:00
Andrew Dunning
a89aa1a681 Combine LaTeX/Beamer templates
All conditionals use the `beamer` variable set by the writer.

Closes #3878.
2017-08-26 09:37:22 +01:00
Václav Haisman
c9be2de5c1 Allow setting Japanese fonts when using LuaLaTeX (#3873)
...by using the `luatexja-fontspec` and `luatexja-preset` packages. Use
existing `CJKmainfont` and `CJKoptions` template variables. Add
`luatexjafontspecoptions` for `luatexja-fontspec` and `luatexjapresetoptions`
for `luatexja-preset`.
2017-08-25 11:20:56 -07:00
Albert Krewinkel
41baaff327
Text.Pandoc.Lua: support Inline and Block catch-alls
Try function `Inline`/`Block` if no other filter function of the
respective type matches an element.

Closes: #3859
2017-08-22 23:30:48 +02:00
John MacFarlane
6cba21b4d3 Small improvement to #3855 - move lang attribute up.
So we don't have a dangling line with the closing `>` when
`lang` is not set.
2017-08-21 21:16:55 -07:00
Jens Getreu
9375e50b96 docbook5 template: use lang and subtitle variables (#3855) 2017-08-21 21:10:41 -07:00
Albert Krewinkel
8ef200b80f
data/pandoc.lua: fix documentation
Multiple documentation mistakes were fixed.
2017-08-21 17:47:54 +02:00
Albert Krewinkel
b81cff4357
data/pandoc.lua: Include Pandoc, Meta in implicit filters
Functions with a name that corresponds to an AST element are included in
implicit pandoc filter, but both `Meta` and `Pandoc` were wrongly
ignored till now.
2017-08-21 16:47:05 +02:00
John MacFarlane
892a4edeb1 Implement multicolumn support for slide formats.
The structure expected is:

    <div class="columns">
      <div class="column" width="40%">
        contents...
      </div>
      <div class="column" width="60%">
        contents...
      </div>
    </div>

Support has been added for beamer and all HTML slide formats.

Closes #1710.

Note:  later we could add a more elegant way to create
this structure in Markdown than to use raw HTML div elements.
This would come for free with a "native div syntax" (#168).
Or we could devise something specific to slides
2017-08-14 23:17:44 -07:00
Andrew Dunning
ceda566a5e Fix hyperref options clash (#3847)
Avoids an options clash when loading a package (e.g. `tufte-latex`) that uses `hyperref` settings different from those in the template (introduced in <feffd7c64a>).
2017-08-14 12:33:46 -07:00
John MacFarlane
f7346bbfc1 Added Listing to Term.
So far only added to English.
2017-08-12 13:19:50 -07:00
John MacFarlane
cc6db2aa8f Added new translations. 2017-08-12 13:18:09 -07:00
John MacFarlane
622c3f2fa6 Change to yaml for translation files. 2017-08-12 12:17:38 -07:00
John MacFarlane
c9c642c8b4 Added de.trans. 2017-08-11 23:52:03 -07:00
John MacFarlane
74212eb1b0 Added support for translations (localization) (see #3559).
* readDataFile, readDefaultDataFile, getReferenceDocx,
  getReferenceODT have been removed from Shared and
  moved into Class.  They are now defined in terms of
  PandocMonad primitives, rather than being primitve
  methods of the class.

* toLang has been moved from BCP47 to Class.

* NoTranslation and CouldNotLoudTranslations have
  been added to LogMessage.

* New module, Text.Pandoc.Translations, exporting
  Term, Translations, readTranslations.

* New functions in Class: translateTerm, setTranslations.
  Note that nothing is loaded from data files until
  translateTerm is used; setTranslation just sets the
  language to be used.

* Added two translation data files in data/translations.

* LaTeX reader: Support `\setmainlanguage` or `\setdefaultlanguage`
  (polyglossia) and `\figurename`.
2017-08-11 22:22:31 -07:00
John MacFarlane
0f658eb46c data/pandoc.lua: regularize constructors.
We now use Pandoc instead of Doc (though Doc remains a deprecated
Synonym), and we deprecate DoubleQuoted, SingleQuoted,
InlineMath, and DisplayMath.
2017-06-29 17:08:59 +02:00
John MacFarlane
7ea49da002 LaTeX template: added natbiboptions variable.
Closes #3768.
2017-06-28 14:34:12 +02:00
Albert Krewinkel
4fab0d2c30
data/pandoc.lua: add accessors to Table elements 2017-06-27 17:11:42 +02:00
John MacFarlane
cf3b9a4058 Removed redundant element from data/docx/word/numbering.xml.
The elements we need are generated when the document is
compiled; this didn't do anything.
2017-06-27 12:39:13 +02:00
John MacFarlane
6773447c8c Support --toc in opendocument/odt. 2017-06-26 16:31:28 +02:00
John MacFarlane
75f4e41d7d Use table-of-contents for contents of toc, make toc a boolean.
Changed markdown, rtf, and HTML-based templates accordingly.

This allows you to set `toc: true` in the metadata; this
previously produced strange results in some output formats.

Closes #2872.

For backwards compatibility, `toc` is still set to the
toc contents.  But it is recommended that you update templates
to use `table-of-contents` for the toc contents and `toc`
for a boolean flag.
2017-06-26 16:20:09 +02:00
John MacFarlane
8af1c065d2 latex template: fix typo in fix for notes in tables.
See 1475299c9a (diff-c7c27b8e99f898fde7715afd9ae8cd02R126)

However, this is not a complete fix:
https://github.com/jgm/pandoc-templates/pull/208#issuecomment-309631622

Thanks to zeeMonkeez.  See #2378.
2017-06-20 10:24:35 +02:00
Yuchen Pei
564c77964d Added Vimwiki reader (#3705).
* New module Text.Pandoc.Readers.Vimwiki, exporting readVimwiki [API change].
* New input format `vimwiki`.
* New data file, `data/vimwiki.css`, for displaying the HTML produced by this reader and pandoc's HTML writer in the style of vimwiki's own HTML export.
2017-06-19 22:15:12 +02:00
John MacFarlane
ec3992b2f0 Use revealjs's math plugin for mathjax.
This is a thin wrapper around mathjax that makes math look better
on revealjs.

See https://github.com/hakimel/reveal.js/#mathjax

We do this by setting the 'mathjax' boolean variable and
using it in the revealjs template. Also, for revealjs
and mathjax, we don't assign the usual thing to the 'math'
variable, since it's handled by mathjax config.

Closes #3743.
2017-06-18 11:44:21 +02:00
Václav Haisman
4bae307616 Added aspectratio variable to beamer template (#3723).
* Transplant jgm/pandoc-templates#236 to Pandoc repository.
* Document `aspectratio` in user manual.
* Enumerate possible values for `aspectratio`.
2017-06-05 15:52:36 +02:00
John MacFarlane
650e1ac1fd Docx writer: Use Table rather than "Table Normal" for table style.
"Table Normal" is the default table style and can't be modified.

Closes #3275, further testing welcome.
2017-05-25 12:11:46 +02:00
lwolfsonkin
b45e47735c modified template.latex to fix XeLaTex being used with tables (#3661)
- reordered `lang` variable handling to immediately before `bidi`
2017-05-18 22:42:18 +02:00
Ian
b9185b0216 Docx writer: Change FigureWithCaption to CaptionedFigure (#3658)
Edit styles.xml as part of the fix for #3656
2017-05-18 22:34:13 +02:00
Albert Krewinkel
399a36280d
Lua module: allow omitting Attr in element constructors
The Attr argument is made optional for all pandoc element constructors
which take such a parameter. The attr param is always the last argument
of the constructor functions, so the option to omit them makes it easier
to construct new pandoc elements by hand.
2017-05-18 00:04:48 +02:00
Václav Haisman
7bdf38ef2e LaTeX: Load parskip before hyperref. (#3654)
* LaTeX: Load `parskip` before `hyperref`.

According to `hyperref` package's `README.pdf`, page 22, `hyperref` package
should be loaded after `parskip` package.

* Adjust tests for previous change.
2017-05-09 22:09:10 +02:00
Václav Haisman
5048be5112 Fix links inside captions in LaTeX output with links-as-notes.
Declare our redefined `\href` robust.

Fixes #3651. (#3652)
2017-05-08 12:07:01 +02:00
John MacFarlane
2f3d62cb86 ConTeXt template: improved font handling.
simplefonts is now obsolete in ConTeXt.

This patch comes from Pablo Rodríguez via jgm/pandoc-templates#247.
2017-05-06 14:58:32 +02:00
Albert Krewinkel
ae21a8bb2a
Lua filter: fall-back to global filters when none is returned
The implicitly defined global filter (i.e. all element filtering
functions defined in the global lua environment) is used if no filter is
returned from a lua script. This allows to just write top-level
functions in order to define a lua filter. E.g

    function Emph(elem) return pandoc.Strong(elem.content) end
2017-04-30 17:06:54 +02:00
Albert Krewinkel
2e916b3abf
Lua module: simplify Attributes, rename to Attr
Attributes was written to behave much like a normal table, in order to
simplify working with it. However, all Attr containing elements were
changed to provide panflute-like accessors to Attr components, rendering
the previous approach unnecessary.
2017-04-30 11:50:09 +02:00
Albert Krewinkel
3362cb89d9
Lua module: make Header argument order consistent
Attributes are always passed as the last element, making it possible to
omit this argument.  Argument order for `Header` was wrong and is fixed.
2017-04-30 11:28:03 +02:00
Albert Krewinkel
01e8df2e53
Lua module: add example for usage of read 2017-04-30 11:24:48 +02:00
John MacFarlane
730796ee31 LaTeX writer: Fix problem with escaping in lstinline.
Previously the LaTeX writer created invalid LaTeX
when `--listings` was specified and a code span occured
inside emphasis or another construction.

This is because the characters `%{}\` must be escaped
in lstinline when the listinline occurs in another
command, otherwise they must not be escaped.

To deal with this, adoping Michael Kofler's suggestion,
we always wrap lstinline in a dummy command `\passthrough`,
now defined in the default template if `--listings` is
specified.  This way we can consistently escape the
special characters.

Closes #1629.
2017-04-29 11:05:44 +02:00
Albert Krewinkel
24ef672132 Lua module: provide simple read format parser
A single `read` function parsing pandoc-supported formats is added to
the module. This is simpler and more convenient than the previous method
of exposing all reader functions individually.
2017-04-26 23:28:40 +02:00
Albert Krewinkel
5416fb14ab Lua filter: allow natural access to meta elements
Meta elements that are treated as lua tables (i.e. MetaList,
MetaInlines, MetaBlocks, and MetaMap), are no longer wrapped in an
additional table but simply marked via a metatable.  This allows
treating those meta values just like normal tables, while still making
empty elements of those values distinguishable.
2017-04-26 23:28:40 +02:00
John MacFarlane
66b08391b3 HTML line block: Use class instead of style attribute.
We now issue `<div class="line-block">` and include a
default definition for `line-block` in the default
templates, instead of hard-coding a `style` on the
div.

Closes #1623.
2017-04-25 23:07:30 +02:00
Albert Krewinkel
291e4f39e8
Lua module: provide accessors to element properties 2017-04-15 21:36:39 +02:00
Albert Krewinkel
3d6edbd9e3
Lua filter: use Attributes constructor for Attrs
Element attributes are pushed to the stack via the `Attributes`
function. `Attributes` creates an Attr like triple, but the triple also
allows table-like access to key-value pairs.
2017-04-15 09:31:09 +02:00
Albert Krewinkel
ac275528c2
Lua module: fix doc generation, reorder code
Ensure that documentation generated with `ldoc` is readable and correct.
2017-04-15 00:12:51 +02:00
Albert Krewinkel
8c2e6a66b9
Lua module: provide builder functions for math and quoted
Provide functions `pandoc.SingleQuoted`, `pandoc.DoubleQuoted`,
`pandoc.DisplayMath`, and `pandoc.InlineMath` to allow simple building
of Math and Quoted elements.
2017-04-15 00:10:33 +02:00
Albert Krewinkel
d671b69b87
Lua filter: use lua strings for nullary constructors
Lua string are used to represent nullary data constructors. The previous
table-based representation was based on the JSON serialization, but can
be simplified. This also matches the way those arguments are passed to
custom writers.
2017-04-14 22:32:08 +02:00
Albert Krewinkel
540a3e80ad
Push blocks via lua constructors and constants
All element creation tasks are handled by lua functions defined in the
pandoc module.
2017-04-14 10:33:38 +02:00
Albert Krewinkel
425df8fff4
Use lua constructors to push meta values 2017-04-13 22:57:50 +02:00
Albert Krewinkel
00746c3c76
Improve lua module documentation 2017-04-13 19:10:51 +02:00
Albert Krewinkel
97dfe782cf
Lua module: provide multi-param Inline constructors
Instead of taking only a single argument containing the pre-packed
element contents, `Inline` constructors now take the same arguments as
the respective filter and `Custom` writer function
2017-04-12 21:21:25 +02:00
Albert Krewinkel
7e3705c1c4
Lua filter: use custom StackValue Inline instance
Inline elements are no longer pushed and pulled via aeson's Value.
2017-04-11 23:31:55 +02:00
John MacFarlane
48729f9715 Ms writer improvements:
- added some variables to the default template.
- cleaner output for images (stringify alt text).
2017-04-04 17:21:02 +02:00
John MacFarlane
65b692b413 Small fixes to ms template. 2017-04-04 16:19:53 +02:00
John MacFarlane
9e78a9d26b Added data/default.theme to repository. 2017-04-01 22:59:10 +02:00
John MacFarlane
1c84a03509 Ms writer: added syntax highlighting.
Closes #3547.

Macro definitions are inserted in the template when there is highlighted
code.

Limitations: background colors and underline currently not
supported.
2017-04-01 22:05:38 +02:00
John MacFarlane
8a3ef99882 JATS template: always include <back> element even if empty. 2017-03-31 15:15:34 +02:00
John MacFarlane
3217bc192e JATS writer: put references in <back>.
Modified template to include a `<back>` and `<body>` section.
This should give authors more flexibility, e.g. to put
acknowledgements metadata in `<back>`.  References are
automatically extracted and put into `<back>`.
2017-03-31 11:07:09 +02:00
John MacFarlane
560cfadb92 jats template: added xml-stylesheet variable. 2017-03-30 22:49:22 +02:00
John MacFarlane
6ad486c3c3 Automatically include URI-encoded jats.csl for jats output.
This way people can do

    pandoc -s -t jats --filter pandoc-citeproc

and it will just work.  If they want to specify a stylesheet,
they still can.
2017-03-30 16:43:17 +02:00
John MacFarlane
64fe39c255 Added default.jats template.
This is copied from Martin Fenner's pandoc-jats project:
https://github.com/mfenner/pandoc-jats
2017-03-28 09:38:00 +02:00
John MacFarlane
306dadc901 default.ms template: move header-includes and .1C up. 2017-03-26 23:47:38 +02:00
John MacFarlane
0eb62f03fe Ms writer: Hyperlink table of contents and other improvements. 2017-03-26 20:03:37 +02:00
John MacFarlane
e30d2c700a Ms writer: Use @ instead of | for inline math delimiter.
The `|` delimiter had a bad interaction with tbl.
See discussion in #1839.
2017-03-26 16:59:38 +02:00
John MacFarlane
267e1a13ea Ms writer: Support external links.
Also add config options for link color.
2017-03-26 11:05:23 +02:00
John MacFarlane
1d659bec01 Ms writer: Implement header identifiers and internal links. 2017-03-25 22:16:44 +01:00
John MacFarlane
ed6249bd0b Ms writer: use light gray for strikeout.
Pending groff definitions for striking out an arbitrary
section of text (not just a few words).
2017-03-25 20:53:32 +01:00
John MacFarlane
c941a00cac Ms writer: improved pdf metadata. 2017-03-25 19:30:24 +01:00
John MacFarlane
7c8eb2ba6e ms template: beginnings of support for PDF metadata.
This will have to be refined along the lines of what is
now done in the latex writer/template.

For help, see
http://pipeline.lbl.gov/code/3rd_party/licenses.win/groff/1.19.2/pdf/pdfmark.pdf
2017-03-25 11:43:44 +01:00
John MacFarlane
a932c71a28 Ms template: don't include www macros. 2017-03-25 09:26:51 +01:00
John MacFarlane
c13cfe8f5d Ms writer: Use indented paragraphs after first in section.
Note that the current indentation setting is 0; see the
settings in the template.
2017-03-24 23:32:28 +01:00
John MacFarlane
af57de0b27 default.ms: Add settings for document variables like width. 2017-03-24 22:15:46 +01:00
John MacFarlane
14e7d3dbff Use www.tmac in default.ms.
This will allow us to use link macros, etc.
2017-03-24 17:35:38 +01:00
John MacFarlane
a7ae4b1ee2 Ms writer: support --toc, date, abstract. 2017-03-24 17:25:09 +01:00
John MacFarlane
2251d9cb73 Ms writer: Use custom .HRULE macro for horizontal rule. 2017-03-24 09:23:19 +01:00
John MacFarlane
d20d3a5dbb Ms writer: Super/subscript support.
Also added some macro definitions to default template
to support subscripts + better superscripts.
2017-03-23 12:59:19 +01:00
John MacFarlane
6c204ea2bd Initial addition of groff ms writer.
* New module: Text.Pandoc.Writers.Ms.
* New template: default.ms.
* The writer uses texmath's new eqn writer to convert math
  to eqn format, so a ms file produced with this writer
  should be processed with `groff -ms -e` if it contains
  math.
2017-03-23 10:14:16 +01:00