aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml186
-rw-r--r--CONTRIBUTING.md29
-rw-r--r--INSTALL2
-rw-r--r--README9
-rw-r--r--data/sample.lua2
-rw-r--r--deb/stack.yaml6
-rw-r--r--osx/stack.yaml6
-rw-r--r--pandoc.cabal4
-rw-r--r--src/Text/Pandoc/Options.hs1
-rw-r--r--src/Text/Pandoc/Readers/Docx/Reducible.hs2
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs50
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs3
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs4
-rw-r--r--src/Text/Pandoc/Writers/Custom.hs4
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs7
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs28
-rw-r--r--stack.full.yaml6
-rw-r--r--stack.yaml13
-rw-r--r--tests/Tests/Readers/Docx.hs4
-rw-r--r--tests/docx/adjacent_links.docxbin0 -> 8538 bytes
-rw-r--r--tests/docx/adjacent_links.native1
-rw-r--r--tests/tables.html28
-rw-r--r--windows/stack.yaml4
23 files changed, 249 insertions, 150 deletions
diff --git a/.travis.yml b/.travis.yml
index 2901288e9..9c031216f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,87 +1,125 @@
-# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
-language: c
+# Copy these contents into the root directory of your Github project in a file
+# named .travis.yml
+
+# Use new container infrastructure to enable caching
sudo: false
+# Choose a lightweight base image; we provide our own build tools.
+language: c
+
+# Caching so the next build will be fast too.
cache:
directories:
- - $HOME/.cabsnap
- - $HOME/.cabal/packages
-
-before_cache:
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
+ - $HOME/.ghc
+ - $HOME/.cabal
+ - $HOME/.stack
+# The different configurations we want to test. We have BUILD=cabal which uses
+# cabal-install, and BUILD=stack which uses Stack. More documentation on each
+# of those below.
+#
+# We set the compiler values here to tell Travis to use a different
+# cache file per set of arguments.
+#
+# If you need to have different apt packages for each combination in the
+# matrix, you can use a line such as:
+# addons: {apt: {packages: [libfcgi-dev,libgmp-dev]}}
matrix:
include:
- - env: CABALVER=1.16 GHCVER=7.4.2 GHCOPTS=-Werror
- compiler: ": #GHC 7.4.2"
- addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}}
- - env: CABALVER=1.16 GHCVER=7.6.3 GHCOPTS=-Werror
- compiler: ": #GHC 7.6.3"
- addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
- - env: CABALVER=1.18 GHCVER=7.8.4 GHCOPTS=-Werror
- compiler: ": #GHC 7.8.4"
- addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
- - env: CABALVER=1.22 GHCVER=7.10.2 GHCOPTS=-Werror
- compiler: ": #GHC 7.10.2"
- addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}}
+ # We grab the appropriate GHC and cabal-install versions from hvr's PPA. See:
+ # https://github.com/hvr/multi-ghc-travis
+ - env: BUILD=cabal GHCVER=7.4.2 CABALVER=1.16
+ compiler: ": #GHC 7.4.2"
+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}}
+ - env: BUILD=cabal GHCVER=7.6.3 CABALVER=1.16
+ compiler: ": #GHC 7.6.3"
+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
+ - env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18
+ compiler: ": #GHC 7.8.4"
+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
+ - env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22
+ compiler: ": #GHC 7.10.3"
+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
-before_install:
- - unset CC
- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
+ # Build with the newest GHC and cabal-install. This is an accepted failure,
+ # see below.
+ - env: BUILD=cabal GHCVER=head CABALVER=head
+ compiler: ": #GHC HEAD"
+ addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
-install:
- - cabal --version
- - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
- - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
- then
- zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
- $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
- fi
- - travis_retry cabal update -v
- - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
- - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
- - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
+ # The Stack builds. We can pass in arbitrary Stack arguments via the ARGS
+ # variable, such as using --stack-yaml to point to a different file.
+ - env: BUILD=stack ARGS="--resolver lts-5"
+ compiler: ": #stack 7.10.3"
+ addons: {apt: {packages: [ghc-7.10.3], sources: [hvr-ghc]}}
-# check whether current requested install-plan matches cached package-db snapshot
- - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
- then
- echo "cabal build-cache HIT";
- rm -rfv .ghc;
- cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
- cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
- else
- echo "cabal build-cache MISS";
- rm -rf $HOME/.cabsnap;
- mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
- cabal install --only-dependencies --enable-tests --enable-benchmarks;
- fi
-
-# snapshot package-db on cache miss
- - if [ ! -d $HOME/.cabsnap ];
- then
- echo "snapshotting package-db to build-cache";
- mkdir $HOME/.cabsnap;
- cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
- cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
- fi
+ # Nightly builds are allowed to fail
+ - env: BUILD=stack ARGS="--resolver nightly"
+ compiler: ": #stack nightly"
+ addons: {apt: {packages: [libgmp-dev]}}
-# Here starts the actual work to be performed for the package under test;
-# any command which exits with a non-zero exit code causes the build to fail.
-script:
- - if [ -f configure.ac ]; then autoreconf -i; fi
- - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
- - cabal build --ghc-options=$GHCOPTS # this builds all libraries and executables (including tests/benchmarks)
- - cabal test
- - cabal check
-# Test that a source-distribution can be generated
-# (with cabal >= 1.18 'cabal sdist' would work too):
- - ./dist/setup/setup sdist
+ - env: BUILD=stack ARGS="--resolver lts-5"
+ compiler: ": #stack 7.10.3 osx"
+ os: osx
-# Check that the resulting source distribution can be built & installed.
-# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
-# `cabal install --force-reinstalls dist/*-*.tar.gz`
- - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
- (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
+ - env: BUILD=stack ARGS="--resolver nightly"
+ compiler: ": #stack nightly osx"
+ os: osx
-# EOF
+ allow_failures:
+ - env: BUILD=cabal GHCVER=head CABALVER=head
+ - env: BUILD=stack ARGS="--resolver nightly"
+
+before_install:
+# Using compiler above sets CC to an invalid value, so unset it
+- unset CC
+
+# We want to always allow newer versions of packages when building on GHC HEAD
+- CABALARGS=""
+- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi
+
+# Download and unpack the stack executable
+- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:$PATH
+- mkdir -p ~/.local/bin
+- |
+ if [ `uname` = "Darwin" ]
+ then
+ curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
+ else
+ curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
+ fi
+
+install:
+- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
+- if [ -f configure.ac ]; then autoreconf -i; fi
+- |
+ case "$BUILD" in
+ stack)
+ stack --no-terminal --install-ghc $ARGS test --only-dependencies
+ ;;
+ cabal)
+ cabal --version
+ travis_retry cabal update
+ cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS
+ ;;
+ esac
+
+script:
+- |
+ case "$BUILD" in
+ stack)
+ stack --no-terminal $ARGS test --haddock --no-haddock-deps
+ ;;
+ cabal)
+ cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options="-O0 -Werror"
+ cabal build
+ cabal check || [ "$CABALVER" == "1.16" ]
+ cabal test
+ cabal copy
+ # cabal sdist fails on cabal 1.16:
+ cabal sdist || [ "$CABALVER" == "1.16" ]
+ SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && \
+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ" || \
+ [ "$CABALVER" == "1.16" ])
+ ;;
+ esac
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index eff033057..f39acab10 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -145,21 +145,40 @@ Tests
Tests can be run as follows:
+ cabal install --only-dependencies --enable-tests
cabal configure --enable-tests
cabal build
cabal test
+or, if you're using [stack],
+
+ stack init
+ stack test
+
The test program is `tests/test-pandoc.hs`.
-Benchmarks can be enabled by passing the `--enable-benchmarks` flag
-to `cabal configure`, and run using `cabal bench`.
+Benchmarks
+----------
+
+To run benchmarks with cabal:
+
+ cabal configure --enable-benchmarks
+ cabal build
+ cabal bench
+
+With stack:
+
+ stack bench
Using the REPL
--------------
With a recent version of cabal, you can do `cabal repl` and get
-a ghci REPL for working with pandoc. We recommend using the following
-`.ghci` file (which can be placed in the source directory):
+a ghci REPL for working with pandoc. With [stack], use
+`cabal ghci`.
+
+We recommend using the following `.ghci` file (which can be
+placed in the source directory):
```
:set -fobject-code
@@ -266,3 +285,5 @@ The library is structured as follows:
[inprogress]: https://github.com/jgm/pandoc/labels/inprogress
[more discussion needed]: https://github.com/jgm/pandoc/labels/More%20discussion%20needed
[more info needed]: https://github.com/jgm/pandoc/labels/More%20info%20needed
+[stack]: https://github.com/commercialhaskell/stack
+
diff --git a/INSTALL b/INSTALL
index 3cb428db9..319c23d43 100644
--- a/INSTALL
+++ b/INSTALL
@@ -11,7 +11,7 @@ https://github.com/jgm/pandoc/wiki/Installing-the-development-version-of-pandoc
Quick install with stack
------------------------
-1. Install [stack](https://github.com/commercialhaskell/stack/wiki/Downloads).
+1. Install [stack](http://docs.haskellstack.org/en/stable/install_and_upgrade.html).
2. If you used git to get the pandoc source (as opposed to unpacking
a release tarball), do
diff --git a/README b/README
index d0d0ddd6b..f5179dc89 100644
--- a/README
+++ b/README
@@ -580,7 +580,7 @@ General writer options
: Include contents of *FILE*, verbatim, at the end of the document
body (before the `</body>` tag in HTML, or the
- `\end{document}` command in LaTeX). This option can be be used
+ `\end{document}` command in LaTeX). This option can be used
repeatedly to include multiple files. They will be included in the
order specified. Implies `--standalone`.
@@ -716,7 +716,7 @@ Options affecting specific writers
`-c` *URL*, `--css=`*URL*
-: Link to a CSS style sheet. This option can be be used repeatedly to
+: Link to a CSS style sheet. This option can be used repeatedly to
include multiple files. They will be included in the order specified.
`--reference-odt=`*FILE*
@@ -1091,7 +1091,7 @@ Language variables
in the YAML metadata, according to [BCP 47]. For example:
`otherlangs: [en-GB, fr]`.
This is automatically generated from the `lang` attributes
- in all `span`s and `div`s but can be overriden.
+ in all `span`s and `div`s but can be overridden.
Currently only used by LaTeX through the generated
`babel-otherlangs` and `polyglossia-otherlangs` variables.
The LaTeX writer outputs polyglossia commands in the text but
@@ -3378,8 +3378,7 @@ variants are supported:
`shortcut_reference_links`.
`markdown_github` (GitHub-Flavored Markdown)
-: `pipe_tables`, `raw_html`, `tex_math_single_backslash`,
- `fenced_code_blocks`, `auto_identifiers`,
+: `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,
`ascii_identifiers`, `backtick_code_blocks`, `autolink_bare_uris`,
`intraword_underscores`, `strikeout`, `hard_line_breaks`, `emoji`,
`shortcut_reference_links`.
diff --git a/data/sample.lua b/data/sample.lua
index 0cb492392..574f378cc 100644
--- a/data/sample.lua
+++ b/data/sample.lua
@@ -255,7 +255,7 @@ function html_align(align)
end
end
-function CaptionedImage(src, tit, caption)
+function CaptionedImage(src, tit, caption, attr)
return '<div class="figure">\n<img src="' .. escape(src,true) ..
'" title="' .. escape(tit,true) .. '"/>\n' ..
'<p class="caption">' .. caption .. '</p>\n</div>'
diff --git a/deb/stack.yaml b/deb/stack.yaml
index 3f84be738..9986ead40 100644
--- a/deb/stack.yaml
+++ b/deb/stack.yaml
@@ -15,8 +15,4 @@ packages:
- '..'
- 'https://hackage.haskell.org/package/pandoc-citeproc-0.9/pandoc-citeproc-0.9.tar.gz'
extra-deps:
-- 'cmark-0.5.0'
-- 'pandoc-types-1.16.0.1'
-# Use older aeson to avoid excessive memory use in compilation:
-- 'aeson-0.8.0.2'
-resolver: lts-4.0
+resolver: lts-5.2
diff --git a/osx/stack.yaml b/osx/stack.yaml
index d9decaba1..50a90f9d6 100644
--- a/osx/stack.yaml
+++ b/osx/stack.yaml
@@ -18,8 +18,4 @@ packages:
- '..'
- 'https://hackage.haskell.org/package/pandoc-citeproc-0.9/pandoc-citeproc-0.9.tar.gz'
extra-deps:
-- 'cmark-0.5.0'
-- 'pandoc-types-1.16.0.1'
-# Use older aeson to avoid excessive memory use in compilation:
-- 'aeson-0.8.0.2'
-resolver: lts-4.0
+resolver: lts-5.2
diff --git a/pandoc.cabal b/pandoc.cabal
index 1918e4879..d82a7e629 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -260,7 +260,7 @@ Library
random >= 1 && < 1.2,
extensible-exceptions >= 0.1 && < 0.2,
pandoc-types >= 1.16 && < 1.17,
- aeson >= 0.7 && < 0.11,
+ aeson >= 0.7 && < 0.12,
tagsoup >= 0.13.1 && < 0.14,
base64-bytestring >= 0.1 && < 1.1,
zlib >= 0.5 && < 0.7,
@@ -416,7 +416,7 @@ Executable pandoc
bytestring >= 0.9 && < 0.11,
extensible-exceptions >= 0.1 && < 0.2,
highlighting-kate >= 0.6.1 && < 0.7,
- aeson >= 0.7.0.5 && < 0.11,
+ aeson >= 0.7.0.5 && < 0.12,
yaml >= 0.8.8.2 && < 0.9,
containers >= 0.1 && < 0.6,
HTTP >= 4000.0.5 && < 4000.4
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 7dd47cd59..333f499fb 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -202,7 +202,6 @@ githubMarkdownExtensions :: Set Extension
githubMarkdownExtensions = Set.fromList
[ Ext_pipe_tables
, Ext_raw_html
- , Ext_tex_math_single_backslash
, Ext_fenced_code_blocks
, Ext_auto_identifiers
, Ext_ascii_identifiers
diff --git a/src/Text/Pandoc/Readers/Docx/Reducible.hs b/src/Text/Pandoc/Readers/Docx/Reducible.hs
index c93b40119..e6de2d474 100644
--- a/src/Text/Pandoc/Readers/Docx/Reducible.hs
+++ b/src/Text/Pandoc/Readers/Docx/Reducible.hs
@@ -53,6 +53,7 @@ instance Modifiable Inlines where
(Strikeout _) -> Modifier strikeout
(Superscript _) -> Modifier superscript
(Subscript _) -> Modifier subscript
+ (Link attr _ tgt) -> Modifier $ linkWith attr (fst tgt) (snd tgt)
(Span attr _) -> AttrModifier spanWith attr
_ -> NullModifier
_ -> NullModifier
@@ -65,6 +66,7 @@ instance Modifiable Inlines where
(Strikeout lst) -> fromList lst
(Superscript lst) -> fromList lst
(Subscript lst) -> fromList lst
+ (Link _ lst _) -> fromList lst
(Span _ lst) -> fromList lst
_ -> ils
_ -> ils
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 773ef6597..03b790d0b 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -445,6 +445,7 @@ pTable = try $ do
-- fail on empty table
guard $ not $ null head' && null rows
let isSinglePlain x = case B.toList x of
+ [] -> True
[Plain _] -> True
_ -> False
let isSimple = all isSinglePlain $ concat (head':rows)
@@ -929,14 +930,45 @@ htmlInBalanced :: (Monad m)
=> (Tag String -> Bool)
-> ParserT String st m String
htmlInBalanced f = try $ do
- (TagOpen t _, tag) <- htmlTag f
- guard $ not $ "/>" `isSuffixOf` tag -- not a self-closing tag
- let stopper = htmlTag (~== TagClose t)
- let anytag = snd <$> htmlTag (const True)
- contents <- many $ notFollowedBy' stopper >>
- (htmlInBalanced f <|> anytag <|> count 1 anyChar)
- endtag <- liftM snd stopper
- return $ tag ++ concat contents ++ endtag
+ lookAhead (char '<')
+ inp <- getInput
+ let ts = canonicalizeTags $
+ parseTagsOptions parseOptions{ optTagWarning = True,
+ optTagPosition = True } inp
+ case ts of
+ (TagPosition sr sc : t@(TagOpen tn _) : rest) -> do
+ guard $ f t
+ guard $ not $ hasTagWarning (t : take 1 rest)
+ case htmlInBalanced' tn (t:rest) of
+ [] -> mzero
+ xs -> case reverse xs of
+ (TagClose _ : TagPosition er ec : _) -> do
+ let ls = er - sr
+ let cs = ec - sc
+ lscontents <- concat <$> count ls anyLine
+ cscontents <- count cs anyChar
+ (_,closetag) <- htmlTag (~== TagClose tn)
+ return (lscontents ++ cscontents ++ closetag)
+ _ -> mzero
+ _ -> mzero
+
+htmlInBalanced' :: String
+ -> [Tag String]
+ -> [Tag String]
+htmlInBalanced' tagname ts = fromMaybe [] $ go 0 ts
+ where go :: Int -> [Tag String] -> Maybe [Tag String]
+ go n (t@(TagOpen tn' _):rest) | tn' == tagname =
+ (t :) <$> go (n + 1) rest
+ go 1 (t@(TagClose tn'):_) | tn' == tagname =
+ return [t]
+ go n (t@(TagClose tn'):rest) | tn' == tagname =
+ (t :) <$> go (n - 1) rest
+ go n (t:ts') = (t :) <$> go n ts'
+ go n [] = mzero
+
+hasTagWarning :: [Tag String] -> Bool
+hasTagWarning (TagWarning _:_) = True
+hasTagWarning _ = False
-- | Matches a tag meeting a certain condition.
htmlTag :: Monad m
@@ -945,8 +977,6 @@ htmlTag :: Monad m
htmlTag f = try $ do
lookAhead (char '<')
inp <- getInput
- let hasTagWarning (TagWarning _:_) = True
- hasTagWarning _ = False
let (next : rest) = canonicalizeTags $ parseTagsOptions
parseOptions{ optTagWarning = True } inp
guard $ f next
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 2acce8ece..9a1708331 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -422,7 +422,8 @@ inlineCommand = try $ do
else if parseRaw
then return $ rawInline "latex" rawcommand
else return mempty
- lookupListDefault mzero [name',name] inlineCommands
+ (lookupListDefault mzero [name',name] inlineCommands <*
+ optional (try (string "{}")))
<|> raw
unlessParseRaw :: LP ()
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 77c3a1016..82d343243 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -36,7 +36,7 @@ import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )
import qualified Data.Map as M
import Data.Scientific (coefficient, base10Exponent)
import Data.Ord ( comparing )
-import Data.Char ( isSpace, isAlphaNum, toLower )
+import Data.Char ( isSpace, isAlphaNum, toLower, isPunctuation )
import Data.Maybe
import Text.Pandoc.Definition
import Text.Pandoc.Emoji (emojis)
@@ -1554,7 +1554,7 @@ math :: MarkdownParser (F Inlines)
math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))
<|> (return . B.math <$> (mathInline >>= applyMacros')) <+?>
((getOption readerSmart >>= guard) *> (return <$> apostrophe)
- <* notFollowedBy space)
+ <* notFollowedBy (space <|> satisfy isPunctuation))
-- Parses material enclosed in *s, **s, _s, or __s.
-- Designed to avoid backtracking.
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs
index 9671fc05b..d69eaaa64 100644
--- a/src/Text/Pandoc/Writers/Custom.hs
+++ b/src/Text/Pandoc/Writers/Custom.hs
@@ -222,8 +222,8 @@ blockToCustom _ Null = return ""
blockToCustom lua (Plain inlines) = callfunc lua "Plain" inlines
-blockToCustom lua (Para [Image _ txt (src,tit)]) =
- callfunc lua "CaptionedImage" src tit txt
+blockToCustom lua (Para [Image attr txt (src,tit)]) =
+ callfunc lua "CaptionedImage" src tit txt (attrToMap attr)
blockToCustom lua (Para inlines) = callfunc lua "Para" inlines
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 6e199583e..c5b6a6db2 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -645,7 +645,7 @@ alignmentToString alignment = case alignment of
AlignLeft -> "left"
AlignRight -> "right"
AlignCenter -> "center"
- AlignDefault -> "left"
+ AlignDefault -> ""
tableItemToHtml :: WriterOptions
-> (Html -> Html)
@@ -658,7 +658,10 @@ tableItemToHtml opts tag' align' item = do
let attribs = if writerHtml5 opts
then A.style (toValue $ "text-align: " ++ alignStr ++ ";")
else A.align (toValue alignStr)
- return $ (tag' ! attribs $ contents) >> nl opts
+ let tag'' = if null alignStr
+ then tag'
+ else tag' ! attribs
+ return $ (tag'' $ contents) >> nl opts
toListItems :: WriterOptions -> [Html] -> [Html]
toListItems opts items = map (toListItem opts) items ++ [nl opts]
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index e4e882b8c..4e4279ec5 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -113,12 +113,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do
(fmap (render colwidth) . inlineListToLaTeX)
meta
let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
- let documentClass = case P.parse (do P.skipMany (P.satisfy (/='\\'))
- P.string "\\documentclass"
- P.skipMany (P.satisfy (/='{'))
- P.char '{'
- P.manyTill P.letter (P.char '}')) "template"
- template of
+ let documentClass = case P.parse pDocumentClass "template" template of
Right r -> r
Left _ -> ""
case lookup "documentclass" (writerVariables options) `mplus`
@@ -1260,3 +1255,24 @@ commonFromBcp47 x = fromIso $ head x
deNote :: Inline -> Inline
deNote (Note _) = RawInline (Format "latex") ""
deNote x = x
+
+pDocumentOptions :: P.Parsec String () [String]
+pDocumentOptions = do
+ P.char '['
+ opts <- P.sepBy
+ (P.many $ P.spaces *> P.noneOf (" ,]" :: String) <* P.spaces)
+ (P.char ',')
+ P.char ']'
+ return opts
+
+pDocumentClass :: P.Parsec String () String
+pDocumentClass =
+ do P.skipMany (P.satisfy (/='\\'))
+ P.string "\\documentclass"
+ classOptions <- pDocumentOptions <|> return []
+ if ("article" :: String) `elem` classOptions
+ then return "article"
+ else do P.skipMany (P.satisfy (/='{'))
+ P.char '{'
+ P.manyTill P.letter (P.char '}')
+
diff --git a/stack.full.yaml b/stack.full.yaml
index d79d25d0c..2d752d531 100644
--- a/stack.full.yaml
+++ b/stack.full.yaml
@@ -12,8 +12,4 @@ packages:
- '../pandoc-citeproc'
- '../pandoc-types'
- '../texmath'
-extra-deps:
-- 'cmark-0.5.0'
-# Use older aeson to avoid excessive memory use in compilation:
-- 'aeson-0.8.0.2'
-resolver: lts-4.0
+resolver: lts-5.2
diff --git a/stack.yaml b/stack.yaml
index 82f2f5073..21ff7bff7 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -7,10 +7,9 @@ flags:
network-uri: true
packages:
- '.'
-extra-deps:
-- 'cmark-0.5.1'
-- 'pandoc-citeproc-0.9'
-- 'pandoc-types-1.16.0.1'
-# Use older aeson to avoid excessive memory use in compilation:
-- 'aeson-0.8.0.2'
-resolver: lts-4.0
+extra-deps: []
+# to compile against aeson 0.11.0.0:
+# - 'aeson-0.11.0.0'
+# - 'fail-4.9.0.0'
+# - 'pandoc-types-1.16.1'
+resolver: lts-5.2
diff --git a/tests/Tests/Readers/Docx.hs b/tests/Tests/Readers/Docx.hs
index 086d3f964..9284d165a 100644
--- a/tests/Tests/Readers/Docx.hs
+++ b/tests/Tests/Readers/Docx.hs
@@ -111,6 +111,10 @@ tests = [ testGroup "inlines"
"docx/links.docx"
"docx/links.native"
, testCompare
+ "normalizing adjacent hyperlinks"
+ "docx/adjacent_links.docx"
+ "docx/adjacent_links.native"
+ , testCompare
"inline image"
"docx/image.docx"
"docx/image_no_embed.native"
diff --git a/tests/docx/adjacent_links.docx b/tests/docx/adjacent_links.docx
new file mode 100644
index 000000000..86b1c2a14
--- /dev/null
+++ b/tests/docx/adjacent_links.docx
Binary files differ
diff --git a/tests/docx/adjacent_links.native b/tests/docx/adjacent_links.native
new file mode 100644
index 000000000..cca861890
--- /dev/null
+++ b/tests/docx/adjacent_links.native
@@ -0,0 +1 @@
+[Para [Str "Le",Space,Str "plus",Space,Str "int\233ressant",Space,Str "\233tant",Space,Str "sans",Space,Str "doute",Space,Str "le",Space,Str "Marsan,",Space,Str "propos\233",Space,Str "par",Space,Str "Claude",Space,Str "Marsan",Space,Str "en",Space,Str "1976",Space,Str "qui",Space,Str "avait",Space,Str "m\234me",Space,Str "fait",Space,Str "l'objet",Space,Str "d'une",Space,Str "norme,",Space,Str "mais",Space,Str "qui",Space,Str "n'a",Space,Str "pas",Space,Str "du",Space,Str "tout",Space,Str "\233t\233",Space,Str "adopt\233",Space,Str "\224",Space,Str "cause",Space,Str "des",Space,Str "habitudes",Space,Str "trop",Space,Str "ancr\233es",Space,Str "et",Space,Str "qui",Space,Str "a",Space,Str "fini",Space,Str "par",Space,Str "tomber",Space,Str "dans",Space,Str "l'oubli,",Space,Str "gros",Space,Str "clin",Space,Str "d'\339il",Space,Str "\224",Space,Str "cela",Space,Str "d'ailleurs",Space,Str "dans",Space,Str "le",Space,Str "film",Space,Link ("",[],[]) [Emph [Str "\"Le",Space,Str "nom",Space,Str "des",Space,Str "gens\""]] ("http://www.allocine.fr/film/fichefilm_gen_cfilm=172167.html",""),Str ".",Space,Str "D\8217ailleurs",Space,Str "l\8217\233tat,",Space,Str "bien",Space,Str "conscient",Space,Str "que",Space,Str "tous",Space,Str "les",Space,Str "fran\231ais",Space,Str "\233crivent",Space,Str "sur",Space,Str "des",Space,Str "claviers",Space,Str "compl\232tement",Space,Str "inadapt\233s,",Space,Link ("",[],[]) [Emph [Str "tente",Space,Str "encore",Space,Str "une",Space,Str "fois",Space,Str "de",Space,Str "faire",Space,Str "une",Space,Str "norme",Space,Str "en",Space,Str "ce",Space,Str "moment",Space,Str "m\234me"]] ("http://www.appy-geek.com/Web/ArticleWeb.aspx?regionid=2&articleid=56103389&source=messenger",""),Str "."]]
diff --git a/tests/tables.html b/tests/tables.html
index f5ddf3bcd..0a9ea413c 100644
--- a/tests/tables.html
+++ b/tests/tables.html
@@ -6,7 +6,7 @@
<th align="right">Right</th>
<th align="left">Left</th>
<th align="center">Center</th>
-<th align="left">Default</th>
+<th>Default</th>
</tr>
</thead>
<tbody>
@@ -14,19 +14,19 @@
<td align="right">12</td>
<td align="left">12</td>
<td align="center">12</td>
-<td align="left">12</td>
+<td>12</td>
</tr>
<tr class="even">
<td align="right">123</td>
<td align="left">123</td>
<td align="center">123</td>
-<td align="left">123</td>
+<td>123</td>
</tr>
<tr class="odd">
<td align="right">1</td>
<td align="left">1</td>
<td align="center">1</td>
-<td align="left">1</td>
+<td>1</td>
</tr>
</tbody>
</table>
@@ -37,7 +37,7 @@
<th align="right">Right</th>
<th align="left">Left</th>
<th align="center">Center</th>
-<th align="left">Default</th>
+<th>Default</th>
</tr>
</thead>
<tbody>
@@ -45,19 +45,19 @@
<td align="right">12</td>
<td align="left">12</td>
<td align="center">12</td>
-<td align="left">12</td>
+<td>12</td>
</tr>
<tr class="even">
<td align="right">123</td>
<td align="left">123</td>
<td align="center">123</td>
-<td align="left">123</td>
+<td>123</td>
</tr>
<tr class="odd">
<td align="right">1</td>
<td align="left">1</td>
<td align="center">1</td>
-<td align="left">1</td>
+<td>1</td>
</tr>
</tbody>
</table>
@@ -69,7 +69,7 @@
<th align="right">Right</th>
<th align="left">Left</th>
<th align="center">Center</th>
-<th align="left">Default</th>
+<th>Default</th>
</tr>
</thead>
<tbody>
@@ -77,19 +77,19 @@
<td align="right">12</td>
<td align="left">12</td>
<td align="center">12</td>
-<td align="left">12</td>
+<td>12</td>
</tr>
<tr class="even">
<td align="right">123</td>
<td align="left">123</td>
<td align="center">123</td>
-<td align="left">123</td>
+<td>123</td>
</tr>
<tr class="odd">
<td align="right">1</td>
<td align="left">1</td>
<td align="center">1</td>
-<td align="left">1</td>
+<td>1</td>
</tr>
</tbody>
</table>
@@ -192,13 +192,13 @@
<td align="center">First</td>
<td align="left">row</td>
<td align="right">12.0</td>
-<td align="left">Example of a row that spans multiple lines.</td>
+<td>Example of a row that spans multiple lines.</td>
</tr>
<tr class="even">
<td align="center">Second</td>
<td align="left">row</td>
<td align="right">5.0</td>
-<td align="left">Here's another one. Note the blank line between rows.</td>
+<td>Here's another one. Note the blank line between rows.</td>
</tr>
</tbody>
</table>
diff --git a/windows/stack.yaml b/windows/stack.yaml
index 91f1c1539..a01dbfc03 100644
--- a/windows/stack.yaml
+++ b/windows/stack.yaml
@@ -15,7 +15,5 @@ packages:
- '..'
- '../../pandoc-citeproc'
extra-deps:
-- 'cmark-0.5.0'
- 'hsb2hs-0.3.1'
-- 'pandoc-types-1.16.0.1'
-resolver: lts-3.20
+resolver: lts-5.2