summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MakeManPage.hs2
-rw-r--r--README61
-rw-r--r--Setup.hs4
-rw-r--r--changelog122
-rw-r--r--dzslides/template.html143
-rw-r--r--man/man1/pandoc.153
-rw-r--r--man/man5/pandoc_markdown.535
-rw-r--r--pandoc.cabal10
-rw-r--r--src/Text/Pandoc.hs2
-rw-r--r--src/Text/Pandoc/Biblio.hs2
-rw-r--r--src/Text/Pandoc/PDF.hs4
-rw-r--r--src/Text/Pandoc/Parsing.hs6
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs12
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs131
-rw-r--r--src/Text/Pandoc/Readers/RST.hs46
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs4
-rw-r--r--src/Text/Pandoc/SelfContained.hs14
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs2
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs5
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs7
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs24
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs36
-rw-r--r--src/Text/Pandoc/Writers/Man.hs17
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs6
-rw-r--r--src/Text/Pandoc/Writers/RST.hs55
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs2
-rw-r--r--src/pandoc.hs45
-rw-r--r--templates/default.beamer6
-rw-r--r--templates/default.context15
-rw-r--r--templates/default.dzslides24
-rw-r--r--templates/default.html55
-rw-r--r--templates/default.latex47
-rw-r--r--tests/latex-reader.latex7
-rw-r--r--tests/latex-reader.native5
-rw-r--r--tests/lhs-test.latex8
-rw-r--r--tests/lhs-test.latex+lhs8
-rw-r--r--tests/rst-reader.native10
-rw-r--r--tests/rst-reader.rst28
-rw-r--r--tests/tables.latex6
-rw-r--r--tests/writer.context9
-rw-r--r--tests/writer.latex10
-rw-r--r--tests/writer.rst6
42 files changed, 810 insertions, 234 deletions
diff --git a/MakeManPage.hs b/MakeManPage.hs
index ca9307c3e..8405df70b 100644
--- a/MakeManPage.hs
+++ b/MakeManPage.hs
@@ -1,4 +1,4 @@
--- Create pandoc.1 man page from README
+-- Create pandoc.1 man and pandoc_markdown.5 man pages from README
import Text.Pandoc
import Data.ByteString.UTF8 (toString, fromString)
import Data.Char (toUpper)
diff --git a/README b/README
index fb1d0a488..44f2f52ae 100644
--- a/README
+++ b/README
@@ -138,7 +138,7 @@ General options
`json` (JSON version of native AST), `markdown` (markdown),
`textile` (Textile), `rst` (reStructuredText), `html` (HTML),
or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,
- or `latex`, the input will be treated as literate Haskell source:
+ `latex`, the input will be treated as literate Haskell source:
see [Literate Haskell support](#literate-haskell-support),
below.
@@ -156,8 +156,8 @@ General options
slide show), or `rtf` (rich text format). Note that `odt` and `epub`
output will not be directed to *stdout*; an output filename must
be specified using the `-o/--output` option. If `+lhs` is appended
- to `markdown`, `rst`, `latex`, `html`, or `html5`, the output will
- be rendered as literate Haskell source: see [Literate Haskell
+ to `markdown`, `rst`, `latex`, `beamer`, `html`, or `html5`, the output
+ will be rendered as literate Haskell source: see [Literate Haskell
support](#literate-haskell-support), below.
`-o` *FILE*, `--output=`*FILE*
@@ -256,12 +256,13 @@ General writer options
template appropriate for the output format will be used (see
`-D/--print-default-template`).
-`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
+`-V` *KEY[=VAL]*, `--variable=`*KEY[:VAL]*
: Set the template variable *KEY* to the value *VAL* when rendering the
document in standalone mode. This is generally only useful when the
`--template` option is used to specify a custom template, since
pandoc automatically sets the variables used in the default
- templates.
+ templates. If no *VAL* is specified, the key will be given the
+ value `true`.
`-D` *FORMAT*, `--print-default-template=`*FORMAT*
: Print the default template for an output *FORMAT*. (See `-t`
@@ -451,7 +452,7 @@ Options affecting specific writers
: Embed the specified font in the EPUB. This option can be repeated
to embed multiple fonts. To use embedded fonts, you
will need to add declarations like the following to your CSS (see
- ``--epub-stylesheet`):
+ `--epub-stylesheet`):
@font-face {
font-family: DejaVuSans;
@@ -625,7 +626,11 @@ where `FORMAT` is the name of the output format. A custom template
can be specified using the `--template` option. You can also override
the system default templates for a given output format `FORMAT`
by putting a file `templates/default.FORMAT` in the user data
-directory (see `--data-dir`, above).
+directory (see `--data-dir`, above). *Exceptions:* For `odt` output,
+customize the `default.opendocument` template. For `pdf` output,
+customize the `default.latex` template. For `epub` output, customize
+the `epub-page.html`, `epub-coverimage.html`, and `epub-titlepage.html`
+templates.
Templates may contain *variables*. Variable names are sequences of
alphanumerics, `-`, and `_`, starting with a letter. A variable name
@@ -668,10 +673,16 @@ depending on the output format, but include:
`http://www.w3.org/Talks/Tools/Slidy2`)
`s5-url`
: base URL for S5 documents (defaults to `ui/default`)
-`font-size`
+`fontsize`
: font size (10pt, 11pt, 12pt) for LaTeX documents
`documentclass`
: document class for LaTeX documents
+`geometry`
+: options for LaTeX `geometry` class, e.g. `margin=1in`;
+ may be repeated for multiple options
+`mainfont`, `sansfont`, `monofont`, `mathfont`
+: fonts for LaTeX documents (works only with xelatex
+ and lualatex)
`theme`
: theme for LaTeX beamer documents
`colortheme`
@@ -834,7 +845,7 @@ also make it easy to provide links from one section of a document to
another. A link to this section, for example, might look like this:
See the section on
- [header identifiers][#header-identifiers-in-html].
+ [header identifiers](#header-identifiers-in-html).
Note, however, that this method of providing links to sections works
only in HTML, LaTeX, and ConTeXt formats.
@@ -1534,10 +1545,12 @@ Backslash escapes do not work in verbatim contexts.
Smart punctuation
-----------------
+*Pandoc extension*.
+
If the `--smart` option is specified, pandoc will produce typographically
-correct output, converting straight quotes to curly quotes, `---` and `--`
-to Em-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after
-certain abbreviations, such as "Mr."
+correct output, converting straight quotes to curly quotes, `---` to
+em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces
+are inserted after certain abbreviations, such as "Mr."
Note: if your LaTeX template uses the `csquotes` package, pandoc will
detect automatically this and use `\enquote{...}` for quoted text.
@@ -1635,7 +1648,7 @@ them and they won't be treated as math delimiters.
TeX math will be printed in all output formats. How it is rendered
depends on the output format:
-Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
+Markdown, LaTeX, Org-Mode, ConTeXt
~ It will appear verbatim between `$` characters.
reStructuredText
@@ -1872,6 +1885,23 @@ empty, or omitted entirely:
[my website]: http://foo.bar.baz
+### Internal links
+
+To link to another section of the same document, use the automatically
+generated identifier (see [Header identifiers in HTML, LaTeX, and
+ConTeXt](#header-identifiers-in-html-latex-and-context), below).
+For example:
+
+ See the [Introduction](#introduction).
+
+or
+
+ See the [Introduction].
+
+ [Introduction]: #introduction
+
+Internal links are currently supported for HTML formats (including
+HTML slide shows and EPUB), LaTeX, and ConTeXt.
Images
------
@@ -2162,8 +2192,9 @@ Literate Haskell support
========================
If you append `+lhs` to an appropriate input or output format (`markdown`,
-`rst`, or `latex` for input or output; `html` or `html5` for output only),
-pandoc will treat the document as literate Haskell source. This means that
+`rst`, or `latex` for input or output; `beamer`, `html` or `html5` for
+output only), pandoc will treat the document as literate Haskell source.
+This means that
- In markdown input, "bird track" sections will be parsed as Haskell
code rather than block quotations. Text between `\begin{code}`
diff --git a/Setup.hs b/Setup.hs
index 2ee9e29a9..56df0045d 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -8,7 +8,7 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Verbosity ( Verbosity, silent )
import Distribution.Simple.GHC (ghcPackageDbOptions)
import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest))
-import Distribution.Simple.Utils (copyFiles)
+import Distribution.Simple.Utils (installOrdinaryFiles)
import Control.Exception ( bracket_ )
import Control.Monad ( unless )
import System.Process ( rawSystem, runCommand, waitForProcess )
@@ -86,7 +86,7 @@ manDir = "man"
installManpages :: PackageDescription -> LocalBuildInfo
-> Verbosity -> CopyDest -> IO ()
installManpages pkg lbi verbosity copy =
- copyFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
+ installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
(zip (repeat manDir) manpages)
-- | Returns a list of 'dependencies' that have been modified after 'file'.
diff --git a/changelog b/changelog
index b75d47f1c..a28f9a6df 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,125 @@
+pandoc (1.9.2)
+
+ * LaTeX reader:
+
+ + Made `lstlisting` work as a proper verbatim environment.
+ + Fixed bug parsing LaTeX tables with one column.
+
+ * LaTeX writer:
+
+ + Use `{}` around `ctable` caption, so that formatting can be used.
+ + Don't require eurosym package unless document has a €.
+
+ * LaTeX template: Added variables for `geometry`, `romanfont`,
+ `sansfont`, `mathfont`, `mainfont` so users can more easily
+ customize fonts.
+
+ * PDF writer:
+
+ + Run latex engine at least two times, to ensure
+ that PDFs will have hyperlinked bookmarks.
+ + Added PDF metadata (title,author) in LaTeX standalone + PDF output.
+
+ * Texinfo writer: retain directories in image paths. (Peter Wang)
+
+ * RST writer: Better handling of inline formatting, in accord
+ with docutils' "inline markup recognition rules" (though we don't
+ implement the unicode rules fully). Now `hi*there*hi` gets
+ rendered properly as `hi\ *there*\ hi`, and unnecessary
+ `\ ` are avoided around `:math:`, `:sub:`, `:sup:`.
+
+ * RST reader:
+
+ + Parse `\ ` as null, not escaped space.
+ + Allow `` :math:`...` `` even when not followed by blank
+ or `\`. This does not implement the complex rule docutils follows,
+ but it should be good enough for most purposes.
+ + Add support for the rST default-role directive. (Greg Maslov)
+
+ * Text.Pandoc.Parsing: Added `stateRstDefaultRole` field to `ParserState`.
+ (Greg Maslov)
+
+ * Markdown reader: Properly handle citations nested in other inline
+ elements.
+
+ * Markdown writer: don't replace empty alt in image with "image".
+
+ * DZSlides: Updated template.html and styles in default template.
+ Removed bizarre CSS for `q` in dzslides template.
+
+ * Avoid repeated `id` attribute in section and header in HTML slides.
+
+ * README improvements: new instructions on internal links,
+ removed misleading note on reST math.
+
+ * Build system:
+
+ + Fixed Windows installer so that dzslides works.
+ + Removed stripansi.sh.
+ + Added .travis.yml for Travis continuous integration support..
+ + Fixed upper bound for zlib (Sergei Trofimovich).
+ + Fixed upper bound for test-framework.
+ + Updated haddocks for haddock-2.10 (Sergei Trofimovich).
+
+pandoc (1.9.1.2)
+
+ * Added `beamer+lhs` as output format.
+
+ * Don't escape `<` in `<style>` tags with `--self-contained`.
+ This fixes a bug which prevented highlighting from working
+ when using `--self-contained`.
+
+ * PDF: run latex engine three times if `--toc` specified.
+ This fixes page numbers in the table of contents.
+
+ * Docx writer: Added TableNormal style to tables.
+
+ * LaTeX math environment fixes. `aligned` is now used instead of
+ the nonexistent `aligned*`. `multline` instead of the nonexistent
+ `multiline`.
+
+ * LaTeX writer: Use `\textasciitilde` for literal `~`.
+
+ * HTML writer: Don't escape contents of EQ tags with --gladtex.
+ This fixes a regression from 1.8.
+
+ * Use `<q>` tags for Quoted items for HTML5 output.
+ The quote style can be changed by modifying the template
+ or including a css file. A default quote style is included.
+
+ * LaTeX reader: Fixed accents (\~{a}, `\c{c}`).
+ Correctly handle \^{}. Support "minted" as a LaTeX verbatim block.
+
+ * Updated LaTeX template for better language support.
+ Use `polyglossia` instead of `babel` with xetex.
+ Set `lang` as documentclass option.
+ `\setmainlanguage` will use the last of a comma-separated
+ list of languages. Thanks to François Gannaz.
+
+ * Fixed default LaTeX template so `\euro` and `€` work. The
+ `eurosym` package is needed if you are using pdflatex.
+
+ * Fixed escaping of period in man writer (thanks to Michael Thompson).
+
+ * Fixed list label positions in beamer.
+
+ * Set `mainlang` variable in context writer.
+ This parallels behavior of latex writer. `mainlang` is the last
+ of a comma-separated list of languages in lang.
+
+ * EPUB language metadat: convert e.g. `en_US` from locale to `en-US`.
+
+ * Changed `-V` so that you can specify a key without a value.
+ Such keys get the value `true`.
+
+ * Fixed permissions on installed man pages - thanks Magnus Therning.
+
+ * Windows installer: require XP or higher. The installer is
+ now compiled on a Windows 7 machine, which fixes a problem
+ using citation functions on Windows 7.
+
+ * OSX package: Check for 64-bit Intel CPU before installing.
+
pandoc (1.9.1.1)
* Better handling of raw latex environments in markdown. Now
diff --git a/dzslides/template.html b/dzslides/template.html
index 591664f30..f2fb64b38 100644
--- a/dzslides/template.html
+++ b/dzslides/template.html
@@ -13,7 +13,8 @@
</section>
<section>
- <h2>Part one</h2>
+ <p>Some random text: But I've never been to the moon! You can see how I lived before I met you. Also Zoidberg.
+ I could if you hadn't turned on the light and shut off my stereo.</p>
</section>
<section>
@@ -23,12 +24,12 @@
<li>Item 2
<li>Item 3
</ul>
+ <details>Some notes. They are only visible using onstage shell.</details>
</section>
<section>
<q>
- Soothe us with sweet lies. Is that a cooking show? No! I want to
- live! There are still too many things I don't own!
+ Who's brave enough to fly into something we all keep calling a death sphere?
</q>
</section>
@@ -37,13 +38,18 @@
</section>
<section>
- <h3>An image</h3>
- <img src="http://placekitten.com/g/800/600">
+ <figure> <!-- Figures are used to display images and videos fullpage -->
+ <img src="http://placekitten.com/g/800/600">
+ <figcaption>An image</figcaption>
+ </figure>
+ <details>Kittens are so cute!</details>
</section>
<section>
- <h3>A video</h3>
- <video src="http://videos-cdn.mozilla.net/brand/Mozilla_Firefox_Manifesto_v0.2_640.webm" poster="http://www.mozilla.org/images/about/poster.jpg"></video>
+ <figure> <!-- Videos are automatically played -->
+ <video src="http://videos-cdn.mozilla.net/brand/Mozilla_Firefox_Manifesto_v0.2_640.webm" poster="http://www.mozilla.org/images/about/poster.jpg"></video>
+ <figcaption>A video</figcaption>
+ </figure>
</section>
<section>
@@ -58,12 +64,12 @@
<style>
html { background-color: black; }
- body { background-color: white; }
+ body { background-color: white; border-radius: 12px}
/* A section is a slide. It's size is 800x600, and this will never change */
section {
/* The font from Google */
font-family: 'Oswald', arial, serif;
- font-size: 40px;
+ font-size: 30px;
}
h1, h2 {
margin-top: 200px;
@@ -78,29 +84,39 @@
margin: 50px 200px;
}
+ p {
+ margin: 75px;
+ font-size: 50px;
+ }
+
q {
- display: inline-block;
- width: 700px;
- height: 600px;
+ display: block;
+ width: 100%;
+ height: 100%;
background-color: black;
color: white;
font-size: 60px;
padding: 50px;
}
- img, video {
- width: 800px;
- height: 600px;
- position: absolute;
- top: 0;
+ /* Figures are displayed full-page, with the caption
+ on top of the image/video */
+ figure {
background-color: black;
- z-index: -1;
+ }
+ figcaption {
+ margin: 70px;
+ font-size: 50px;
}
footer {
position: absolute;
- bottom: 10px;
- right: 20px;
+ bottom: 0;
+ width: 100%;
+ padding: 40px;
+ text-align: right;
+ background-color: #F3F4F8;
+ border-top: 1px solid #CCC;
}
/* Transition effect */
@@ -128,11 +144,17 @@
.incremental > * { opacity: 1; }
/* The current item */
- .incremental > *[aria-selected] { color: red; opacity: 1; }
+ .incremental > *[aria-selected] { opacity: 1; }
/* The items to-be-selected */
- .incremental > *[aria-selected] ~ * { opacity: 0.2; }
+ .incremental > *[aria-selected] ~ * { opacity: 0; }
+ /* The progressbar, at the bottom of the slides, show the global
+ progress of the presentation. */
+ #progress-bar {
+ height: 2px;
+ background: #AAA;
+ }
</style>
<!-- {{{{ dzslides core
@@ -149,9 +171,11 @@
#
-->
+<div id="progress-bar"></div>
+
<!-- Default Style -->
<style>
- * { margin: 0; padding: 0; }
+ * { margin: 0; padding: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
details { display: none; }
body {
width: 800px; height: 600px;
@@ -170,6 +194,24 @@
body.loaded { display: block; }
.incremental {visibility: hidden; }
.incremental[active] {visibility: visible; }
+ #progress-bar{
+ bottom: 0;
+ position: absolute;
+ -moz-transition: width 400ms linear 0s;
+ -webkit-transition: width 400ms linear 0s;
+ -ms-transition: width 400ms linear 0s;
+ transition: width 400ms linear 0s;
+ }
+ figure {
+ width: 100%;
+ height: 100%;
+ }
+ figure > * {
+ position: absolute;
+ }
+ figure > img, figure > video {
+ width: 100%; height: 100%;
+ }
</style>
<script>
@@ -178,6 +220,7 @@
idx: -1,
step: 0,
slides: null,
+ progressBar : null,
params: {
autoplay: "1"
}
@@ -186,6 +229,7 @@
Dz.init = function() {
document.body.className = "loaded";
this.slides = $$("body > section");
+ this.progressBar = $("#progress-bar");
this.setupParams();
this.onhashchange();
this.setupTouchEvents();
@@ -198,6 +242,9 @@
var keyVal = e.split('=');
Dz.params[keyVal[0]] = decodeURIComponent(keyVal[1]);
});
+ // Specific params handling
+ if (!+this.params.autoplay)
+ $$.forEach($$("video"), function(v){ v.controls = true });
}
Dz.onkeydown = function(aEvent) {
@@ -234,6 +281,10 @@
aEvent.preventDefault();
this.toggleContent();
}
+ if (aEvent.keyCode == 70) { // f
+ aEvent.preventDefault();
+ this.goFullscreen();
+ }
}
/* Touch Events */
@@ -352,6 +403,7 @@
newidx++;
}
}
+ this.setProgress(newidx, newstep);
if (newidx != this.idx) {
this.setSlide(newidx);
}
@@ -427,9 +479,9 @@
if (old) {
old.removeAttribute('aria-selected');
}
- var incrementals = this.slides[this.idx - 1].$$('.incremental');
+ var incrementals = $$('.incremental');
if (this.step <= 0) {
- incrementals.forEach(function(aNode) {
+ $$.forEach(incrementals, function(aNode) {
aNode.removeAttribute('active');
});
return;
@@ -439,7 +491,7 @@
next.setAttribute('aria-selected', true);
next.parentNode.setAttribute('active', true);
var found = false;
- incrementals.forEach(function(aNode) {
+ $$.forEach(incrementals, function(aNode) {
if (aNode != next.parentNode)
if (found)
aNode.removeAttribute('active');
@@ -453,6 +505,24 @@
}
return next;
}
+
+ Dz.goFullscreen = function() {
+ var html = $('html'),
+ requestFullscreen = html.requestFullscreen || html.requestFullScreen || html.mozRequestFullScreen || html.webkitRequestFullScreen;
+ if (requestFullscreen) {
+ requestFullscreen.apply(html);
+ }
+ }
+
+ Dz.setProgress = function(aIdx, aStep) {
+ var slide = $("section:nth-of-type("+ aIdx +")");
+ if (!slide)
+ return;
+ var steps = slide.$$('.incremental > *').length + 1,
+ slideSize = 100 / (this.slides.length - 1),
+ stepSize = slideSize / steps;
+ this.progressBar.style.width = ((aIdx - 1) * slideSize + aStep * stepSize) + '%';
+ }
Dz.postMsg = function(aWin, aMsg) { // [arg0, [arg1...]]
aMsg = [aMsg];
@@ -460,12 +530,16 @@
aMsg.push(encodeURIComponent(arguments[i]));
aWin.postMessage(aMsg.join(" "), "*");
}
+
+ function init() {
+ Dz.init();
+ window.onkeydown = Dz.onkeydown.bind(Dz);
+ window.onresize = Dz.onresize.bind(Dz);
+ window.onhashchange = Dz.onhashchange.bind(Dz);
+ window.onmessage = Dz.onmessage.bind(Dz);
+ }
- window.onload = Dz.init.bind(Dz);
- window.onkeydown = Dz.onkeydown.bind(Dz);
- window.onresize = Dz.onresize.bind(Dz);
- window.onhashchange = Dz.onhashchange.bind(Dz);
- window.onmessage = Dz.onmessage.bind(Dz);
+ window.onload = init;
</script>
@@ -503,11 +577,8 @@
return this.querySelectorAll(aQuery);
}).bind(document);
- NodeList.prototype.forEach = function(fun) {
- if (typeof fun !== "function") throw new TypeError();
- for (var i = 0; i < this.length; i++) {
- fun.call(this, this[i]);
- }
+ $$.forEach = function(nodeList, fun) {
+ Array.prototype.forEach.call(nodeList, fun);
}
</script>
diff --git a/man/man1/pandoc.1 b/man/man1/pandoc.1
index d7f3227a3..f237ad364 100644
--- a/man/man1/pandoc.1
+++ b/man/man1/pandoc.1
@@ -124,7 +124,7 @@ Earlier versions of pandoc came with a program, \f[C]markdown2pdf\f[],
that used pandoc and pdflatex to produce a PDF.
This is no longer needed, since \f[C]pandoc\f[] can now produce
\f[C]pdf\f[] output itself.
-To produce a PDF, simply specify an output file with a \f[C].pdf\f[]
+To produce a PDF, simply specify an output file with a \f[C]\&.pdf\f[]
extension.
Pandoc will create a latex file and use pdflatex (or another engine, see
\f[C]--latex-engine\f[]) to convert it to PDF:
@@ -165,7 +165,7 @@ Specify input format.
(JSON version of native AST), \f[C]markdown\f[] (markdown),
\f[C]textile\f[] (Textile), \f[C]rst\f[] (reStructuredText),
\f[C]html\f[] (HTML), or \f[C]latex\f[] (LaTeX).
-If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[], or
+If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[],
\f[C]latex\f[], the input will be treated as literate Haskell source:
see Literate Haskell support, below.
.RS
@@ -192,9 +192,9 @@ Note that \f[C]odt\f[] and \f[C]epub\f[] output will not be directed to
\f[I]stdout\f[]; an output filename must be specified using the
\f[C]-o/--output\f[] option.
If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[],
-\f[C]latex\f[], \f[C]html\f[], or \f[C]html5\f[], the output will be
-rendered as literate Haskell source: see Literate Haskell support,
-below.
+\f[C]latex\f[], \f[C]beamer\f[], \f[C]html\f[], or \f[C]html5\f[], the
+output will be rendered as literate Haskell source: see Literate Haskell
+support, below.
.RS
.RE
.TP
@@ -269,7 +269,7 @@ LaTeX environments.
.B \f[C]-S\f[], \f[C]--smart\f[]
Produce typographically correct output, converting straight quotes to
curly quotes, \f[C]---\f[] to em-dashes, \f[C]--\f[] to en-dashes, and
-\f[C]...\f[] to ellipses.
+\f[C]\&...\f[] to ellipses.
Nonbreaking spaces are inserted after certain abbreviations, such as
"Mr." (Note: This option is significant only when the input format is
\f[C]markdown\f[] or \f[C]textile\f[].
@@ -338,12 +338,15 @@ output format will be used (see \f[C]-D/--print-default-template\f[]).
.RS
.RE
.TP
-.B \f[C]-V\f[] \f[I]KEY=VAL\f[], \f[C]--variable=\f[]\f[I]KEY:VAL\f[]
+.B \f[C]-V\f[] \f[I]KEY[=VAL]\f[],
+\f[C]--variable=\f[]\f[I]KEY[:VAL]\f[]
Set the template variable \f[I]KEY\f[] to the value \f[I]VAL\f[] when
rendering the document in standalone mode.
This is generally only useful when the \f[C]--template\f[] option is
used to specify a custom template, since pandoc automatically sets the
variables used in the default templates.
+If no \f[I]VAL\f[] is specified, the key will be given the value
+\f[C]true\f[].
.RS
.RE
.TP
@@ -623,7 +626,7 @@ Any of these may be overridden by elements in the metadata file.
Embed the specified font in the EPUB.
This option can be repeated to embed multiple fonts.
To use embedded fonts, you will need to add declarations like the
-following to your CSS (see `\f[C]--epub-stylesheet\f[]):
+following to your CSS (see \f[C]--epub-stylesheet\f[]):
.RS
.IP
.nf
@@ -669,11 +672,11 @@ specified here.
.B \f[C]--bibliography=\f[]\f[I]FILE\f[]
Specify bibliography database to be used in resolving citations.
The database type will be determined from the extension of
-\f[I]FILE\f[], which may be \f[C].mods\f[] (MODS format), \f[C].bib\f[]
-(BibTeX/BibLaTeX format), \f[C].ris\f[] (RIS format), \f[C].enl\f[]
-(EndNote format), \f[C].xml\f[] (EndNote XML format), \f[C].wos\f[] (ISI
-format), \f[C].medline\f[] (MEDLINE format), \f[C].copac\f[] (Copac
-format), or \f[C].json\f[] (citeproc JSON).
+\f[I]FILE\f[], which may be \f[C]\&.mods\f[] (MODS format),
+\f[C]\&.bib\f[] (BibTeX/BibLaTeX format), \f[C]\&.ris\f[] (RIS format),
+\f[C]\&.enl\f[] (EndNote format), \f[C]\&.xml\f[] (EndNote XML format),
+\f[C]\&.wos\f[] (ISI format), \f[C]\&.medline\f[] (MEDLINE format),
+\f[C]\&.copac\f[] (Copac format), or \f[C]\&.json\f[] (citeproc JSON).
If you want to use multiple bibliographies, just use this option
repeatedly.
.RS
@@ -857,6 +860,12 @@ You can also override the system default templates for a given output
format \f[C]FORMAT\f[] by putting a file
\f[C]templates/default.FORMAT\f[] in the user data directory (see
\f[C]--data-dir\f[], above).
+\f[I]Exceptions:\f[] For \f[C]odt\f[] output, customize the
+\f[C]default.opendocument\f[] template.
+For \f[C]pdf\f[] output, customize the \f[C]default.latex\f[] template.
+For \f[C]epub\f[] output, customize the \f[C]epub-page.html\f[],
+\f[C]epub-coverimage.html\f[], and \f[C]epub-titlepage.html\f[]
+templates.
.PP
Templates may contain \f[I]variables\f[].
Variable names are sequences of alphanumerics, \f[C]-\f[], and
@@ -938,7 +947,7 @@ base URL for S5 documents (defaults to \f[C]ui/default\f[])
.RS
.RE
.TP
-.B \f[C]font-size\f[]
+.B \f[C]fontsize\f[]
font size (10pt, 11pt, 12pt) for LaTeX documents
.RS
.RE
@@ -948,6 +957,18 @@ document class for LaTeX documents
.RS
.RE
.TP
+.B \f[C]geometry\f[]
+options for LaTeX \f[C]geometry\f[] class, e.g.
+\f[C]margin=1in\f[]; may be repeated for multiple options
+.RS
+.RE
+.TP
+.B \f[C]mainfont\f[], \f[C]sansfont\f[], \f[C]monofont\f[],
+\f[C]mathfont\f[]
+fonts for LaTeX documents (works only with xelatex and lualatex)
+.RS
+.RE
+.TP
.B \f[C]theme\f[]
theme for LaTeX beamer documents
.RS
@@ -1179,8 +1200,8 @@ pandoc\ -t\ beamer\ habits.txt\ -V\ theme:Warsaw\ -o\ habits.pdf
.PP
If you append \f[C]+lhs\f[] to an appropriate input or output format
(\f[C]markdown\f[], \f[C]rst\f[], or \f[C]latex\f[] for input or output;
-\f[C]html\f[] or \f[C]html5\f[] for output only), pandoc will treat the
-document as literate Haskell source.
+\f[C]beamer\f[], \f[C]html\f[] or \f[C]html5\f[] for output only),
+pandoc will treat the document as literate Haskell source.
This means that
.IP \[bu] 2
In markdown input, "bird track" sections will be parsed as Haskell code
diff --git a/man/man5/pandoc_markdown.5 b/man/man5/pandoc_markdown.5
index ad6c41e5d..2e15829b8 100644
--- a/man/man5/pandoc_markdown.5
+++ b/man/man5/pandoc_markdown.5
@@ -175,7 +175,7 @@ A link to this section, for example, might look like this:
.nf
\f[C]
See\ the\ section\ on
-[header\ identifiers][#header-identifiers-in-html].
+[header\ identifiers](#header-identifiers-in-html).
\f[]
.fi
.PP
@@ -1062,10 +1062,12 @@ indicating hard line breaks using two trailing spaces on a line.
Backslash escapes do not work in verbatim contexts.
.SH SMART PUNCTUATION
.PP
+\f[I]Pandoc extension\f[].
+.PP
If the \f[C]--smart\f[] option is specified, pandoc will produce
typographically correct output, converting straight quotes to curly
-quotes, \f[C]---\f[] and \f[C]--\f[] to Em-dashes, and \f[C]...\f[] to
-ellipses.
+quotes, \f[C]---\f[] to em-dashes, \f[C]--\f[] to en-dashes, and
+\f[C]\&...\f[] to ellipses.
Nonbreaking spaces are inserted after certain abbreviations, such as
"Mr."
.PP
@@ -1195,7 +1197,7 @@ delimiters.
TeX math will be printed in all output formats.
How it is rendered depends on the output format:
.TP
-.B Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
+.B Markdown, LaTeX, Org-Mode, ConTeXt
It will appear verbatim between \f[C]$\f[] characters.
.RS
.RE
@@ -1505,6 +1507,31 @@ See\ [my\ website][],\ or\ [my\ website].
[my\ website]:\ http://foo.bar.baz
\f[]
.fi
+.SS Internal links
+.PP
+To link to another section of the same document, use the automatically
+generated identifier (see Header identifiers in HTML, LaTeX, and
+ConTeXt, below).
+For example:
+.IP
+.nf
+\f[C]
+See\ the\ [Introduction](#introduction).
+\f[]
+.fi
+.PP
+or
+.IP
+.nf
+\f[C]
+See\ the\ [Introduction].
+
+[Introduction]:\ #introduction
+\f[]
+.fi
+.PP
+Internal links are currently supported for HTML formats (including HTML
+slide shows and EPUB), LaTeX, and ConTeXt.
.SH IMAGES
.PP
A link immediately preceded by a \f[C]!\f[] will be treated as an image.
diff --git a/pandoc.cabal b/pandoc.cabal
index 7420416c8..444e737ae 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,5 +1,5 @@
Name: pandoc
-Version: 1.9.1.1
+Version: 1.9.2
Cabal-Version: >= 1.10
Build-Type: Custom
License: GPL
@@ -213,7 +213,7 @@ Library
json >= 0.4 && < 0.6,
tagsoup >= 0.12.5 && < 0.13,
base64-bytestring >= 0.1 && < 0.2,
- zlib >= 0.5 && <= 0.6,
+ zlib >= 0.5 && < 0.6,
highlighting-kate >= 0.5.0.2 && < 0.6,
temporary >= 1.1 && < 1.2
if impl(ghc >= 6.10)
@@ -311,7 +311,7 @@ Executable pandoc
json >= 0.4 && < 0.6,
tagsoup >= 0.12.5 && < 0.13,
base64-bytestring >= 0.1 && < 0.2,
- zlib >= 0.5 && <= 0.6,
+ zlib >= 0.5 && < 0.6,
highlighting-kate >= 0.5.0.2 && < 0.6,
temporary >= 1.1 && < 1.2
if impl(ghc >= 6.10)
@@ -369,7 +369,7 @@ Executable test-pandoc
json >= 0.4 && < 0.6,
tagsoup >= 0.12.5 && < 0.13,
base64-bytestring >= 0.1 && < 0.2,
- zlib >= 0.5 && <= 0.6,
+ zlib >= 0.5 && < 0.6,
highlighting-kate >= 0.5.0.2 && < 0.6,
temporary >= 1.1 && < 1.2
if impl(ghc >= 6.10)
@@ -401,7 +401,7 @@ Executable test-pandoc
else
cpp-options: -D_LIT=$lit
Other-Extensions: TemplateHaskell, QuasiQuotes
- Build-Depends: Diff, test-framework >= 0.3 && < 0.6,
+ Build-Depends: Diff, test-framework >= 0.3 && < 0.7,
test-framework-hunit >= 0.2 && < 0.3,
test-framework-quickcheck2 >= 0.2.9 && < 0.3,
QuickCheck >= 2.4 && < 2.6,
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index 878f0e0dd..597d2e07f 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -192,6 +192,8 @@ writers = [("native" , writeNative)
writeLaTeX o{ writerLiterateHaskell = True })
,("beamer" , \o ->
writeLaTeX o{ writerBeamer = True })
+ ,("beamer+lhs" , \o ->
+ writeLaTeX o{ writerBeamer = True, writerLiterateHaskell = True })
,("context" , writeConTeXt)
,("texinfo" , writeTexinfo)
,("man" , writeMan)
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs
index c8e87b2a0..6adb3248e 100644
--- a/src/Text/Pandoc/Biblio.hs
+++ b/src/Text/Pandoc/Biblio.hs
@@ -80,7 +80,7 @@ processCite s cs (Cite t _ : rest) =
++ processCite s cs rest
else Cite t (renderPandoc s (x:xs)) : processCite s cs rest
_ -> Str ("Error processing " ++ show t) : processCite s cs rest
-processCite s cs (x:xs) = x : processCite s cs xs
+processCite s cs (x:xs) = bottomUp (processCite s cs) x : processCite s cs xs
processCite _ _ [] = []
procInlines :: ([Inline] -> [Inline]) -> Block -> Block
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index cc19e1c50..4f3f38a14 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -57,8 +57,8 @@ tex2pdf' :: FilePath -- ^ temp directory for output
-> IO (Either ByteString ByteString)
tex2pdf' tmpDir program source = do
let numruns = if "\\tableofcontents" `isInfixOf` source
- then 2
- else 1
+ then 3 -- to get page numbers
+ else 2 -- 1 run won't give you PDF bookmarks
(exit, log', mbPdf) <- runTeXProgram program numruns tmpDir source
let msg = "Error producing PDF from TeX source."
case (exit, mbPdf) of
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 725621ce2..22a8d4d50 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -652,7 +652,8 @@ data ParserState = ParserState
stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
stateHasChapters :: Bool, -- ^ True if \chapter encountered
stateApplyMacros :: Bool, -- ^ Apply LaTeX macros?
- stateMacros :: [Macro] -- ^ List of macros defined so far
+ stateMacros :: [Macro], -- ^ List of macros defined so far
+ stateRstDefaultRole :: String -- ^ Current rST default interpreted text role
}
deriving Show
@@ -682,7 +683,8 @@ defaultParserState =
stateExamples = M.empty,
stateHasChapters = False,
stateApplyMacros = True,
- stateMacros = []}
+ stateMacros = [],
+ stateRstDefaultRole = "title-reference"}
data HeaderType
= SingleHeader Char -- ^ Single line of characters underneath
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 43165ceb1..0c017b2e4 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -46,7 +46,7 @@ import Text.Pandoc.Shared
import Text.Pandoc.Parsing
import Data.Maybe ( fromMaybe, isJust )
import Data.List ( intercalate )
-import Data.Char ( isSpace, isDigit )
+import Data.Char ( isSpace, isDigit, toLower )
import Control.Monad ( liftM, guard, when )
-- | Convert HTML-formatted string to 'Pandoc' document.
@@ -90,9 +90,17 @@ block = choice
, pRawHtmlBlock
]
+-- repeated in SelfContained -- consolidate eventually
renderTags' :: [Tag String] -> String
renderTags' = renderTagsOptions
- renderOptions{ optMinimize = (`elem` ["hr","br","img"]) }
+ renderOptions{ optMinimize = \x ->
+ let y = map toLower x
+ in y == "hr" || y == "br" ||
+ y == "img" || y == "meta" ||
+ y == "link"
+ , optRawTag = \x ->
+ let y = map toLower x
+ in y == "script" || y == "style" }
pList :: TagParser [Block]
pList = pBulletList <|> pOrderedList <|> pDefinitionList
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 5e69347b6..fbd0d464b 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -358,8 +358,6 @@ inlineCommands = M.fromList $
, ("scshape", smallcaps <$> inlines)
, ("bfseries", strong <$> inlines)
, ("/", pure mempty) -- italic correction
- , ("cc", lit "ç")
- , ("cC", lit "Ç")
, ("aa", lit "å")
, ("AA", lit "Å")
, ("ss", lit "ß")
@@ -374,11 +372,12 @@ inlineCommands = M.fromList $
, ("copyright", lit "©")
, ("`", option (str "`") $ try $ tok >>= accent grave)
, ("'", option (str "'") $ try $ tok >>= accent acute)
- , ("^", option (str "^") $ try $ tok >>= accent hat)
- , ("~", option (str "~") $ try $ tok >>= accent circ)
+ , ("^", option (str "^") $ try $ tok >>= accent circ)
+ , ("~", option (str "~") $ try $ tok >>= accent tilde)
, ("\"", option (str "\"") $ try $ tok >>= accent umlaut)
, (".", option (str ".") $ try $ tok >>= accent dot)
, ("=", option (str "=") $ try $ tok >>= accent macron)
+ , ("c", option (str "c") $ try $ tok >>= accent cedilla)
, ("i", lit "i")
, ("\\", linebreak <$ (optional (bracketed inline) *> optional sp))
, (",", pure mempty)
@@ -502,33 +501,66 @@ acute 'E' = 'É'
acute 'I' = 'Í'
acute 'O' = 'Ó'
acute 'U' = 'Ú'
+acute 'Y' = 'Ý'
acute 'a' = 'á'
acute 'e' = 'é'
acute 'i' = 'í'
acute 'o' = 'ó'
acute 'u' = 'ú'
+acute 'y' = 'ý'
+acute 'C' = 'Ć'
+acute 'c' = 'ć'
+acute 'L' = 'Ĺ'
+acute 'l' = 'ĺ'
+acute 'N' = 'Ń'
+acute 'n' = 'ń'
+acute 'R' = 'Ŕ'
+acute 'r' = 'ŕ'
+acute 'S' = 'Ś'
+acute 's' = 'ś'
+acute 'Z' = 'Ź'
+acute 'z' = 'ź'
acute c = c
-hat :: Char -> Char
-hat 'A' = 'Â'
-hat 'E' = 'Ê'
-hat 'I' = 'Î'
-hat 'O' = 'Ô'
-hat 'U' = 'Û'
-hat 'a' = 'ã'
-hat 'e' = 'ê'
-hat 'i' = 'î'
-hat 'o' = 'ô'
-hat 'u' = 'û'
-hat c = c
-
circ :: Char -> Char
-circ 'A' = 'Ã'
-circ 'O' = 'Õ'
-circ 'o' = 'õ'
-circ 'N' = 'Ñ'
-circ 'n' = 'ñ'
-circ c = c
+circ 'A' = 'Â'
+circ 'E' = 'Ê'
+circ 'I' = 'Î'
+circ 'O' = 'Ô'
+circ 'U' = 'Û'
+circ 'a' = 'â'
+circ 'e' = 'ê'
+circ 'i' = 'î'
+circ 'o' = 'ô'
+circ 'u' = 'û'
+circ 'C' = 'Ĉ'
+circ 'c' = 'ĉ'
+circ 'G' = 'Ĝ'
+circ 'g' = 'ĝ'
+circ 'H' = 'Ĥ'
+circ 'h' = 'ĥ'
+circ 'J' = 'Ĵ'
+circ 'j' = 'ĵ'
+circ 'S' = 'Ŝ'
+circ 's' = 'ŝ'
+circ 'W' = 'Ŵ'
+circ 'w' = 'ŵ'
+circ 'Y' = 'Ŷ'
+circ 'y' = 'ŷ'
+circ c = c
+
+tilde :: Char -> Char
+tilde 'A' = 'Ã'
+tilde 'a' = 'ã'
+tilde 'O' = 'Õ'
+tilde 'o' = 'õ'
+tilde 'I' = 'Ĩ'
+tilde 'i' = 'ĩ'
+tilde 'U' = 'Ũ'
+tilde 'u' = 'ũ'
+tilde 'N' = 'Ñ'
+tilde 'n' = 'ñ'
+tilde c = c
umlaut :: Char -> Char
umlaut 'A' = 'Ä'
@@ -568,6 +600,13 @@ macron 'o' = 'ō'
macron 'u' = 'ū'
macron c = c
+cedilla :: Char -> Char
+cedilla 'c' = 'ç'
+cedilla 'C' = 'Ç'
+cedilla 's' = 'ş'
+cedilla 'S' = 'Ş'
+cedilla c = c
+
tok :: LP Inlines
tok = try $ grouped inline <|> inlineCommand <|> str <$> (count 1 $ inlineChar)
@@ -646,7 +685,7 @@ verbatimEnv = do
controlSeq "begin"
name <- braced
guard $ name == "verbatim" || name == "Verbatim" ||
- name == "lstlisting"
+ name == "lstlisting" || name == "minted"
verbEnv name
rest <- getInput
return (r,rest)
@@ -678,20 +717,22 @@ environments = M.fromList
verbEnv "code"))
, ("verbatim", codeBlock <$> (verbEnv "verbatim"))
, ("Verbatim", codeBlock <$> (verbEnv "Verbatim"))
- , ("lstlisting", codeBlock <$> (verbEnv "listlisting"))
+ , ("lstlisting", codeBlock <$> (verbEnv "lstlisting"))
+ , ("minted", liftA2 (\l c -> codeBlockWith ("",[l],[]) c)
+ (grouped (many1 $ satisfy (/= '}'))) (verbEnv "minted"))
, ("displaymath", mathEnv Nothing "displaymath")
, ("equation", mathEnv Nothing "equation")
, ("equation*", mathEnv Nothing "equation*")
, ("gather", mathEnv (Just "gathered") "gather")
, ("gather*", mathEnv (Just "gathered") "gather*")
- , ("multiline", mathEnv (Just "gathered") "multiline")
- , ("multiline*", mathEnv (Just "gathered") "multiline*")
- , ("eqnarray", mathEnv (Just "aligned*") "eqnarray")
- , ("eqnarray*", mathEnv (Just "aligned*") "eqnarray*")
- , ("align", mathEnv (Just "aligned*") "align")
- , ("align*", mathEnv (Just "aligned*") "align*")
- , ("alignat", mathEnv (Just "aligned*") "alignat")
- , ("alignat*", mathEnv (Just "aligned*") "alignat*")
+ , ("multline", mathEnv (Just "gathered") "multline")
+ , ("multline*", mathEnv (Just "gathered") "multline*")
+ , ("eqnarray", mathEnv (Just "aligned") "eqnarray")
+ , ("eqnarray*", mathEnv (Just "aligned") "eqnarray*")
+ , ("align", mathEnv (Just "aligned") "align")
+ , ("align*", mathEnv (Just "aligned") "align*")
+ , ("alignat", mathEnv (Just "aligned") "alignat")
+ , ("alignat*", mathEnv (Just "aligned") "alignat*")
]
letter_contents :: LP Blocks
@@ -878,9 +919,9 @@ parseAligns :: LP [Alignment]
parseAligns = try $ do
char '{'
optional $ char '|'
- let cAlign = char 'c' >> return AlignCenter
- let lAlign = char 'l' >> return AlignLeft
- let rAlign = char 'r' >> return AlignRight
+ let cAlign = AlignCenter <$ char 'c'
+ let lAlign = AlignLeft <$ char 'l'
+ let rAlign = AlignRight <$ char 'r'
let alignChar = optional sp *> (cAlign <|> lAlign <|> rAlign)
aligns' <- sepEndBy alignChar (optional $ char '|')
spaces
@@ -891,16 +932,20 @@ parseAligns = try $ do
hline :: LP ()
hline = () <$ (try $ spaces >> controlSeq "hline")
+lbreak :: LP ()
+lbreak = () <$ (try $ spaces *> controlSeq "\\")
+
+amp :: LP ()
+amp = () <$ (try $ spaces *> char '&')
+
parseTableRow :: Int -- ^ number of columns
-> LP [Blocks]
parseTableRow cols = try $ do
- let amp = try $ spaces *> string "&"
- let tableCellInline = notFollowedBy (amp <|> controlSeq "\\") >> inline
- cells' <- sepBy ((plain . trimInlines . mconcat) <$> many tableCellInline) amp
+ let tableCellInline = notFollowedBy (amp <|> lbreak) >> inline
+ let tableCell = (plain . trimInlines . mconcat) <$> many tableCellInline
+ cells' <- sepBy tableCell amp
guard $ length cells' == cols
spaces
- optional $ controlSeq "\\"
- spaces
return cells'
simpTable :: LP Blocks
@@ -909,8 +954,8 @@ simpTable = try $ do
aligns <- parseAligns
let cols = length aligns
optional hline
- header' <- option [] $ try (parseTableRow cols <* hline)
- rows <- many (parseTableRow cols <* optional hline)
+ header' <- option [] $ try (parseTableRow cols <* lbreak <* hline)
+ rows <- sepEndBy (parseTableRow cols) (lbreak <* optional hline)
spaces
let header'' = if null header'
then replicate cols mempty
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 456b23ce8..35fe5d768 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -129,6 +129,7 @@ block = choice [ codeBlock
, imageBlock
, customCodeBlock
, mathBlock
+ , defaultRoleBlock
, unknownDirective
, header
, hrule
@@ -533,6 +534,24 @@ bulletList = many1 (listItem bulletListStart) >>=
return . BulletList . compactify
--
+-- default-role block
+--
+
+defaultRoleBlock :: GenParser Char ParserState Block
+defaultRoleBlock = try $ do
+ string ".. default-role::"
+ -- doesn't enforce any restrictions on the role name; embedded spaces shouldn't be allowed, for one
+ role <- manyTill anyChar newline >>= return . removeLeadingTrailingSpace
+ updateState $ \s -> s { stateRstDefaultRole =
+ if null role
+ then stateRstDefaultRole defaultParserState
+ else role
+ }
+ -- skip body of the directive if it exists
+ many $ blanklines <|> (spaceChar >> manyTill anyChar newline)
+ return Null
+
+--
-- unknown directive (e.g. comment)
--
@@ -780,7 +799,9 @@ hyphens = do
escapedChar :: GenParser Char st Inline
escapedChar = do c <- escaped anyChar
- return $ Str [c]
+ return $ if c == ' ' -- '\ ' is null in RST
+ then Str ""
+ else Str [c]
symbol :: GenParser Char ParserState Inline
symbol = do
@@ -803,12 +824,25 @@ strong :: GenParser Char ParserState Inline
strong = enclosed (string "**") (try $ string "**") inline >>=
return . Strong . normalizeSpaces
-interpreted :: [Char] -> GenParser Char st [Char]
+-- Parses inline interpreted text which is required to have the given role.
+-- This decision is based on the role marker (if present),
+-- and the current default interpreted text role.
+interpreted :: [Char] -> GenParser Char ParserState [Char]
interpreted role = try $ do
- optional $ try $ string "\\ "
- result <- enclosed (string $ ":" ++ role ++ ":`") (char '`') anyChar
- try (string "\\ ") <|> lookAhead (count 1 $ oneOf " \t\n") <|> (eof >> return "")
- return result
+ state <- getState
+ if role == stateRstDefaultRole state
+ then try markedInterpretedText <|> unmarkedInterpretedText
+ else markedInterpretedText
+ where
+ markedInterpretedText = try (roleMarker >> unmarkedInterpretedText)
+ <|> (unmarkedInterpretedText >>= (\txt -> roleMarker >> return txt))
+ roleMarker = string $ ":" ++ role ++ ":"
+ -- Note, this doesn't precisely implement the complex rule in
+ -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
+ -- but it should be good enough for most purposes
+ unmarkedInterpretedText = do
+ result <- enclosed (char '`') (char '`') anyChar
+ return result
superscript :: GenParser Char ParserState Inline
superscript = interpreted "sup" >>= \x -> return (Superscript [Str x])
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index 3b5954368..f33436835 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -228,14 +228,14 @@ bulletListItemAtDepth depth = try $ do
return (p:sublist)
-- | Ordered List of given depth, depth being the number of
--- leading '#'
+-- leading '#'
orderedListAtDepth :: Int -> GenParser Char ParserState Block
orderedListAtDepth depth = try $ do
items <- many1 (orderedListItemAtDepth depth)
return (OrderedList (1, DefaultStyle, DefaultDelim) items)
-- | Ordered List Item of given depth, depth being the number of
--- leading '#'
+-- leading '#'
orderedListItemAtDepth :: Int -> GenParser Char ParserState [Block]
orderedListItemAtDepth depth = try $ do
count depth (char '#')
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
index 9c609b8fe..9332a3fa0 100644
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -157,6 +157,16 @@ makeSelfContained :: Maybe FilePath -> String -> IO String
makeSelfContained userdata inp = do
let tags = parseTags inp
out' <- mapM (convertTag userdata) tags
- return $ renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br"
- || t == "img" || t == "meta" || t == "link" ) } out'
+ return $ renderTags' out'
+-- repeated from HTML reader:
+renderTags' :: [Tag String] -> String
+renderTags' = renderTagsOptions
+ renderOptions{ optMinimize = \x ->
+ let y = map toLower x
+ in y == "hr" || y == "br" ||
+ y == "img" || y == "meta" ||
+ y == "link"
+ , optRawTag = \x ->
+ let y = map toLower x
+ in y == "script" || y == "style" }
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index dfdf7a140..b612b9904 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -77,6 +77,8 @@ pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do
, ("title", titletext)
, ("date", datetext) ] ++
[ ("number-sections", "yes") | writerNumberSections options ] ++
+ [ ("mainlang", maybe "" (reverse . takeWhile (/=',') . reverse)
+ (lookup "lang" $ writerVariables options)) ] ++
[ ("author", a) | a <- authorstext ]
return $ if writerStandalone options
then renderTemplate context $ writerTemplate options
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 22278be7e..a2995b705 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -387,8 +387,9 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do
return $
[ mknode "w:tbl" []
( mknode "w:tblPr" []
- [ mknode "w:tblCaption" [("w:val", captionStr)] ()
- | not (null caption) ]
+ ( [ mknode "w:tblStyle" [("w:val","TableNormal")] () ] ++
+ [ mknode "w:tblCaption" [("w:val", captionStr)] ()
+ | not (null caption) ] )
: mknode "w:tblGrid" []
(if all (==0) widths
then []
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 67048348e..b423f136f 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -48,6 +48,8 @@ import Text.Pandoc.Writers.Markdown ( writePlain )
import Data.Char ( toLower )
import Network.URI ( unEscapeString )
import Text.Pandoc.MIME (getMimeType)
+import Prelude hiding (catch)
+import Control.Exception (catch, SomeException)
-- | Produce an EPUB file from a Pandoc document.
writeEPUB :: Maybe String -- ^ EPUB stylesheet specified at command line
@@ -126,8 +128,9 @@ writeEPUB mbStylesheet fonts opts doc@(Pandoc meta _) = do
let chapterEntries = zipWith chapterToEntry [1..] chapters
-- contents.opf
- localeLang <- catch (liftM (takeWhile (/='.')) $ getEnv "LANG")
- (\_ -> return "en-US")
+ localeLang <- catch (liftM (map (\c -> if c == '_' then '-' else c) .
+ takeWhile (/='.')) $ getEnv "LANG")
+ (\e -> let _ = (e :: SomeException) in return "en-US")
let lang = case lookup "lang" (writerVariables opts') of
Just x -> x
Nothing -> localeLang
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index f35b29370..f9bbe8796 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -59,12 +59,14 @@ import Data.Monoid (mempty, mconcat)
data WriterState = WriterState
{ stNotes :: [Html] -- ^ List of notes
, stMath :: Bool -- ^ Math is used in document
+ , stQuotes :: Bool -- ^ <q> tag is used
, stHighlighting :: Bool -- ^ Syntax highlighting is used
, stSecNum :: [Int] -- ^ Number of current section
}
defaultWriterState :: WriterState
-defaultWriterState = WriterState {stNotes= [], stMath = False, stHighlighting = False, stSecNum = []}
+defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False,
+ stHighlighting = False, stSecNum = []}
-- Helpers to render HTML with the appropriate function.
@@ -156,7 +158,8 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
let newvars = [("highlighting-css",
styleToCss $ writerHighlightStyle opts) |
stHighlighting st] ++
- [("math", renderHtml math) | stMath st]
+ [("math", renderHtml math) | stMath st] ++
+ [("quotes", "yes") | stQuotes st]
return (tit, auths, authsMeta, date, toc, thebody, newvars)
-- | Prepare author for meta tag, converting notes into
@@ -261,9 +264,8 @@ elementToHtml slideLevel opts (Sec level num id' title' elements) = do
-- title slides have no content of their own
then filter isSec elements
else elements
- let header'' = if (writerStrictMarkdown opts ||
- writerSectionDivs opts ||
- writerSlideVariant opts == S5Slides)
+ let header'' = if (writerStrictMarkdown opts || writerSectionDivs opts ||
+ writerSlideVariant opts == S5Slides || slide)
then header'
else header' ! prefixedId opts id'
let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]
@@ -581,8 +583,12 @@ inlineToHtml opts inline =
strToHtml "’")
DoubleQuote -> (strToHtml "“",
strToHtml "”")
- in do contents <- inlineListToHtml opts lst
- return $ leftQuote >> contents >> rightQuote
+ in if writerHtml5 opts
+ then do
+ modify $ \st -> st{ stQuotes = True }
+ H.q `fmap` inlineListToHtml opts lst
+ else (\x -> leftQuote >> x >> rightQuote)
+ `fmap` inlineListToHtml opts lst
(Math t str) -> modify (\st -> st {stMath = True}) >>
(case writerHTMLMathMethod opts of
LaTeXMathML _ ->
@@ -610,8 +616,8 @@ inlineToHtml opts inline =
DisplayMath -> brtag >> m >> brtag
GladTeX ->
return $ case t of
- InlineMath -> preEscapedString "<EQ ENV=\"math\">" >> toHtml str >> preEscapedString "</EQ>"
- DisplayMath -> preEscapedString "<EQ ENV=\"displaymath\">" >> toHtml str >> preEscapedString "</EQ>"
+ InlineMath -> preEscapedString $ "<EQ ENV=\"math\">" ++ str ++ "</EQ>"
+ DisplayMath -> preEscapedString $ "<EQ ENV=\"displaymath\">" ++ str ++ "</EQ>"
MathML _ -> do
let dt = if t == InlineMath
then DisplayInline
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index e99b20c60..3bef597dc 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -65,6 +65,7 @@ data WriterState =
, stHighlighting :: Bool -- true if document has highlighted code
, stIncremental :: Bool -- true if beamer lists should be displayed bit by bit
, stInternalLinks :: [String] -- list of internal link targets
+ , stUsesEuro :: Bool -- true if euro symbol used
}
-- | Convert Pandoc to LaTeX.
@@ -79,7 +80,7 @@ writeLaTeX options document =
stLHS = False, stBook = writerChapters options,
stCsquotes = False, stHighlighting = False,
stIncremental = writerIncremental options,
- stInternalLinks = [] }
+ stInternalLinks = [], stUsesEuro = False }
pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
@@ -134,6 +135,8 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
[ ("toc", if writerTableOfContents options then "yes" else "")
, ("body", main)
, ("title", titletext)
+ , ("title-meta", stringify title)
+ , ("author-meta", intercalate "; " $ map stringify authors)
, ("date", dateText)
, ("documentclass", if writerBeamer options
then "beamer"
@@ -151,8 +154,11 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
[ ("lhs", "yes") | stLHS st ] ++
[ ("graphics", "yes") | stGraphics st ] ++
[ ("book-class", "yes") | stBook st] ++
+ [ ("euro", "yes") | stUsesEuro st] ++
[ ("listings", "yes") | writerListings options || stLHS st ] ++
[ ("beamer", "yes") | writerBeamer options ] ++
+ [ ("mainlang", maybe "" (reverse . takeWhile (/=',') . reverse)
+ (lookup "lang" $ writerVariables options)) ] ++
[ ("highlighting-macros", styleToLaTeX
$ writerHighlightStyle options ) | stHighlighting st ] ++
citecontext
@@ -169,10 +175,15 @@ elementToLaTeX opts (Sec level _ id' title' elements) = do
return $ vcat (header' : innerContents)
-- escape things as needed for LaTeX
-stringToLaTeX :: Bool -> String -> String
-stringToLaTeX _ [] = ""
-stringToLaTeX isUrl (x:xs) =
- case x of
+stringToLaTeX :: Bool -> String -> State WriterState String
+stringToLaTeX _ [] = return ""
+stringToLaTeX isUrl (x:xs) = do
+ rest <- stringToLaTeX isUrl xs
+ when (x == '€') $
+ modify $ \st -> st{ stUsesEuro = True }
+ return $
+ case x of
+ '€' -> "\\euro{}" ++ rest
'{' -> "\\{" ++ rest
'}' -> "\\}" ++ rest
'$' -> "\\$" ++ rest
@@ -183,10 +194,9 @@ stringToLaTeX isUrl (x:xs) =
'-' -> case xs of -- prevent adjacent hyphens from forming ligatures
('-':_) -> "-{}" ++ rest
_ -> '-' : rest
- '~' | not isUrl -> "\\ensuremath{\\sim}"
+ '~' | not isUrl -> "\\textasciitilde{}" ++ rest
'^' -> "\\^{}" ++ rest
'\\' -> "\\textbackslash{}" ++ rest
- '€' -> "\\euro{}" ++ rest
'|' -> "\\textbar{}" ++ rest
'<' -> "\\textless{}" ++ rest
'>' -> "\\textgreater{}" ++ rest
@@ -201,7 +211,6 @@ stringToLaTeX isUrl (x:xs) =
'\x2014' -> "---" ++ rest
'\x2013' -> "--" ++ rest
_ -> x : rest
- where rest = stringToLaTeX isUrl xs
-- | Puts contents into LaTeX command.
inCmd :: String -> Doc -> Doc
@@ -370,7 +379,7 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
captionText <- inlineListToLaTeX caption
let capt = if isEmpty captionText
then empty
- else text "caption = " <> captionText <> "," <> space
+ else text "caption = {" <> captionText <> "}," <> space
rows' <- mapM (tableRowToLaTeX False aligns widths) rows
let rows'' = intersperse ("\\\\\\noalign{\\medskip}") rows'
tableNotes <- liftM (reverse . stTableNotes) get
@@ -525,8 +534,8 @@ inlineToLaTeX (Code (_,classes,_) str) = do
Nothing -> rawCode
Just h -> modify (\st -> st{ stHighlighting = True }) >>
return (text h)
- rawCode = return
- $ text $ "\\texttt{" ++ stringToLaTeX False str ++ "}"
+ rawCode = liftM (text . (\s -> "\\texttt{" ++ s ++ "}"))
+ $ stringToLaTeX False str
inlineToLaTeX (Quoted SingleQuote lst) = do
contents <- inlineListToLaTeX lst
csquotes <- liftM stCsquotes get
@@ -553,7 +562,7 @@ inlineToLaTeX (Quoted DoubleQuote lst) = do
then "\\,"
else empty
return $ "``" <> s1 <> contents <> s2 <> "''"
-inlineToLaTeX (Str str) = return $ text $ stringToLaTeX False str
+inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'
inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"
inlineToLaTeX (RawInline "latex" str) = return $ text str
@@ -567,7 +576,8 @@ inlineToLaTeX (Link txt (src, _)) =
do modify $ \s -> s{ stUrl = True }
return $ text $ "\\url{" ++ x ++ "}"
_ -> do contents <- inlineListToLaTeX txt
- return $ text ("\\href{" ++ stringToLaTeX True src ++ "}{") <>
+ src' <- stringToLaTeX True src
+ return $ text ("\\href{" ++ src' ++ "}{") <>
contents <> char '}'
inlineToLaTeX (Image _ (source, _)) = do
modify $ \s -> s{ stGraphics = True }
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index d3735efa7..c481e6c87 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -112,7 +112,11 @@ escapeString = escapeStringUsing manEscapes
-- | Escape a literal (code) section for Man.
escapeCode :: String -> String
-escapeCode = escapeStringUsing (manEscapes ++ backslashEscapes "\t ")
+escapeCode = concat . intersperse "\n" . map escapeLine . lines where
+ escapeLine codeline =
+ case escapeStringUsing (manEscapes ++ backslashEscapes "\t ") codeline of
+ a@('.':_) -> "\\&" ++ a
+ b -> b
-- We split inline lists into sentences, and print one sentence per
-- line. groff/troff treats the line-ending period differently.
@@ -122,15 +126,18 @@ escapeCode = escapeStringUsing (manEscapes ++ backslashEscapes "\t ")
breakSentence :: [Inline] -> ([Inline], [Inline])
breakSentence [] = ([],[])
breakSentence xs =
- let isSentenceEndInline (Str ".") = True
- isSentenceEndInline (Str "?") = True
+ let isSentenceEndInline (Str ys@(_:_)) | last ys == '.' = True
+ isSentenceEndInline (Str ys@(_:_)) | last ys == '?' = True
+ isSentenceEndInline (LineBreak) = True
isSentenceEndInline _ = False
(as, bs) = break isSentenceEndInline xs
in case bs of
[] -> (as, [])
[c] -> (as ++ [c], [])
(c:Space:cs) -> (as ++ [c], cs)
- (Str ".":Str ")":cs) -> (as ++ [Str ".", Str ")"], cs)
+ (Str ".":Str (')':ys):cs) -> (as ++ [Str ".", Str (')':ys)], cs)
+ (x@(Str ('.':')':_)):cs) -> (as ++ [x], cs)
+ (LineBreak:x@(Str ('.':_)):cs) -> (as ++[LineBreak], x:cs)
(c:cs) -> (as ++ [c] ++ ds, es)
where (ds, es) = breakSentence cs
@@ -279,7 +286,7 @@ blockListToMan opts blocks =
inlineListToMan :: WriterOptions -> [Inline] -> State WriterState Doc
-- if list starts with ., insert a zero-width character \& so it
-- won't be interpreted as markup if it falls at the beginning of a line.
-inlineListToMan opts lst@(Str "." : _) = mapM (inlineToMan opts) lst >>=
+inlineListToMan opts lst@(Str ('.':_) : _) = mapM (inlineToMan opts) lst >>=
(return . (text "\\&" <>) . hcat)
inlineListToMan opts lst = mapM (inlineToMan opts) lst >>= (return . hcat)
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 7ce939395..9a51dfdcb 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -516,9 +516,9 @@ inlineToMarkdown opts (Link txt (src, tit)) = do
else "[" <> linktext <> "](" <>
text src <> linktitle <> ")"
inlineToMarkdown opts (Image alternate (source, tit)) = do
- let txt = if (null alternate) || (alternate == [Str ""]) ||
- (alternate == [Str source]) -- to prevent autolinks
- then [Str "image"]
+ let txt = if null alternate || alternate == [Str source]
+ -- to prevent autolinks
+ then [Str ""]
else alternate
linkPart <- inlineToMarkdown opts (Link txt (source, tit))
return $ "!" <> linkPart
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index d6e5b5c9e..e6c84760e 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -38,6 +38,7 @@ import Data.List ( isPrefixOf, intersperse, transpose )
import Text.Pandoc.Pretty
import Control.Monad.State
import Control.Applicative ( (<$>) )
+import Data.Char (isSpace)
type Refs = [([Inline], Target)]
@@ -253,7 +254,52 @@ blockListToRST blocks = mapM blockToRST blocks >>= return . vcat
-- | Convert list of Pandoc inline elements to RST.
inlineListToRST :: [Inline] -> State WriterState Doc
-inlineListToRST lst = mapM inlineToRST lst >>= return . hcat
+inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat
+ where insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed
+ insertBS (x:y:z:zs)
+ | isComplex y && surroundComplex x z =
+ x : y : RawInline "rst" "\\ " : insertBS (z:zs)
+ insertBS (x:y:zs)
+ | isComplex x && not (okAfterComplex y) =
+ x : RawInline "rst" "\\ " : insertBS (y : zs)
+ | isComplex y && not (okBeforeComplex x) =
+ x : RawInline "rst" "\\ " : insertBS (y : zs)
+ | otherwise =
+ x : insertBS (y : zs)
+ insertBS (x:ys) = x : insertBS ys
+ insertBS [] = []
+ surroundComplex :: Inline -> Inline -> Bool
+ surroundComplex (Str s@(_:_)) (Str s'@(_:_)) =
+ case (last s, head s') of
+ ('\'','\'') -> True
+ ('"','"') -> True
+ ('<','>') -> True
+ ('[',']') -> True
+ ('{','}') -> True
+ _ -> False
+ surroundComplex _ _ = False
+ okAfterComplex :: Inline -> Bool
+ okAfterComplex Space = True
+ okAfterComplex LineBreak = True
+ okAfterComplex (Str (c:_)) = isSpace c || c `elem` "-.,:;!?\\/'\")]}>–—"
+ okAfterComplex _ = False
+ okBeforeComplex :: Inline -> Bool
+ okBeforeComplex Space = True
+ okBeforeComplex LineBreak = True
+ okBeforeComplex (Str (c:_)) = isSpace c || c `elem` "-:/'\"<([{–—"
+ okBeforeComplex _ = False
+ isComplex :: Inline -> Bool
+ isComplex (Emph _) = True
+ isComplex (Strong _) = True
+ isComplex (SmallCaps _) = True
+ isComplex (Strikeout _) = True
+ isComplex (Superscript _) = True
+ isComplex (Subscript _) = True
+ isComplex (Link _ _) = True
+ isComplex (Image _ _) = True
+ isComplex (Code _ _) = True
+ isComplex (Math _ _) = True
+ isComplex _ = False
-- | Convert Pandoc inline element to RST.
inlineToRST :: Inline -> State WriterState Doc
@@ -268,10 +314,10 @@ inlineToRST (Strikeout lst) = do
return $ "[STRIKEOUT:" <> contents <> "]"
inlineToRST (Superscript lst) = do
contents <- inlineListToRST lst
- return $ "\\ :sup:`" <> contents <> "`\\ "
+ return $ ":sup:`" <> contents <> "`"
inlineToRST (Subscript lst) = do
contents <- inlineListToRST lst
- return $ "\\ :sub:`" <> contents <> "`\\ "
+ return $ ":sub:`" <> contents <> "`"
inlineToRST (SmallCaps lst) = inlineListToRST lst
inlineToRST (Quoted SingleQuote lst) = do
contents <- inlineListToRST lst
@@ -286,11 +332,12 @@ inlineToRST (Str str) = return $ text $ escapeString str
inlineToRST (Math t str) = do
modify $ \st -> st{ stHasMath = True }
return $ if t == InlineMath
- then ":math:`" <> text str <> "`" <> beforeNonBlank "\\ "
+ then ":math:`" <> text str <> "`"
else if '\n' `elem` str
then blankline $$ ".. math::" $$
blankline $$ nest 3 (text str) $$ blankline
else blankline $$ (".. math:: " <> text str) $$ blankline
+inlineToRST (RawInline "rst" x) = return $ text x
inlineToRST (RawInline _ _) = return empty
inlineToRST (LineBreak) = return cr -- there's no line break in RST
inlineToRST Space = return space
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
index 563ad7044..45e4c439f 100644
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -415,7 +415,7 @@ inlineToTexinfo (Image alternate (source, _)) = do
text (ext ++ "}")
where
ext = drop 1 $ takeExtension source'
- base = takeBaseName source'
+ base = dropExtension source'
source' = if isAbsoluteURI source
then source
else unEscapeString source
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 3853d360a..dab7b4161 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -295,14 +295,13 @@ options =
, Option "V" ["variable"]
(ReqArg
- (\arg opt ->
- case break (`elem` ":=") arg of
- (k,_:v) -> do
- let newvars = optVariables opt ++ [(k,v)]
- return opt{ optVariables = newvars }
- _ -> err 17 $
- "Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)")
- "KEY:VALUE")
+ (\arg opt -> do
+ let (key,val) = case break (`elem` ":=") arg of
+ (k,_:v) -> (k,v)
+ (k,_) -> (k,"true")
+ let newvars = optVariables opt ++ [(key,val)]
+ return opt{ optVariables = newvars })
+ "KEY[:VALUE]")
"" -- "Use custom template"
, Option "D" ["print-default-template"]
@@ -833,10 +832,12 @@ main = do
let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
+ let laTeXOutput = writerName' == "latex" || writerName' == "beamer" ||
+ writerName' == "latex+lhs" || writerName' == "beamer+lhs"
+
when pdfOutput $ do
-- make sure writer is latex or beamer
- unless (writerName' == "latex" || writerName' == "beamer" ||
- writerName' == "latex+lhs") $
+ unless laTeXOutput $
err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer"
-- check for latex program
mbLatex <- findExecutable latexEngine
@@ -916,14 +917,13 @@ main = do
lhsExtension sources,
stateStandalone = standalone',
stateCitations = map CSL.refId refs,
- stateSmart = smart || writerName' `elem`
- ["latex", "context", "latex+lhs", "beamer"],
+ stateSmart = smart || laTeXOutput || writerName' == "context",
stateOldDashes = oldDashes,
stateColumns = columns,
stateStrict = strict,
stateIndentedCodeClasses = codeBlockClasses,
- stateApplyMacros = writerName' `notElem`
- ["latex", "latex+lhs", "beamer"] }
+ stateApplyMacros = not laTeXOutput
+ }
let writerOptions = defaultWriterOptions
{ writerStandalone = standalone',
@@ -945,8 +945,7 @@ main = do
writerReferenceLinks = referenceLinks,
writerWrapText = wrap,
writerColumns = columns,
- writerLiterateHaskell = "+lhs" `isSuffixOf` writerName' ||
- lhsExtension [outputFile],
+ writerLiterateHaskell = False,
writerEmailObfuscation = if strict
then ReferenceObfuscation
else obfuscationMethod,
@@ -957,7 +956,7 @@ main = do
slideVariant == DZSlides,
writerChapters = chapters,
writerListings = listings,
- writerBeamer = writerName' == "beamer",
+ writerBeamer = False,
writerSlideLevel = slideLevel,
writerHighlight = highlight,
writerHighlightStyle = highlightStyle,
@@ -980,9 +979,7 @@ main = do
let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
- let handleIncludes' = if readerName' == "latex" || readerName' == "beamer" ||
- readerName' == "latex+lhs" ||
- readerName' == "context"
+ let handleIncludes' = if readerName' == "latex" || readerName' == "latex+lhs"
then handleIncludes
else return
@@ -1029,18 +1026,18 @@ main = do
| writerName' == "docx" ->
writeDocx referenceDocx writerOptions doc2 >>= writeBinary
| otherwise -> err 9 ("Unknown writer: " ++ writerName')
- Just _
+ Just w
| pdfOutput -> do
- res <- tex2pdf latexEngine $ writeLaTeX writerOptions doc2
+ res <- tex2pdf latexEngine $ w writerOptions doc2
case res of
Right pdf -> writeBinary pdf
Left err' -> err 43 $ toString err'
- Just r
+ Just w
| htmlFormat && ascii ->
writerFn outputFile =<< selfcontain (toEntities result)
| otherwise ->
writerFn outputFile =<< selfcontain result
- where result = r writerOptions doc2 ++ ['\n' | not standalone']
+ where result = w writerOptions doc2 ++ ['\n' | not standalone']
htmlFormat = writerName' `elem`
["html","html+lhs","html5","html5+lhs",
"s5","slidy","dzslides"]
diff --git a/templates/default.beamer b/templates/default.beamer
index db9210ef1..b8d1b8fe0 100644
--- a/templates/default.beamer
+++ b/templates/default.beamer
@@ -41,12 +41,6 @@ $if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
$if(fancy-enums)$
-% Redefine labelwidth for lists; otherwise, the enumerate package will cause
-% markers to extend beyond the left margin.
-\makeatletter\AtBeginDocument{%
- \renewcommand{\@listi}
- {\setlength{\labelwidth}{4em}}
-}\makeatother
\usepackage{enumerate}
$endif$
$if(tables)$
diff --git a/templates/default.context b/templates/default.context
index f2710a8e9..54cc8ea09 100644
--- a/templates/default.context
+++ b/templates/default.context
@@ -2,6 +2,9 @@
\enableregime[utf-8]
\setupcolors[state=start]
\stopmode
+$if(mainlang)$
+\mainlanguage[$mainlang$]
+$endif$
% Enable hyperlinks
\setupinteraction[state=start, color=middleblue]
@@ -16,9 +19,15 @@
\setupwhitespace[medium]
-\setuphead[section] [style=\tfc$if(number-sections)$$else$,number=no$endif$]
-\setuphead[subsection] [style=\tfb$if(number-sections)$$else$,number=no$endif$]
-\setuphead[subsubsection][style=\bf$if(number-sections)$$else$,number=no$endif$]
+\setuphead[chapter] [style=\tfd]
+\setuphead[section] [style=\tfc]
+\setuphead[subsection] [style=\tfb]
+\setuphead[subsubsection][style=\bf]
+
+$if(number-sections)$
+$else$
+\setuphead[chapter, section, subsection, subsubsection][number=no]
+$endif$
\definedescription
[description]
diff --git a/templates/default.dzslides b/templates/default.dzslides
index 33e1ee098..48e3e8027 100644
--- a/templates/default.dzslides
+++ b/templates/default.dzslides
@@ -20,7 +20,7 @@ $endfor$
$else$
<style>
html { background-color: black; }
- body { background-color: white; }
+ body { background-color: white; border-radius: 12px}
/* A section is a slide. It's size is 800x600, and this will never change */
section {
font-family: Arial, serif;
@@ -39,20 +39,24 @@ $else$
h1 { font-size: 180%; }
h2 { font-size: 120%; }
h3 { font-size: 100%; }
+ q { quotes: "“" "”" "‘" "’"; }
blockquote { font-style: italic }
- q {
- display: inline-block;
- width: 700px;
- height: 600px;
+ /* Figures are displayed full-page, with the caption on
+ top of the image/video */
+ figure {
background-color: black;
- color: white;
- font-size: 60px;
- padding: 50px;
+ }
+ figcaption {
+ margin: 70px;
}
footer {
position: absolute;
- bottom: 10px;
- right: 20px;
+ bottom: 0;
+ width: 100%;
+ padding: 40px;
+ text-align: right;
+ background-color: #F3F4F8;
+ border-top: 1px solid #CCC;
}
/* Transition effect */
diff --git a/templates/default.html5 b/templates/default.html5
index 47a3fc934..800f8a626 100644
--- a/templates/default.html5
+++ b/templates/default.html5
@@ -13,6 +13,11 @@ $endif$
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
+$if(quotes)$
+ <style type="text/css">
+ q { quotes: "“" "”" "‘" "’"; }
+ </style>
+$endif$
$if(highlighting-css)$
<style type="text/css">
$highlighting-css$
diff --git a/templates/default.latex b/templates/default.latex
index d244ef7b9..f181ee24a 100644
--- a/templates/default.latex
+++ b/templates/default.latex
@@ -1,17 +1,49 @@
-\documentclass[$if(fontsize)$$fontsize$,$endif$]{$documentclass$}
+\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$]{$documentclass$}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
+$if(mainfont)$
+ \setmainfont{$mainfont$}
+$endif$
+$if(sansfont)$
+ \setsansfont{$sansfont$}
+$endif$
+$if(monofont)$
+ \setmonofont{$monofont$}
+$endif$
+$if(mathfont)$
+ \setmathfont{$mathfont$}
+$endif$
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
+$if(mainfont)$
+ \setmainfont{$mainfont$}
+$endif$
+$if(sansfont)$
+ \setsansfont{$sansfont$}
+$endif$
+$if(monofont)$
+ \setmonofont{$monofont$}
+$endif$
+$if(mathfont)$
+ \setmathfont{$mathfont$}
+$endif$
\else
\usepackage[utf8]{inputenc}
+$if(euro)$
+ \usepackage{eurosym}
+$endif$
\fi
\fi
+$if(geometry)$
+\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
+$endif$
$if(natbib)$
\usepackage{natbib}
\bibliographystyle{plainnat}
@@ -66,10 +98,16 @@ $endif$
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex,
+ bookmarks=true,
+ pdfauthor={$author-meta$},
+ pdftitle={$title-meta$},
colorlinks=true,
linkcolor=blue]{hyperref}
\else
\usepackage[unicode=true,
+ bookmarks=true,
+ pdfauthor={$author-meta$},
+ pdftitle={$title-meta$},
colorlinks=true,
linkcolor=blue]{hyperref}
\fi
@@ -93,7 +131,12 @@ $if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$if(lang)$
-\usepackage[$lang$]{babel}
+\ifxetex
+ \usepackage{polyglossia}
+ \setmainlanguage{$mainlang$}
+\else
+ \usepackage[$lang$]{babel}
+\fi
$endif$
$for(header-includes)$
$header-includes$
diff --git a/tests/latex-reader.latex b/tests/latex-reader.latex
index 119ad0881..cd424baec 100644
--- a/tests/latex-reader.latex
+++ b/tests/latex-reader.latex
@@ -631,6 +631,13 @@ Dog & 2 \\
Cat & 1 \\ \hline
\end{tabular}
+A table with one column:
+
+\begin{tabular}{c}
+Animal \\
+Vegetable
+\end{tabular}
+
\begin{center}\rule{3in}{0.4pt}\end{center}
\section{Special Characters}
diff --git a/tests/latex-reader.native b/tests/latex-reader.native
index c6f6ce500..2873529ae 100644
--- a/tests/latex-reader.native
+++ b/tests/latex-reader.native
@@ -281,6 +281,11 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docA
,[Plain [Str "2"]]]
,[[Plain [Str "Cat"]]
,[Plain [Str "1"]]]]
+,Para [Str "A",Space,Str "table",Space,Str "with",Space,Str "one",Space,Str "column:"]
+,Table [] [AlignCenter] [0.0]
+ [[]]
+ [[[Plain [Str "Animal"]]]
+ ,[[Plain [Str "Vegetable"]]]]
,HorizontalRule
,Header 1 [Str "Special",Space,Str "Characters"]
,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
diff --git a/tests/lhs-test.latex b/tests/lhs-test.latex
index 4bb2ab1a6..307139499 100644
--- a/tests/lhs-test.latex
+++ b/tests/lhs-test.latex
@@ -4,10 +4,12 @@
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
\else
\usepackage[utf8]{inputenc}
\fi
@@ -36,10 +38,16 @@
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex,
+ bookmarks=true,
+ pdfauthor={},
+ pdftitle={},
colorlinks=true,
linkcolor=blue]{hyperref}
\else
\usepackage[unicode=true,
+ bookmarks=true,
+ pdfauthor={},
+ pdftitle={},
colorlinks=true,
linkcolor=blue]{hyperref}
\fi
diff --git a/tests/lhs-test.latex+lhs b/tests/lhs-test.latex+lhs
index d80d02a38..cda150107 100644
--- a/tests/lhs-test.latex+lhs
+++ b/tests/lhs-test.latex+lhs
@@ -4,10 +4,12 @@
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
\else
\usepackage[utf8]{inputenc}
\fi
@@ -18,10 +20,16 @@
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex,
+ bookmarks=true,
+ pdfauthor={},
+ pdftitle={},
colorlinks=true,
linkcolor=blue]{hyperref}
\else
\usepackage[unicode=true,
+ bookmarks=true,
+ pdfauthor={},
+ pdftitle={},
colorlinks=true,
linkcolor=blue]{hyperref}
\fi
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index e0eb4d438..bf794c849 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -312,4 +312,12 @@ Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":
,Para [Math DisplayMath "E = mc^2"]
,Para [Math DisplayMath "E = mc^2",Math DisplayMath "\\alpha = \\beta"]
,Para [Math DisplayMath "E &= mc^2\\\\\nF &= \\pi E",Math DisplayMath "F &= \\gamma \\alpha^2"]
-,Para [Str "All",Space,Str "done",Str "."]]
+,Para [Str "All",Space,Str "done",Str "."]
+,Header 1 [Str "Default",Str "-",Str "Role"]
+,Para [Str "Try",Space,Str "changing",Space,Str "the",Space,Str "default",Space,Str "role",Space,Str "to",Space,Str "a",Space,Str "few",Space,Str "different",Space,Str "things",Str "."]
+,Header 2 [Str "Doesn",Str "\8217",Str "t",Space,Str "Break",Space,Str "Title",Space,Str "Parsing"]
+,Para [Str "Inline",Space,Str "math",Str ":",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Other",Space,Str "roles",Str ":",Space,Superscript [Str "super"],Str ",",Space,Subscript [Str "sub"],Str "."]
+,Para [Math DisplayMath "\\alpha = beta",Math DisplayMath "E = mc^2"]
+,Para [Str "Some",Space,Superscript [Str "of"],Space,Str "these",Space,Superscript [Str "words"],Space,Str "are",Space,Str "in",Space,Superscript [Str "superscript"],Str "."]
+,Para [Str "Reset",Space,Str "default",Str "-",Str "role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default",Str "."]
+,Para [Str "And",Space,Str "now",Space,Str "`",Str "some",Str "-",Str "invalid",Str "-",Str "string",Str "-",Str "3231231",Str "`",Space,Str "is",Space,Str "nonsense",Str "."]]
diff --git a/tests/rst-reader.rst b/tests/rst-reader.rst
index cfebd2054..abe6d4f69 100644
--- a/tests/rst-reader.rst
+++ b/tests/rst-reader.rst
@@ -565,3 +565,31 @@ display math:
All done.
+Default-Role
+============
+
+Try changing the default role to a few different things.
+
+.. default-role:: math
+
+Doesn't Break Title Parsing
+---------------------------
+
+Inline math: `E=mc^2` or :math:`E=mc^2` or `E=mc^2`:math:.
+Other roles: :sup:`super`, `sub`:sub:.
+
+.. math::
+ \alpha = beta
+
+ E = mc^2
+
+.. default-role:: sup
+
+Some `of` these :sup:`words` are in `superscript`:sup:.
+
+Reset default-role to the default default.
+
+.. default-role::
+
+And now `some-invalid-string-3231231` is nonsense.
+
diff --git a/tests/tables.latex b/tests/tables.latex
index 21ad73b0a..7025452ae 100644
--- a/tests/tables.latex
+++ b/tests/tables.latex
@@ -1,6 +1,6 @@
Simple table with caption:
-\ctable[caption = Demonstration of simple table syntax.,
+\ctable[caption = {Demonstration of simple table syntax.},
pos = H, center, botcap]{rlcl}
{% notes
}
@@ -35,7 +35,7 @@ Right & Left & Center & Default
Simple table indented two spaces:
-\ctable[caption = Demonstration of simple table syntax.,
+\ctable[caption = {Demonstration of simple table syntax.},
pos = H, center, botcap]{rlcl}
{% notes
}
@@ -53,7 +53,7 @@ Right & Left & Center & Default
Multiline table with caption:
-\ctable[caption = Here's the caption. It may span multiple lines.,
+\ctable[caption = {Here's the caption. It may span multiple lines.},
pos = H, center, botcap]{clrl}
{% notes
}
diff --git a/tests/writer.context b/tests/writer.context
index 3aaf8c14b..7f8d8a115 100644
--- a/tests/writer.context
+++ b/tests/writer.context
@@ -16,9 +16,12 @@
\setupwhitespace[medium]
-\setuphead[section] [style=\tfc,number=no]
-\setuphead[subsection] [style=\tfb,number=no]
-\setuphead[subsubsection][style=\bf,number=no]
+\setuphead[chapter] [style=\tfd]
+\setuphead[section] [style=\tfc]
+\setuphead[subsection] [style=\tfb]
+\setuphead[subsubsection][style=\bf]
+
+\setuphead[chapter, section, subsection, subsubsection][number=no]
\definedescription
[description]
diff --git a/tests/writer.latex b/tests/writer.latex
index 4ce579516..0600efa1e 100644
--- a/tests/writer.latex
+++ b/tests/writer.latex
@@ -4,10 +4,12 @@
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
\else
\usepackage[utf8]{inputenc}
\fi
@@ -35,10 +37,16 @@
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex,
+ bookmarks=true,
+ pdfauthor={John MacFarlane; Anonymous},
+ pdftitle={Pandoc Test Suite},
colorlinks=true,
linkcolor=blue]{hyperref}
\else
\usepackage[unicode=true,
+ bookmarks=true,
+ pdfauthor={John MacFarlane; Anonymous},
+ pdftitle={Pandoc Test Suite},
colorlinks=true,
linkcolor=blue]{hyperref}
\fi
@@ -591,7 +599,7 @@ a\textsuperscript{hello~there}.
Subscripts: H\textsubscr{2}O, H\textsubscr{23}O, H\textsubscr{many~of~them}O.
These should not be superscripts or subscripts, because of the unescaped
-spaces: a\^{}b c\^{}d, a\ensuremath{\sim}b c\ensuremath{\sim}d.
+spaces: a\^{}b c\^{}d, a\textasciitilde{}b c\textasciitilde{}d.
\begin{center}\rule{3in}{0.4pt}\end{center}
diff --git a/tests/writer.rst b/tests/writer.rst
index 09fd8dcb3..8d7c7915c 100644
--- a/tests/writer.rst
+++ b/tests/writer.rst
@@ -563,7 +563,7 @@ This is code: ``>``, ``$``, ``\``, ``\$``, ``<html>``.
[STRIKEOUT:This is *strikeout*.]
-Superscripts: a\ :sup:`bc`\ d a\ :sup:`*hello*`\ a\ :sup:`hello there`\ .
+Superscripts: a\ :sup:`bc`\ d a\ :sup:`*hello*` a\ :sup:`hello there`.
Subscripts: H\ :sub:`2`\ O, H\ :sub:`23`\ O, H\ :sub:`many of them`\ O.
@@ -602,12 +602,12 @@ LaTeX
- :math:`x \in y`
- :math:`\alpha \wedge \omega`
- :math:`223`
-- :math:`p`\ -Tree
+- :math:`p`-Tree
- Here’s some display math:
.. math:: \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
-- Here’s one that has a line break in it: :math:`\alpha + \omega \times x^2`\ .
+- Here’s one that has a line break in it: :math:`\alpha + \omega \times x^2`.
These shouldn’t be math: