From 97b70d20bbd266d627a402360b0fd682f53355a3 Mon Sep 17 00:00:00 2001 From: Shin Sang-jae Date: Sat, 28 Nov 2020 02:11:40 +0900 Subject: EPUB: use preserveAspectRatio="xMidYMid" for cover image (#6895) This change affects both the epub2 and the epub3 templates. It avoids distortion of the cover image by requiring that the aspect ratio be preserved. --- data/templates/default.epub2 | 2 +- data/templates/default.epub3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/templates/default.epub2 b/data/templates/default.epub2 index f440134df..685d10208 100644 --- a/data/templates/default.epub2 +++ b/data/templates/default.epub2 @@ -48,7 +48,7 @@ $endif$ $else$ $if(coverpage)$
- +
diff --git a/data/templates/default.epub3 b/data/templates/default.epub3 index 4f5bd6641..fc4fa7620 100644 --- a/data/templates/default.epub3 +++ b/data/templates/default.epub3 @@ -49,7 +49,7 @@ $endif$ $else$ $if(coverpage)$
- +
-- cgit v1.2.3 From aab54c43258e53e4c1fde1b574c65ff8769709d0 Mon Sep 17 00:00:00 2001 From: Kolen Cheung Date: Wed, 2 Dec 2020 21:00:57 -0800 Subject: Add translations zh-Hans.yaml and zh-Hant.yaml Closes #6904, closes #6909. Co-authored-by: taotieren --- data/translations/zh-Hans.yaml | 22 ++++++++++++++++++++++ data/translations/zh-Hant.yaml | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 data/translations/zh-Hans.yaml create mode 100644 data/translations/zh-Hant.yaml (limited to 'data') diff --git a/data/translations/zh-Hans.yaml b/data/translations/zh-Hans.yaml new file mode 100644 index 000000000..d44ef41e3 --- /dev/null +++ b/data/translations/zh-Hans.yaml @@ -0,0 +1,22 @@ +Abstract: 摘要 +Appendix: 附录 +Bibliography: 文献目录 +Cc: 副本 +Chapter: 章 +Contents: 目录 +Encl: 附件 +Figure: 图 +Glossary: 术语 +Index: 索引 +Listing: 列表 +ListOfFigures: 附图目录 +ListOfTables: 表格索引 +Page: 页 +Part: 段 +Preface: 序 +Proof: 校对 +References: 参考文献 +See: 见 +SeeAlso: 参见 +Table: 表 +To: 到 diff --git a/data/translations/zh-Hant.yaml b/data/translations/zh-Hant.yaml new file mode 100644 index 000000000..60be44201 --- /dev/null +++ b/data/translations/zh-Hant.yaml @@ -0,0 +1,22 @@ +Abstract: 摘要 +Appendix: 附錄 +Bibliography: 文獻目錄 +Cc: 副本 +Chapter: 章 +Contents: 目錄 +Encl: 附件 +Figure: 圖 +Glossary: 術語 +Index: 索引 +Listing: 列表 +ListOfFigures: 附圖目錄 +ListOfTables: 表格索引 +Page: 頁 +Part: 段 +Preface: 序 +Proof: 校對 +References: 參考文獻 +See: 見 +SeeAlso: 參見 +Table: 表 +To: 到 -- cgit v1.2.3 From 8031ac137f9f84bf6c12d66592b07a3244b049a9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 7 Dec 2020 18:57:24 -0800 Subject: LaTeX template: include csquotes package if csquotes variable set. --- data/templates/default.latex | 3 +++ 1 file changed, 3 insertions(+) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 60af51225..169661582 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -391,6 +391,9 @@ $if(csl-refs)$ \newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} \newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} $endif$ +$if(csquotes)$ +\usepackage{csquotes} +$endif$ $if(title)$ \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} -- cgit v1.2.3 From f4839cc581ccca6292c52172624e7402095e9fb4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 18 Dec 2020 12:08:43 -0800 Subject: Remove some extraneous files in data directory. --- data/templates/.github/ISSUE_TEMPLATE.md | 3 - data/templates/.github/PULL_REQUEST_TEMPLATE.md | 4 -- data/vimwiki.css | 82 ------------------------- 3 files changed, 89 deletions(-) delete mode 100644 data/templates/.github/ISSUE_TEMPLATE.md delete mode 100644 data/templates/.github/PULL_REQUEST_TEMPLATE.md delete mode 100644 data/vimwiki.css (limited to 'data') diff --git a/data/templates/.github/ISSUE_TEMPLATE.md b/data/templates/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index ead4f6811..000000000 --- a/data/templates/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,3 +0,0 @@ -This repository is now maintained as a subtree of -[jgm/pandoc](https://github.com/jgm/pandoc). Please open -your issue there, not here. diff --git a/data/templates/.github/PULL_REQUEST_TEMPLATE.md b/data/templates/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7328f66a4..000000000 --- a/data/templates/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,4 +0,0 @@ -This repository is now maintained as a subtree of -[jgm/pandoc](https://github.com/jgm/pandoc). Please open -your pull request there, not here. - diff --git a/data/vimwiki.css b/data/vimwiki.css deleted file mode 100644 index 0a8841a32..000000000 --- a/data/vimwiki.css +++ /dev/null @@ -1,82 +0,0 @@ -pre{ - font-size: 1.5em -} - -img {vertical-align: middle} - -body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 120%; line-height: 130%;} -h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;} -h1 {font-size: 2.6em; color: #000000;} -h2 {font-size: 2.2em; color: #404040;} -h3 {font-size: 1.8em; color: #707070;} -h4 {font-size: 1.4em; color: #909090;} -h5 {font-size: 1.3em; color: #989898;} -h6 {font-size: 1.2em; color: #9c9c9c;} -p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;} -ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;} -li {margin: 0.3em auto;} -ul {margin-left: 2em; padding-left: 0.5em;} -dt {font-weight: bold;} -img {border: none;} -pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;} -blockquote {padding: 0.4em; background-color: #f6f5eb;} -th, td {border: 1px solid #ccc; padding: 0.3em;} -th {background-color: #f0f0f0;} -hr {border: none; border-top: 1px solid #ccc; width: 100%;} -del {text-decoration: line-through; color: #777777;} -.toc li {list-style-type: none;} -.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;} -.justleft {text-align: left;} -.justright {text-align: right;} -.justcenter {text-align: center;} -.center {margin-left: auto; margin-right: auto;} -div.center > table {margin-left: auto; margin-right: auto;} -.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;} - -/* classes for items of todo lists */ -.done0 { - /* list-style: none; */ - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==); - background-repeat: no-repeat; - background-position: 0 .2em; - padding-left: 1.5em; -} -.done1 { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC); - background-repeat: no-repeat; - background-position: 0 .15em; - padding-left: 1.5em; -} -.done2 { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=); - background-repeat: no-repeat; - background-position: 0 .15em; - padding-left: 1.5em; -} -.done3 { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==); - background-repeat: no-repeat; - background-position: 0 .15em; - padding-left: 1.5em; -} -.done4 { - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC); - background-repeat: no-repeat; - background-position: 0 .15em; - padding-left: 1.5em; -} - -*:not(pre) > code { - font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace; - -webkit-border-radius: 1px; - -moz-border-radius: 1px; - border-radius: 1px; - -moz-background-clip: padding; - -webkit-background-clip: padding-box; - background-clip: padding-box; - padding: 0px 3px; - display: inline-block; - color: #52595d; - border: 1px solid #ccc; - background-color: #f9f9f9; -} -- cgit v1.2.3 From 906251e6237ccff60b4b4787cb40a7f8c7960cf7 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 18 Dec 2020 12:16:52 -0800 Subject: Remove data/make-reference-files.hs. I don't think this has been used for a long time. --- data/make-reference-files.hs | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 data/make-reference-files.hs (limited to 'data') diff --git a/data/make-reference-files.hs b/data/make-reference-files.hs deleted file mode 100644 index 77e518496..000000000 --- a/data/make-reference-files.hs +++ /dev/null @@ -1,27 +0,0 @@ -import System.Environment -import System.Directory -import Codec.Archive.Zip -import qualified Data.ByteString.Lazy as BS -import qualified Control.Exception as E -import System.IO.Error (isDoesNotExistError) -import System.FilePath - -mkzip :: String -> IO () -mkzip fmt = do - let dir = "data" fmt - output = "data" "reference" <.> fmt - cd <- getCurrentDirectory - setCurrentDirectory dir - archive <- addFilesToArchive [OptRecursive] emptyArchive ["."] - setCurrentDirectory cd - removeIfExists output - BS.writeFile output $ fromArchive archive - -removeIfExists :: FilePath -> IO () -removeIfExists fileName = removeFile fileName `E.catch` handleExists - where handleExists e - | isDoesNotExistError e = return () - | otherwise = E.throwIO e - -main :: IO () -main = getArgs >>= mkzip . (!!0) -- cgit v1.2.3 From 29c6089681a726af6ec0bc86fcfb6bf1dba1018e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 18 Dec 2020 12:19:44 -0800 Subject: Remove data/templates/README.markdown. --- data/templates/README.markdown | 49 ------------------------------------------ 1 file changed, 49 deletions(-) delete mode 100644 data/templates/README.markdown (limited to 'data') diff --git a/data/templates/README.markdown b/data/templates/README.markdown deleted file mode 100644 index 4fca1cba1..000000000 --- a/data/templates/README.markdown +++ /dev/null @@ -1,49 +0,0 @@ -The [pandoc-templates] repository contains default templates for [pandoc]. - -If you use custom templates, we recommend forking this -repository, so that you can integrate changes to the default -templates in future pandoc releases. - -This repository is a subtree of [pandoc]; it will be updated -each time there is a new pandoc release. However, changes to -templates are made first in [pandoc]; thus, issues and pull -requests should be made [pandoc]'s issue tracker rather than -here. - -[pandoc]: https://github.com/jgm/pandoc -[pandoc-templates]: https://github.com/jgm/pandoc-templates - -All of the templates in this repository are dual licensed, under both -the GPL (v2 or higher, same as pandoc) and the BSD 3-clause license -(included below). - -Copyright (c) 2014--2019, John MacFarlane - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - -* Neither the name of John MacFarlane nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- cgit v1.2.3 From 8f402beab922646d4c428b40a75fe4d140ab5e9e Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 21 Dec 2020 03:04:54 +0100 Subject: LaTeX writer: support colspans and rowspans in tables. (#6950) Note that the multirow package is needed for rowspans. It is included in the latex template under a variable, so that it won't be used unless needed for a table. --- data/templates/default.latex | 3 + pandoc.cabal | 1 + src/Text/Pandoc/Writers/AnnotatedTable.hs | 23 +++ src/Text/Pandoc/Writers/LaTeX.hs | 6 +- src/Text/Pandoc/Writers/LaTeX/Table.hs | 301 ++++++++++++++++++++---------- src/Text/Pandoc/Writers/LaTeX/Types.hs | 2 + test/Tests/Old.hs | 2 +- test/tables/nordics.latex | 26 +++ test/tables/planets.latex | 36 ++++ test/tables/students.latex | 23 +++ 10 files changed, 326 insertions(+), 97 deletions(-) create mode 100644 test/tables/nordics.latex create mode 100644 test/tables/planets.latex create mode 100644 test/tables/students.latex (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 169661582..c567278e3 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -255,6 +255,9 @@ $highlighting-macros$ $endif$ $if(tables)$ \usepackage{longtable,booktabs,array} +$if(multirow)$ +\usepackage{multirow} +$endif$ \usepackage{calc} % for calculating minipage widths $if(beamer)$ \usepackage{caption} diff --git a/pandoc.cabal b/pandoc.cabal index 8a4faa3e1..4a893d672 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -299,6 +299,7 @@ extra-source-files: test/tables.xwiki test/tables/*.html4 test/tables/*.html5 + test/tables/*.latex test/tables/*.native test/tables/*.jats_archiving test/testsuite.txt diff --git a/src/Text/Pandoc/Writers/AnnotatedTable.hs b/src/Text/Pandoc/Writers/AnnotatedTable.hs index 48c9d61f2..3f69496a9 100644 --- a/src/Text/Pandoc/Writers/AnnotatedTable.hs +++ b/src/Text/Pandoc/Writers/AnnotatedTable.hs @@ -1,8 +1,12 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE UndecidableInstances #-} {- | Module : Text.Pandoc.Writers.AnnotatedTable @@ -45,6 +49,7 @@ import Data.Generics ( Data import Data.List.NonEmpty ( NonEmpty(..) ) import GHC.Generics ( Generic ) import qualified Text.Pandoc.Builder as B +import Text.Pandoc.Walk ( Walkable (..) ) -- | An annotated table type, corresponding to the Pandoc 'B.Table' -- constructor and the HTML @\@ element. It records the data @@ -298,3 +303,21 @@ fromBodyRow (BodyRow attr _ rh rb) = fromCell :: Cell -> B.Cell fromCell (Cell _ _ c) = c + +-- +-- Instances +-- +instance Walkable a B.Cell => Walkable a Cell where + walkM f (Cell colspecs colnum cell) = + Cell colspecs colnum <$> walkM f cell + query f (Cell _colspecs _colnum cell) = query f cell + +instance Walkable a B.Cell => Walkable a HeaderRow where + walkM f (HeaderRow attr rownum cells) = + HeaderRow attr rownum <$> walkM f cells + query f (HeaderRow _attr _rownum cells) = query f cells + +instance Walkable a B.Cell => Walkable a TableHead where + walkM f (TableHead attr rows) = + TableHead attr <$> walkM f rows + query f (TableHead _attr rows) = query f rows diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 6a4e3ba69..2281290c0 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -48,6 +48,7 @@ import Text.Pandoc.Writers.LaTeX.Types (LW, WriterState (..), startingState) import Text.Pandoc.Writers.Shared import Text.Printf (printf) import qualified Data.Text.Normalize as Normalize +import qualified Text.Pandoc.Writers.AnnotatedTable as Ann -- | Convert Pandoc to LaTeX. writeLaTeX :: PandocMonad m => WriterOptions -> Pandoc -> m Text @@ -154,6 +155,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do defField "documentclass" documentClass $ defField "verbatim-in-note" (stVerbInNote st) $ defField "tables" (stTable st) $ + defField "multirow" (stMultiRow st) $ defField "strikeout" (stStrikeout st) $ defField "url" (stUrl st) $ defField "numbersections" (writerNumberSections options) $ @@ -716,9 +718,9 @@ blockToLaTeX (Header level (id',classes,_) lst) = do hdr <- sectionHeader classes id' level lst modify $ \s -> s{stInHeading = False} return hdr -blockToLaTeX (Table _ blkCapt specs thead tbodies tfoot) = +blockToLaTeX (Table attr blkCapt specs thead tbodies tfoot) = tableToLaTeX inlineListToLaTeX blockListToLaTeX - blkCapt specs thead tbodies tfoot + (Ann.toTable attr blkCapt specs thead tbodies tfoot) blockListToLaTeX :: PandocMonad m => [Block] -> LW m (Doc Text) blockListToLaTeX lst = diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs index 5299efa37..9dd66c8a3 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs @@ -16,6 +16,7 @@ module Text.Pandoc.Writers.LaTeX.Table ) where import Control.Monad.State.Strict import Data.List (intersperse) +import Data.List.NonEmpty (NonEmpty ((:|))) import Data.Text (Text) import qualified Data.Text as T import Text.Pandoc.Class.PandocMonad (PandocMonad) @@ -23,102 +24,196 @@ import Text.Pandoc.Definition import Text.DocLayout ( Doc, braces, cr, empty, hcat, hsep, isEmpty, literal, nest , text, vcat, ($$) ) -import Text.Pandoc.Shared (splitBy) +import Text.Pandoc.Shared (blocksToInlines, splitBy, tshow) import Text.Pandoc.Walk (walk) -import Text.Pandoc.Writers.Shared (toLegacyTable) import Text.Pandoc.Writers.LaTeX.Caption (getCaption) import Text.Pandoc.Writers.LaTeX.Notes (notesToLaTeX) import Text.Pandoc.Writers.LaTeX.Types - ( LW, WriterState (stBeamer, stExternalNotes, stInMinipage, stNotes, stTable) ) + ( LW, WriterState (stBeamer, stExternalNotes, stInMinipage, stMultiRow + , stNotes, stTable) ) import Text.Printf (printf) +import qualified Text.Pandoc.Builder as B +import qualified Text.Pandoc.Writers.AnnotatedTable as Ann tableToLaTeX :: PandocMonad m => ([Inline] -> LW m (Doc Text)) -> ([Block] -> LW m (Doc Text)) - -> Caption -> [ColSpec] -> TableHead -> [TableBody] -> TableFoot + -> Ann.Table -> LW m (Doc Text) -tableToLaTeX inlnsToLaTeX blksToLaTeX blkCapt specs thead tbody tfoot = do - let (caption, aligns, widths, heads, rows) = - toLegacyTable blkCapt specs thead tbody tfoot - -- simple tables have to have simple cells: - let isSimple = \case - [Plain _] -> True - [Para _] -> True - [] -> True - _ -> False - let widths' = if all (== 0) widths && not (all (all isSimple) rows) - then replicate (length aligns) - (1 / fromIntegral (length aligns)) - else widths - (captionText, captForLof, captNotes) <- getCaption inlnsToLaTeX False caption - let toHeaders hs = do contents <- tableRowToLaTeX blksToLaTeX True aligns hs - return ("\\toprule" $$ contents $$ "\\midrule") +tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do + let (Ann.Table _attr caption _specs thead tbodies tfoot) = tbl + CaptionDocs capt captNotes <- captionToLaTeX inlnsToLaTeX caption let removeNote (Note _) = Span ("", [], []) [] removeNote x = x - firsthead <- if isEmpty captionText || all null heads - then return empty - else ($$ text "\\endfirsthead") <$> toHeaders heads - head' <- if all null heads - then return "\\toprule" - -- avoid duplicate notes in head and firsthead: - else toHeaders (if isEmpty firsthead - then heads - else walk removeNote heads) - let capt = if isEmpty captionText - then empty - else "\\caption" <> captForLof <> braces captionText - <> "\\tabularnewline" - rows' <- mapM (tableRowToLaTeX blksToLaTeX False aligns) rows - let colDescriptors = - (if all (== 0) widths' - then hcat . map literal - else (\xs -> cr <> nest 2 (vcat $ map literal xs))) $ - zipWith (toColDescriptor (length widths')) aligns widths' + firsthead <- if isEmpty capt || isEmptyHead thead + then return empty + else ($$ text "\\endfirsthead") <$> + headToLaTeX blksToLaTeX thead + head' <- if isEmptyHead thead + then return "\\toprule" + -- avoid duplicate notes in head and firsthead: + else headToLaTeX blksToLaTeX + (if isEmpty firsthead + then thead + else walk removeNote thead) + rows' <- mapM (rowToLaTeX blksToLaTeX BodyCell) $ + mconcat (map bodyRows tbodies) <> footRows tfoot modify $ \s -> s{ stTable = True } notes <- notesToLaTeX <$> gets stNotes - return $ "\\begin{longtable}[]" <> - braces ("@{}" <> colDescriptors <> "@{}") - -- the @{} removes extra space at beginning and end - $$ capt - $$ firsthead - $$ head' - $$ "\\endhead" - $$ vcat rows' - $$ "\\bottomrule" - $$ "\\end{longtable}" - $$ captNotes - $$ notes - -toColDescriptor :: Int -> Alignment -> Double -> Text -toColDescriptor _numcols align 0 = - case align of - AlignLeft -> "l" - AlignRight -> "r" - AlignCenter -> "c" - AlignDefault -> "l" -toColDescriptor numcols align width = - T.pack $ printf - ">{%s\\arraybackslash}p{(\\columnwidth - %d\\tabcolsep) * \\real{%0.2f}}" - align' - ((numcols - 1) * 2) - width - where - align' :: String - align' = case align of - AlignLeft -> "\\raggedright" - AlignRight -> "\\raggedleft" - AlignCenter -> "\\centering" - AlignDefault -> "\\raggedright" - -tableRowToLaTeX :: PandocMonad m - => ([Block] -> LW m (Doc Text)) - -> Bool - -> [Alignment] - -> [[Block]] - -> LW m (Doc Text) -tableRowToLaTeX blockListToLaTeX header aligns cols = do - cells <- mapM (tableCellToLaTeX blockListToLaTeX header) $ zip aligns cols - return $ hsep (intersperse "&" cells) <> " \\\\ \\addlinespace" + return + $ "\\begin{longtable}[]" <> + braces ("@{}" <> colDescriptors tbl <> "@{}") + -- the @{} removes extra space at beginning and end + $$ capt + $$ firsthead + $$ head' + $$ "\\endhead" + $$ vcat rows' + $$ "\\bottomrule" + $$ "\\end{longtable}" + $$ captNotes + $$ notes + +-- | Creates column descriptors for the table. +colDescriptors :: Ann.Table -> Doc Text +colDescriptors (Ann.Table _attr _caption specs thead tbodies tfoot) = + let (aligns, widths) = unzip specs + + defaultWidthsOnly = all (== ColWidthDefault) widths + isSimpleTable = all (all isSimpleCell) $ mconcat + [ headRows thead + , concatMap bodyRows tbodies + , footRows tfoot + ] + + relativeWidths = if defaultWidthsOnly + then replicate (length specs) + (1 / fromIntegral (length specs)) + else map toRelWidth widths + in if defaultWidthsOnly && isSimpleTable + then hcat $ map (literal . colAlign) aligns + else (cr <>) . nest 2 . vcat . map literal $ + zipWith (toColDescriptor (length specs)) + aligns + relativeWidths + where + toColDescriptor :: Int -> Alignment -> Double -> Text + toColDescriptor numcols align width = + T.pack $ printf + ">{%s\\arraybackslash}p{(\\columnwidth - %d\\tabcolsep) * \\real{%0.2f}}" + (T.unpack (alignCommand align)) + ((numcols - 1) * 2) + width + + isSimpleCell (Ann.Cell _ _ (Cell _attr _align _rowspan _colspan blocks)) = + case blocks of + [Para _] -> True + [Plain _] -> True + [] -> True + _ -> False + + toRelWidth ColWidthDefault = 0 + toRelWidth (ColWidth w) = w + +alignCommand :: Alignment -> Text +alignCommand = \case + AlignLeft -> "\\raggedright" + AlignRight -> "\\raggedleft" + AlignCenter -> "\\centering" + AlignDefault -> "\\raggedright" + +colAlign :: Alignment -> Text +colAlign = \case + AlignLeft -> "l" + AlignRight -> "r" + AlignCenter -> "c" + AlignDefault -> "l" + +data CaptionDocs = + CaptionDocs + { captionCommand :: Doc Text + , captionNotes :: Doc Text + } + +captionToLaTeX :: PandocMonad m + => ([Inline] -> LW m (Doc Text)) + -> Caption + -> LW m CaptionDocs +captionToLaTeX inlnsToLaTeX (Caption _maybeShort longCaption) = do + let caption = blocksToInlines longCaption + (captionText, captForLof, captNotes) <- getCaption inlnsToLaTeX False caption + return $ CaptionDocs + { captionNotes = captNotes + , captionCommand = if isEmpty captionText + then empty + else "\\caption" <> captForLof <> + braces captionText <> "\\tabularnewline" + } + +type BlocksWriter m = [Block] -> LW m (Doc Text) + +headToLaTeX :: PandocMonad m + => BlocksWriter m + -> Ann.TableHead + -> LW m (Doc Text) +headToLaTeX blocksWriter (Ann.TableHead _attr headerRows) = do + rowsContents <- mapM (rowToLaTeX blocksWriter HeaderCell . headerRowCells) + headerRows + return ("\\toprule" $$ vcat rowsContents $$ "\\midrule") + +-- | Converts a row of table cells into a LaTeX row. +rowToLaTeX :: PandocMonad m + => BlocksWriter m + -> CellType + -> [Ann.Cell] + -> LW m (Doc Text) +rowToLaTeX blocksWriter celltype row = do + cellsDocs <- mapM (cellToLaTeX blocksWriter celltype) (fillRow row) + return $ hsep (intersperse "&" cellsDocs) <> " \\\\ \\addlinespace" + +-- | Pads row with empty cells to adjust for rowspans above this row. +fillRow :: [Ann.Cell] -> [Ann.Cell] +fillRow = go 0 + where + go _ [] = [] + go n (acell@(Ann.Cell _spec (Ann.ColNumber colnum) cell):cells) = + let (Cell _ _ _ (ColSpan colspan) _) = cell + in map mkEmptyCell [n .. colnum - 1] ++ + acell : go (colnum + colspan) cells + + mkEmptyCell :: Int -> Ann.Cell + mkEmptyCell colnum = + Ann.Cell ((AlignDefault, ColWidthDefault):|[]) + (Ann.ColNumber colnum) + B.emptyCell + +isEmptyHead :: Ann.TableHead -> Bool +isEmptyHead (Ann.TableHead _attr []) = True +isEmptyHead (Ann.TableHead _attr rows) = all (null . headerRowCells) rows + +-- | Gets all cells in a header row. +headerRowCells :: Ann.HeaderRow -> [Ann.Cell] +headerRowCells (Ann.HeaderRow _attr _rownum cells) = cells + +-- | Gets all cells in a body row. +bodyRowCells :: Ann.BodyRow -> [Ann.Cell] +bodyRowCells (Ann.BodyRow _attr _rownum rowhead cells) = rowhead <> cells + +-- | Gets a list of rows of the table body, where a row is a simple +-- list of cells. +bodyRows :: Ann.TableBody -> [[Ann.Cell]] +bodyRows (Ann.TableBody _attr _rowheads headerRows rows) = + map headerRowCells headerRows <> map bodyRowCells rows + +-- | Gets a list of rows of the table head, where a row is a simple +-- list of cells. +headRows :: Ann.TableHead -> [[Ann.Cell]] +headRows (Ann.TableHead _attr rows) = map headerRowCells rows + +-- | Gets a list of rows from the foot, where a row is a simple list +-- of cells. +footRows :: Ann.TableFoot -> [[Ann.Cell]] +footRows (Ann.TableFoot _attr rows) = map headerRowCells rows -- For simple latex tables (without minipages or parboxes), -- we need to go to some lengths to get line breaks working: @@ -144,11 +239,14 @@ displayMathToInline :: Inline -> Inline displayMathToInline (Math DisplayMath x) = Math InlineMath x displayMathToInline x = x -tableCellToLaTeX :: PandocMonad m - => ([Block] -> LW m (Doc Text)) - -> Bool -> (Alignment, [Block]) - -> LW m (Doc Text) -tableCellToLaTeX blockListToLaTeX header (align, blocks) = do +cellToLaTeX :: PandocMonad m + => BlocksWriter m + -> CellType + -> Ann.Cell + -> LW m (Doc Text) +cellToLaTeX blockListToLaTeX celltype annotatedCell = do + let (Ann.Cell _specs _colnum cell) = annotatedCell + let (Cell _attr align rowspan colspan blocks) = cell beamer <- gets stBeamer externalNotes <- gets stExternalNotes inMinipage <- gets stInMinipage @@ -167,15 +265,30 @@ tableCellToLaTeX blockListToLaTeX header (align, blocks) = do modify $ \st -> st{ stInMinipage = True } cellContents <- blockListToLaTeX blocks modify $ \st -> st{ stInMinipage = inMinipage } - let valign = text $ if header then "[b]" else "[t]" - let halign = case align of - AlignLeft -> "\\raggedright" - AlignRight -> "\\raggedleft" - AlignCenter -> "\\centering" - AlignDefault -> "\\raggedright" + let valign = text $ case celltype of + HeaderCell -> "[b]" + BodyCell -> "[t]" + let halign = literal $ alignCommand align return $ "\\begin{minipage}" <> valign <> braces "\\linewidth" <> halign <> cr <> cellContents <> cr <> "\\end{minipage}" modify $ \st -> st{ stExternalNotes = externalNotes } - return result + when (rowspan /= RowSpan 1) $ + modify (\st -> st{ stMultiRow = True }) + let inMultiColumn x = case colspan of + (ColSpan 1) -> x + (ColSpan n) -> "\\multicolumn" + <> braces (literal (tshow n)) + <> braces (literal $ colAlign align) + <> braces x + let inMultiRow x = case rowspan of + (RowSpan 1) -> x + (RowSpan n) -> let nrows = literal (tshow n) + in "\\multirow" <> braces nrows + <> braces "*" <> braces x + return . inMultiColumn . inMultiRow $ result + +data CellType + = HeaderCell + | BodyCell diff --git a/src/Text/Pandoc/Writers/LaTeX/Types.hs b/src/Text/Pandoc/Writers/LaTeX/Types.hs index a76388729..d598794ad 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Types.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Types.hs @@ -31,6 +31,7 @@ data WriterState = -- be parameter , stVerbInNote :: Bool -- ^ true if document has verbatim text in note , stTable :: Bool -- ^ true if document has a table + , stMultiRow :: Bool -- ^ true if document has multirow cells , stStrikeout :: Bool -- ^ true if document has strikeout , stUrl :: Bool -- ^ true if document has visible URL link , stGraphics :: Bool -- ^ true if document contains images @@ -61,6 +62,7 @@ startingState options = , stOptions = options , stVerbInNote = False , stTable = False + , stMultiRow = False , stStrikeout = False , stUrl = False , stGraphics = False diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index aca2d05d0..cf0396d0a 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -58,7 +58,7 @@ tests pandocPath = ] , testGroup "latex" [ testGroup "writer" - (writerTests' "latex" ++ lhsWriterTests' "latex") + (extWriterTests' "latex" ++ lhsWriterTests' "latex") , testGroup "reader" [ test' "basic" ["-r", "latex+raw_tex", "-w", "native", "-s"] "latex-reader.latex" "latex-reader.native" diff --git a/test/tables/nordics.latex b/test/tables/nordics.latex new file mode 100644 index 000000000..d1a0b4aed --- /dev/null +++ b/test/tables/nordics.latex @@ -0,0 +1,26 @@ +\begin{longtable}[]{@{} + >{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.30}} + >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.30}} + >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.20}} + >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.20}}@{}} +\caption{States belonging to the \emph{Nordics.}}\tabularnewline +\toprule +Name & Capital & \vtop{\hbox{\strut Population}\hbox{\strut (in 2018)}} & +\vtop{\hbox{\strut Area}\hbox{\strut (in +km\textsuperscript{2})}} \\ \addlinespace +\midrule +\endfirsthead +\toprule +Name & Capital & \vtop{\hbox{\strut Population}\hbox{\strut (in 2018)}} & +\vtop{\hbox{\strut Area}\hbox{\strut (in +km\textsuperscript{2})}} \\ \addlinespace +\midrule +\endhead +Denmark & Copenhagen & 5,809,502 & 43,094 \\ \addlinespace +Finland & Helsinki & 5,537,364 & 338,145 \\ \addlinespace +Iceland & Reykjavik & 343,518 & 103,000 \\ \addlinespace +Norway & Oslo & 5,372,191 & 323,802 \\ \addlinespace +Sweden & Stockholm & 10,313,447 & 450,295 \\ \addlinespace +Total & & 27,376,022 & 1,258,336 \\ \addlinespace +\bottomrule +\end{longtable} diff --git a/test/tables/planets.latex b/test/tables/planets.latex new file mode 100644 index 000000000..9457b6821 --- /dev/null +++ b/test/tables/planets.latex @@ -0,0 +1,36 @@ +\begin{longtable}[]{@{}cclrrrrrrrrl@{}} +\caption{Data about the planets of our solar system.}\tabularnewline +\toprule +\multicolumn{2}{l}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density +(kg/m\^{}3) & Gravity (m/s\^{}2) & Length of day (hours) & Distance from Sun +(10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \addlinespace +\midrule +\endfirsthead +\toprule +\multicolumn{2}{l}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density +(kg/m\^{}3) & Gravity (m/s\^{}2) & Length of day (hours) & Distance from Sun +(10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \addlinespace +\midrule +\endhead +\multicolumn{2}{l}{\multirow{4}{*}{Terrestrial planets}} & Mercury & 0.330 & +4,879 & 5427 & 3.7 & 4222.6 & 57.9 & 167 & 0 & Closest to the +Sun \\ \addlinespace +& & Venus & 4.87 & 12,104 & 5243 & 8.9 & 2802.0 & 108.2 & 464 & 0 +& \\ \addlinespace +& & Earth & 5.97 & 12,756 & 5514 & 9.8 & 24.0 & 149.6 & 15 & 1 & Our +world \\ \addlinespace +& & Mars & 0.642 & 6,792 & 3933 & 3.7 & 24.7 & 227.9 & -65 & 2 & The red +planet \\ \addlinespace +\multirow{4}{*}{Jovian planets} & \multirow{2}{*}{Gas giants} & Jupiter & 1898 +& 142,984 & 1326 & 23.1 & 9.9 & 778.6 & -110 & 67 & The largest +planet \\ \addlinespace +& & Saturn & 568 & 120,536 & 687 & 9.0 & 10.7 & 1433.5 & -140 & 62 +& \\ \addlinespace +& \multirow{2}{*}{Ice giants} & Uranus & 86.8 & 51,118 & 1271 & 8.7 & 17.2 & +2872.5 & -195 & 27 & \\ \addlinespace +& & Neptune & 102 & 49,528 & 1638 & 11.0 & 16.1 & 4495.1 & -200 & 14 +& \\ \addlinespace +\multicolumn{2}{l}{Dwarf planets} & Pluto & 0.0146 & 2,370 & 2095 & 0.7 & +153.3 & 5906.4 & -225 & 5 & Declassified as a planet in 2006. \\ \addlinespace +\bottomrule +\end{longtable} diff --git a/test/tables/students.latex b/test/tables/students.latex new file mode 100644 index 000000000..680a539d3 --- /dev/null +++ b/test/tables/students.latex @@ -0,0 +1,23 @@ +\begin{longtable}[]{@{} + >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.50}} + >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.50}}@{}} +\caption{List of Students}\tabularnewline +\toprule +Student ID & Name \\ \addlinespace +\midrule +\endfirsthead +\toprule +Student ID & Name \\ \addlinespace +\midrule +\endhead +\multicolumn{2}{l}{Computer Science} \\ \addlinespace +3741255 & Jones, Martha \\ \addlinespace +4077830 & Pierce, Benjamin \\ \addlinespace +5151701 & Kirk, James \\ \addlinespace +\multicolumn{2}{l}{Russian Literature} \\ \addlinespace +3971244 & Nim, Victor \\ \addlinespace +\multicolumn{2}{l}{Astrophysics} \\ \addlinespace +4100332 & Petrov, Alexandra \\ \addlinespace +4100332 & Toyota, Hiroko \\ \addlinespace +\bottomrule +\end{longtable} -- cgit v1.2.3 From 528b67df596feab2f3b80ecce1c9716123a4d8c5 Mon Sep 17 00:00:00 2001 From: Jerry Sky Date: Mon, 28 Dec 2020 08:02:28 +0100 Subject: templates: added the `description` metatag to both html4 and html5 templates (#6982) The `description` meta tag will make the generated HTML documents more complete and SEO-friendly. --- data/templates/default.html4 | 3 +++ data/templates/default.html5 | 3 +++ 2 files changed, 6 insertions(+) (limited to 'data') diff --git a/data/templates/default.html4 b/data/templates/default.html4 index f0dd8880e..deba57a7b 100644 --- a/data/templates/default.html4 +++ b/data/templates/default.html4 @@ -12,6 +12,9 @@ $if(date-meta)$ $endif$ $if(keywords)$ +$endif$ +$if(description)$ + $endif$ $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ diff --git a/pandoc.cabal b/pandoc.cabal index ede9af6f0..db8dab491 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -180,8 +180,6 @@ data-files: data/pandoc.List.lua -- bash completion template data/bash_completion.tpl - -- jats csl - data/jats.csl -- citeproc data/default.csl citeproc/biblatex-localization/*.lbx.strings diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 725c76424..437af3257 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -50,10 +50,9 @@ import Text.Pandoc.App.Opt (Opt (..), LineEnding (..), defaultOpts, import Text.Pandoc.App.CommandLineOptions (parseOptions, options) import Text.Pandoc.App.OutputSettings (OutputSettings (..), optToOutputSettings) import Text.Pandoc.BCP47 (Lang (..), parseBCP47) -import Text.Pandoc.Builder (setMeta) import Text.Pandoc.Filter (Filter (JSONFilter, LuaFilter), applyFilters) import Text.Pandoc.PDF (makePDF) -import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained) +import Text.Pandoc.SelfContained (makeSelfContained) import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs, headerShift, isURI, tabFilter, uriPathToPath, filterIpynbOutput, defaultUserDataDirs, tshow, findM) @@ -190,17 +189,6 @@ convertWithOpts opts = do Nothing -> readDataFile "abbreviations" Just f -> readFileStrict f - metadata <- if format == "jats" && - isNothing (lookupMeta "csl" (optMetadata opts)) && - isNothing (lookupMeta "citation-style" - (optMetadata opts)) - then do - jatsCSL <- readDataFile "jats.csl" - let jatsEncoded = makeDataURI - ("application/xml", jatsCSL) - return $ setMeta "csl" jatsEncoded $ optMetadata opts - else return $ optMetadata opts - case lookupMetaString "lang" (optMetadata opts) of "" -> setTranslations $ Lang "en" "" "US" [] l -> case parseBCP47 l of @@ -286,7 +274,7 @@ convertWithOpts opts = do then fillMediaBag else return) >=> return . adjustMetadata (metadataFromFile <>) - >=> return . adjustMetadata (<> metadata) + >=> return . adjustMetadata (<> optMetadata opts) >=> applyTransforms transforms >=> applyFilters readerOpts filters [T.unpack format] >=> maybe return extractMedia (optExtractMedia opts) diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index e8d93b8d5..b2266d179 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -3,7 +3,7 @@ {-# LANGUAGE ViewPatterns #-} {- | Module : Text.Pandoc.Writers.JATS - Copyright : Copyright (C) 2017-2021 John MacFarlane + Copyright : 2017-2021 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane @@ -168,13 +168,15 @@ plainToPara x = x -- | Convert a list of pairs of terms and definitions into a list of -- JATS varlistentrys. deflistItemsToJATS :: PandocMonad m - => WriterOptions -> [([Inline],[[Block]])] -> JATS m (Doc Text) + => WriterOptions + -> [([Inline],[[Block]])] -> JATS m (Doc Text) deflistItemsToJATS opts items = vcat <$> mapM (uncurry (deflistItemToJATS opts)) items -- | Convert a term and a list of blocks into a JATS varlistentry. deflistItemToJATS :: PandocMonad m - => WriterOptions -> [Inline] -> [[Block]] -> JATS m (Doc Text) + => WriterOptions + -> [Inline] -> [[Block]] -> JATS m (Doc Text) deflistItemToJATS opts term defs = do term' <- inlinesToJATS opts term def' <- wrappedBlocksToJATS (not . isPara) @@ -186,7 +188,8 @@ deflistItemToJATS opts term defs = do -- | Convert a list of lists of blocks to a list of JATS list items. listItemsToJATS :: PandocMonad m - => WriterOptions -> Maybe [Text] -> [[Block]] -> JATS m (Doc Text) + => WriterOptions + -> Maybe [Text] -> [[Block]] -> JATS m (Doc Text) listItemsToJATS opts markers items = case markers of Nothing -> vcat <$> mapM (listItemToJATS opts Nothing) items @@ -194,12 +197,13 @@ listItemsToJATS opts markers items = -- | Convert a list of blocks into a JATS list item. listItemToJATS :: PandocMonad m - => WriterOptions -> Maybe Text -> [Block] -> JATS m (Doc Text) + => WriterOptions + -> Maybe Text -> [Block] -> JATS m (Doc Text) listItemToJATS opts mbmarker item = do contents <- wrappedBlocksToJATS (not . isParaOrList) opts (walk demoteHeaderAndRefs item) return $ inTagsIndented "list-item" $ - maybe empty (\lbl -> inTagsSimple "label" (text $ T.unpack lbl)) mbmarker + maybe empty (inTagsSimple "label" . text . T.unpack) mbmarker $$ contents imageMimeType :: Text -> [(Text, Text)] -> (Text, Text) @@ -247,7 +251,9 @@ blockToJATS opts (Div (id',"section":_,kvs) (Header _lvl _ ils : xs)) = do return $ inTags True "sec" attribs $ inTagsSimple "title" title' $$ contents -- Bibliography reference: -blockToJATS opts (Div (T.stripPrefix "ref-" -> Just _,_,_) [Para lst]) = +blockToJATS opts (Div (ident,_,_) [Para lst]) | "ref-" `T.isPrefixOf` ident = + inTags True "ref" [("id", ident)] . + inTagsSimple "mixed-citation" <$> inlinesToJATS opts lst blockToJATS opts (Div ("refs",_,_) xs) = do contents <- blocksToJATS opts xs @@ -470,10 +476,13 @@ inlineToJATS _ (Link _attr [Str t] (T.stripPrefix "mailto:" -> Just email, _)) | escapeURI t == email = return $ inTagsSimple "email" $ literal (escapeStringForXML email) inlineToJATS opts (Link (ident,_,kvs) txt (T.uncons -> Just ('#', src), _)) = do - let attr = [("id", ident) | not (T.null ident)] ++ - [("alt", stringify txt) | not (null txt)] ++ - [("rid", src)] ++ - [(k,v) | (k,v) <- kvs, k `elem` ["ref-type", "specific-use"]] + let attr = mconcat + [ [("id", ident) | not (T.null ident)] + , [("alt", stringify txt) | not (null txt)] + , [("rid", src)] + , [(k,v) | (k,v) <- kvs, k `elem` ["ref-type", "specific-use"]] + , [("ref-type", "bibr") | "ref-" `T.isPrefixOf` src] + ] if null txt then return $ selfClosingTag "xref" attr else do @@ -529,7 +538,7 @@ demoteHeaderAndRefs (Div ("refs",cls,kvs) bs) = demoteHeaderAndRefs x = x parseDate :: Text -> Maybe Day -parseDate s = msum (map (\fs -> parsetimeWith fs $ T.unpack s) formats) :: Maybe Day +parseDate s = msum (map (`parsetimeWith` T.unpack s) formats) where parsetimeWith = parseTimeM True defaultTimeLocale formats = ["%x","%m/%d/%Y", "%D","%F", "%d %b %Y", "%e %B %Y", "%b. %e, %Y", "%B %e, %Y", diff --git a/test/command/7016.md b/test/command/7016.md new file mode 100644 index 000000000..c2d791ce9 --- /dev/null +++ b/test/command/7016.md @@ -0,0 +1,48 @@ +``` +% pandoc --citeproc --to=jats_archiving --standalone +--- +csl: command/apa.csl +references: +- id: doe + type: article + author: + - family: Doe + given: Jane + container-title: Proceedings of the Academy of Test Inputs + doi: 10.x/nope + issued: 2021 + title: Another article +... +Blah [@doe]. +^D + + +
+ + + + + + + + + + + + + + +

Blah (Doe, 2021).

+ + + + + Doe, J. (2021). Another article. Proceedings + of the Academy of Test Inputs. + doi:10.x/nope + + + +
+``` -- cgit v1.2.3 From c451207b08edc36fa5c2f1af5556a8d211e023ed Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 12 Jan 2021 09:49:10 -0800 Subject: Docx writer: handle table header using styles. Instead of hard-coding the border and header cell vertical alignment, we now let this be determined by the Table style, making use of Word's "conditional formatting" for the table's first row. For headerless tables, we use the tblLook element to tell Word not to apply conditional first-row formatting. Closes #7008. --- data/docx/word/styles.xml | 15 +++++++++ src/Text/Pandoc/Writers/Docx.hs | 37 +++++++++++---------- test/docx/golden/block_quotes.docx | Bin 10001 -> 10092 bytes test/docx/golden/codeblock.docx | Bin 9853 -> 9944 bytes test/docx/golden/comments.docx | Bin 10188 -> 10279 bytes test/docx/golden/custom_style_no_reference.docx | Bin 9952 -> 10042 bytes test/docx/golden/custom_style_preserve.docx | Bin 10578 -> 10666 bytes test/docx/golden/definition_list.docx | Bin 9850 -> 9941 bytes .../golden/document-properties-short-desc.docx | Bin 9856 -> 9947 bytes test/docx/golden/document-properties.docx | Bin 10332 -> 10423 bytes test/docx/golden/headers.docx | Bin 9989 -> 10080 bytes test/docx/golden/image.docx | Bin 26667 -> 26758 bytes test/docx/golden/inline_code.docx | Bin 9789 -> 9880 bytes test/docx/golden/inline_formatting.docx | Bin 9969 -> 10060 bytes test/docx/golden/inline_images.docx | Bin 26725 -> 26816 bytes test/docx/golden/link_in_notes.docx | Bin 10010 -> 10101 bytes test/docx/golden/links.docx | Bin 10185 -> 10276 bytes test/docx/golden/lists.docx | Bin 10261 -> 10352 bytes test/docx/golden/lists_continuing.docx | Bin 10052 -> 10143 bytes test/docx/golden/lists_multiple_initial.docx | Bin 10141 -> 10232 bytes test/docx/golden/lists_restarting.docx | Bin 10053 -> 10144 bytes test/docx/golden/nested_anchors_in_header.docx | Bin 10148 -> 10239 bytes test/docx/golden/notes.docx | Bin 9955 -> 10046 bytes test/docx/golden/raw-blocks.docx | Bin 9888 -> 9980 bytes test/docx/golden/raw-bookmarks.docx | Bin 10023 -> 10115 bytes test/docx/golden/table_one_row.docx | Bin 9834 -> 9932 bytes test/docx/golden/table_with_list_cell.docx | Bin 10199 -> 10249 bytes test/docx/golden/tables.docx | Bin 10225 -> 10266 bytes test/docx/golden/track_changes_deletion.docx | Bin 9833 -> 9924 bytes test/docx/golden/track_changes_insertion.docx | Bin 9816 -> 9907 bytes test/docx/golden/track_changes_move.docx | Bin 9850 -> 9941 bytes .../golden/track_changes_scrubbed_metadata.docx | Bin 9962 -> 10053 bytes test/docx/golden/unicode.docx | Bin 9774 -> 9865 bytes test/docx/golden/verbatim_subsuper.docx | Bin 9822 -> 9913 bytes 34 files changed, 35 insertions(+), 17 deletions(-) (limited to 'data') diff --git a/data/docx/word/styles.xml b/data/docx/word/styles.xml index 6bb5a3f52..832b1b25b 100644 --- a/data/docx/word/styles.xml +++ b/data/docx/word/styles.xml @@ -350,6 +350,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index a99e13a85..8f498775d 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -1023,23 +1023,15 @@ blockToOpenXML' opts (Table _ blkCapt specs thead tbody tfoot) = do _ -> es ++ [Elem $ mknode "w:p" [] ()] headers' <- mapM cellToOpenXML $ zip aligns headers rows' <- mapM (mapM cellToOpenXML . zip aligns) rows - let borderProps = Elem $ mknode "w:tcPr" [] - [ mknode "w:tcBorders" [] - $ mknode "w:bottom" [("w:val","single")] () - , mknode "w:vAlign" [("w:val","bottom")] () ] compactStyle <- pStyleM "Compact" let emptyCell' = [Elem $ mknode "w:p" [] [mknode "w:pPr" [] [compactStyle]]] - let mkcell border contents = mknode "w:tc" [] - $ [ borderProps | border ] ++ - if null contents - then emptyCell' - else contents - let mkrow border cells = + let mkcell contents = mknode "w:tc" [] + $ if null contents + then emptyCell' + else contents + let mkrow cells = mknode "w:tr" [] $ - [ mknode "w:trPr" [] - [ mknode "w:cnfStyle" [("w:firstRow","1")] ()] - | border] - ++ map (mkcell border) cells + map mkcell cells let textwidth = 7920 -- 5.5 in in twips, 1/20 pt let fullrow = 5000 -- 100% specified in pct let rowwidth = fullrow * sum widths @@ -1047,6 +1039,15 @@ blockToOpenXML' opts (Table _ blkCapt specs thead tbody tfoot) = do [("w:w", show (floor (textwidth * w) :: Integer))] () let hasHeader = not $ all null headers modify $ \s -> s { stInTable = False } + -- for compatibility with Word <= 2007, we include a val with a bitmask + -- 0×0020 Apply first row conditional formatting + -- 0×0040 Apply last row conditional formatting + -- 0×0080 Apply first column conditional formatting + -- 0×0100 Apply last column conditional formatting + -- 0×0200 Do not apply row banding conditional formatting + -- 0×0400 Do not apply column banding conditional formattin + let tblLookVal :: Int + tblLookVal = if hasHeader then 0x20 else 0 return $ caption' ++ [Elem $ @@ -1059,15 +1060,17 @@ blockToOpenXML' opts (Table _ blkCapt specs thead tbody tfoot) = do ,("w:firstColumn","0") ,("w:lastColumn","0") ,("w:noHBand","0") - ,("w:noVBand","0")] () : + ,("w:noVBand","0") + ,("w:val", printf "%04x" tblLookVal) + ] () : [ mknode "w:tblCaption" [("w:val", T.unpack captionStr)] () | not (null caption) ] ) : mknode "w:tblGrid" [] (if all (==0) widths then [] else map mkgridcol widths) - : [ mkrow True headers' | hasHeader ] ++ - map (mkrow False) rows' + : [ mkrow headers' | hasHeader ] ++ + map mkrow rows' )] blockToOpenXML' opts el | BulletList lst <- el = addOpenXMLList BulletMarker lst diff --git a/test/docx/golden/block_quotes.docx b/test/docx/golden/block_quotes.docx index bbc8d8de9..3e1bf16e7 100644 Binary files a/test/docx/golden/block_quotes.docx and b/test/docx/golden/block_quotes.docx differ diff --git a/test/docx/golden/codeblock.docx b/test/docx/golden/codeblock.docx index e20efcab4..66f055063 100644 Binary files a/test/docx/golden/codeblock.docx and b/test/docx/golden/codeblock.docx differ diff --git a/test/docx/golden/comments.docx b/test/docx/golden/comments.docx index f1185da98..fb3a02a0a 100644 Binary files a/test/docx/golden/comments.docx and b/test/docx/golden/comments.docx differ diff --git a/test/docx/golden/custom_style_no_reference.docx b/test/docx/golden/custom_style_no_reference.docx index 83243ab8c..bc6c2702a 100644 Binary files a/test/docx/golden/custom_style_no_reference.docx and b/test/docx/golden/custom_style_no_reference.docx differ diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx index 17804bb81..8c555a5bd 100644 Binary files a/test/docx/golden/custom_style_preserve.docx and b/test/docx/golden/custom_style_preserve.docx differ diff --git a/test/docx/golden/definition_list.docx b/test/docx/golden/definition_list.docx index 21629e208..c21b3a5b3 100644 Binary files a/test/docx/golden/definition_list.docx and b/test/docx/golden/definition_list.docx differ diff --git a/test/docx/golden/document-properties-short-desc.docx b/test/docx/golden/document-properties-short-desc.docx index 5cf8db0b0..92ce144e9 100644 Binary files a/test/docx/golden/document-properties-short-desc.docx and b/test/docx/golden/document-properties-short-desc.docx differ diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx index 14bfab6d4..d21b67309 100644 Binary files a/test/docx/golden/document-properties.docx and b/test/docx/golden/document-properties.docx differ diff --git a/test/docx/golden/headers.docx b/test/docx/golden/headers.docx index 416743aa1..3558a47bf 100644 Binary files a/test/docx/golden/headers.docx and b/test/docx/golden/headers.docx differ diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx index ef2940f89..606df92a3 100644 Binary files a/test/docx/golden/image.docx and b/test/docx/golden/image.docx differ diff --git a/test/docx/golden/inline_code.docx b/test/docx/golden/inline_code.docx index 479ea65ec..759269cac 100644 Binary files a/test/docx/golden/inline_code.docx and b/test/docx/golden/inline_code.docx differ diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx index e12e3b38d..c37777080 100644 Binary files a/test/docx/golden/inline_formatting.docx and b/test/docx/golden/inline_formatting.docx differ diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx index 8bd57bb8c..9450b1a73 100644 Binary files a/test/docx/golden/inline_images.docx and b/test/docx/golden/inline_images.docx differ diff --git a/test/docx/golden/link_in_notes.docx b/test/docx/golden/link_in_notes.docx index 2c6a638fc..6f0b830e6 100644 Binary files a/test/docx/golden/link_in_notes.docx and b/test/docx/golden/link_in_notes.docx differ diff --git a/test/docx/golden/links.docx b/test/docx/golden/links.docx index 11e52c4b1..e53889cfb 100644 Binary files a/test/docx/golden/links.docx and b/test/docx/golden/links.docx differ diff --git a/test/docx/golden/lists.docx b/test/docx/golden/lists.docx index 7667990c4..5dbe298b7 100644 Binary files a/test/docx/golden/lists.docx and b/test/docx/golden/lists.docx differ diff --git a/test/docx/golden/lists_continuing.docx b/test/docx/golden/lists_continuing.docx index 3e8c6d2b2..194181288 100644 Binary files a/test/docx/golden/lists_continuing.docx and b/test/docx/golden/lists_continuing.docx differ diff --git a/test/docx/golden/lists_multiple_initial.docx b/test/docx/golden/lists_multiple_initial.docx index 05a7cf060..6e0b634f7 100644 Binary files a/test/docx/golden/lists_multiple_initial.docx and b/test/docx/golden/lists_multiple_initial.docx differ diff --git a/test/docx/golden/lists_restarting.docx b/test/docx/golden/lists_restarting.docx index f5ae4a384..477178e77 100644 Binary files a/test/docx/golden/lists_restarting.docx and b/test/docx/golden/lists_restarting.docx differ diff --git a/test/docx/golden/nested_anchors_in_header.docx b/test/docx/golden/nested_anchors_in_header.docx index d02c77271..51110356e 100644 Binary files a/test/docx/golden/nested_anchors_in_header.docx and b/test/docx/golden/nested_anchors_in_header.docx differ diff --git a/test/docx/golden/notes.docx b/test/docx/golden/notes.docx index f7fdcbe11..b6206cdf5 100644 Binary files a/test/docx/golden/notes.docx and b/test/docx/golden/notes.docx differ diff --git a/test/docx/golden/raw-blocks.docx b/test/docx/golden/raw-blocks.docx index ae7f8f1f0..07b576080 100644 Binary files a/test/docx/golden/raw-blocks.docx and b/test/docx/golden/raw-blocks.docx differ diff --git a/test/docx/golden/raw-bookmarks.docx b/test/docx/golden/raw-bookmarks.docx index 5e433b736..d46095eb7 100644 Binary files a/test/docx/golden/raw-bookmarks.docx and b/test/docx/golden/raw-bookmarks.docx differ diff --git a/test/docx/golden/table_one_row.docx b/test/docx/golden/table_one_row.docx index d404878c6..7caba4e93 100644 Binary files a/test/docx/golden/table_one_row.docx and b/test/docx/golden/table_one_row.docx differ diff --git a/test/docx/golden/table_with_list_cell.docx b/test/docx/golden/table_with_list_cell.docx index 79c395262..6aaa6da61 100644 Binary files a/test/docx/golden/table_with_list_cell.docx and b/test/docx/golden/table_with_list_cell.docx differ diff --git a/test/docx/golden/tables.docx b/test/docx/golden/tables.docx index df9680773..5746c5ad0 100644 Binary files a/test/docx/golden/tables.docx and b/test/docx/golden/tables.docx differ diff --git a/test/docx/golden/track_changes_deletion.docx b/test/docx/golden/track_changes_deletion.docx index bb73b82f6..5f22dccc6 100644 Binary files a/test/docx/golden/track_changes_deletion.docx and b/test/docx/golden/track_changes_deletion.docx differ diff --git a/test/docx/golden/track_changes_insertion.docx b/test/docx/golden/track_changes_insertion.docx index 7df484aaa..ab5c4f56d 100644 Binary files a/test/docx/golden/track_changes_insertion.docx and b/test/docx/golden/track_changes_insertion.docx differ diff --git a/test/docx/golden/track_changes_move.docx b/test/docx/golden/track_changes_move.docx index d717b93ab..085f33162 100644 Binary files a/test/docx/golden/track_changes_move.docx and b/test/docx/golden/track_changes_move.docx differ diff --git a/test/docx/golden/track_changes_scrubbed_metadata.docx b/test/docx/golden/track_changes_scrubbed_metadata.docx index 791182db2..1ac86d5c8 100644 Binary files a/test/docx/golden/track_changes_scrubbed_metadata.docx and b/test/docx/golden/track_changes_scrubbed_metadata.docx differ diff --git a/test/docx/golden/unicode.docx b/test/docx/golden/unicode.docx index b64a7b58e..c2c443b19 100644 Binary files a/test/docx/golden/unicode.docx and b/test/docx/golden/unicode.docx differ diff --git a/test/docx/golden/verbatim_subsuper.docx b/test/docx/golden/verbatim_subsuper.docx index b5116d1a8..5ea18d32e 100644 Binary files a/test/docx/golden/verbatim_subsuper.docx and b/test/docx/golden/verbatim_subsuper.docx differ -- cgit v1.2.3 From d82fe52a02e43d905f34830162def346d851fc5a Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 29 Jan 2021 09:42:25 +0100 Subject: JATS templates: tag author.name as string-name The partitioning the components of a name into surname, given names, etc. is not always possible or not available. Using `author.name` allows to give the full name as a fallback to be used when `author.surname` is not available. --- data/templates/article.jats_publishing | 2 ++ data/templates/default.jats_articleauthoring | 2 ++ doc/jats.md | 5 +++++ 3 files changed, 9 insertions(+) (limited to 'data') diff --git a/data/templates/article.jats_publishing b/data/templates/article.jats_publishing index 4bdb3f278..15d2e3b08 100644 --- a/data/templates/article.jats_publishing +++ b/data/templates/article.jats_publishing @@ -95,6 +95,8 @@ $if(author.surname)$ $author.surname$ $author.given-names$ +$elseif(author.name)$ +$author.name$ $else$ $author$ $endif$ diff --git a/data/templates/default.jats_articleauthoring b/data/templates/default.jats_articleauthoring index 94c929548..ef2aed769 100644 --- a/data/templates/default.jats_articleauthoring +++ b/data/templates/default.jats_articleauthoring @@ -28,6 +28,8 @@ $if(author.surname)$ $author.surname$ $author.given-names$ +$elseif(author.name)$ +$author.name$ $else$ $author$ $endif$ diff --git a/doc/jats.md b/doc/jats.md index 362ae3bef..0faea8b06 100644 --- a/doc/jats.md +++ b/doc/jats.md @@ -33,6 +33,11 @@ Metadata Values See [``][elem:given-names]. + `name` + : full name of the author; included only as a fallback if + `author.surname` is not available. Tagged with + [``][elem:string-name]. + `email` : the contributor's email address. -- cgit v1.2.3 From 02d3c71e7224853ecabaa9ac4cd947ec2ac1e579 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 1 Feb 2021 18:02:17 -0800 Subject: BibTeX writer: use doclayout and doctemplate. This change allows bibtex/biblatex output to wrap as other formats do, depending on the settings of `--wrap` and `--columns`. It also introduces default templates for bibtex and biblatex, which allow for using the variables `header-include`, `include-before` or `include-after` (or alternatively the command line options `--include-in-header`, `--include-before-body`, `--include-after-body`) to insert content into the generated bibtex/biblatex. This change requires a change in the return type of the unexported `T.P.Citeproc.writeBibTeXString` from `Text` to `Doc Text`. Closes #7068. --- data/templates/default.biblatex | 10 ++++++++++ pandoc.cabal | 2 ++ src/Text/Pandoc/Citeproc/BibTeX.hs | 41 +++++++++++++++++++++----------------- src/Text/Pandoc/Templates.hs | 2 -- src/Text/Pandoc/Writers/BibTeX.hs | 19 +++++++++++++++--- test/command/7067.md | 6 +++--- 6 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 data/templates/default.biblatex (limited to 'data') diff --git a/data/templates/default.biblatex b/data/templates/default.biblatex new file mode 100644 index 000000000..6bf2632d8 --- /dev/null +++ b/data/templates/default.biblatex @@ -0,0 +1,10 @@ +$for(header-includes)$ +$header-includes$ +$endfor$ +$for(include-before)$ +$include-before$ +$endfor$ +$body$ +$for(include-after)$ +$include-after$ +$endfor$ diff --git a/pandoc.cabal b/pandoc.cabal index 1bdd2a6b3..2f8c255a8 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -56,6 +56,8 @@ data-files: data/templates/default.icml data/templates/default.opml data/templates/default.latex + data/templates/default.bibtex + data/templates/default.biblatex data/templates/default.context data/templates/default.texinfo data/templates/default.jira diff --git a/src/Text/Pandoc/Citeproc/BibTeX.hs b/src/Text/Pandoc/Citeproc/BibTeX.hs index 2b43fffb6..416fe439e 100644 --- a/src/Text/Pandoc/Citeproc/BibTeX.hs +++ b/src/Text/Pandoc/Citeproc/BibTeX.hs @@ -52,6 +52,8 @@ import Data.Char (isAlphaNum, isDigit, isLetter, import Data.List (foldl', intercalate, intersperse) import Safe (readMay) import Text.Printf (printf) +import Text.DocLayout (literal, hsep, nest, hang, Doc(..), + braces, ($$), cr) data Variant = Bibtex | Biblatex deriving (Show, Eq, Ord) @@ -77,10 +79,11 @@ writeBibtexString :: WriterOptions -- ^ options (for writing LaTex) -> Variant -- ^ bibtex or biblatex -> Maybe Lang -- ^ Language -> Reference Inlines -- ^ Reference to write - -> Text + -> Doc Text writeBibtexString opts variant mblang ref = - "@" <> bibtexType <> "{" <> unItemId (referenceId ref) <> ",\n " <> - renderFields fs <> "\n}\n" + "@" <> bibtexType <> "{" <> literal (unItemId (referenceId ref)) <> "," + $$ nest 2 (renderFields fs) + $$ "}" <> cr where bibtexType = @@ -231,10 +234,12 @@ writeBibtexString opts variant mblang ref = toLaTeX x = case runPure (writeLaTeX opts $ doc (B.plain x)) of Left _ -> Nothing - Right t -> Just t + Right t -> Just $ hsep . map literal $ T.words t - renderField name = (\contents -> name <> " = {" <> contents <> "}") - <$> getContentsFor name + renderField :: Text -> Maybe (Doc Text) + renderField name = + (((literal name) <>) . hang 2 " = " . braces) + <$> getContentsFor name getVariable v = lookupVariable (toVariable v) ref @@ -248,10 +253,10 @@ writeBibtexString opts variant mblang ref = Nothing -> case dateParts date of [DateParts (y1:_), DateParts (y2:_)] -> - Just (T.pack (printf "%04d" y1) <> "--" <> + Just $ literal (T.pack (printf "%04d" y1) <> "--" <> T.pack (printf "%04d" y2)) [DateParts (y1:_)] -> - Just (T.pack (printf "%04d" y1)) + Just $ literal (T.pack (printf "%04d" y1)) _ -> Nothing _ -> Nothing @@ -274,19 +279,19 @@ writeBibtexString opts variant mblang ref = DateVal date -> case dateParts date of [DateParts (_:m1:_), DateParts (_:m2:_)] -> - Just (toMonth m1 <> "--" <> toMonth m2) - [DateParts (_:m1:_)] -> Just (toMonth m1) + Just $ literal (toMonth m1 <> "--" <> toMonth m2) + [DateParts (_:m1:_)] -> Just $ literal (toMonth m1) _ -> Nothing _ -> Nothing - getContentsFor :: Text -> Maybe Text + getContentsFor :: Text -> Maybe (Doc Text) getContentsFor "type" = getVariableAsText "genre" >>= \case "mathesis" -> Just "mastersthesis" "phdthesis" -> Just "phdthesis" _ -> Nothing - getContentsFor "entrysubtype" = mbSubtype + getContentsFor "entrysubtype" = literal <$> mbSubtype getContentsFor "journal" | bibtexType `elem` ["article", "periodical", "suppperiodical", "review"] = getVariable "container-title" >>= toLaTeX . valToInlines @@ -314,7 +319,7 @@ writeBibtexString opts variant mblang ref = getContentsFor x = getVariable x >>= if isURL x - then Just . stringify . valToInlines + then Just . literal . stringify . valToInlines else toLaTeX . (if x == "title" then titlecase @@ -323,7 +328,7 @@ writeBibtexString opts variant mblang ref = isURL x = x `elem` ["url","doi","issn","isbn"] - renderFields = T.intercalate ",\n " . mapMaybe renderField + renderFields = mconcat . intersperse ("," <> cr) . mapMaybe renderField defaultLang :: Lang defaultLang = Lang "en" (Just "US") @@ -1038,14 +1043,14 @@ getOldDate prefix = do let dateparts = filter (\x -> x /= DateParts []) $ map toDateParts [(year',month',day'), (endyear',endmonth',endday')] - literal <- if null dateparts - then Just <$> getRawField (prefix <> "year") - else return Nothing + literal' <- if null dateparts + then Just <$> getRawField (prefix <> "year") + else return Nothing return $ Date { dateParts = dateparts , dateCirca = False , dateSeason = Nothing - , dateLiteral = literal } + , dateLiteral = literal' } getRawField :: Text -> Bib Text getRawField f = do diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs index 3e539bff7..e83f26329 100644 --- a/src/Text/Pandoc/Templates.hs +++ b/src/Text/Pandoc/Templates.hs @@ -81,8 +81,6 @@ getDefaultTemplate writer = do case format of "native" -> return "" "csljson" -> return "" - "bibtex" -> return "" - "biblatex" -> return "" "json" -> return "" "docx" -> return "" "fb2" -> return "" diff --git a/src/Text/Pandoc/Writers/BibTeX.hs b/src/Text/Pandoc/Writers/BibTeX.hs index e1cb47ca1..b9ae0c13a 100644 --- a/src/Text/Pandoc/Writers/BibTeX.hs +++ b/src/Text/Pandoc/Writers/BibTeX.hs @@ -25,7 +25,11 @@ import Citeproc (parseLang) import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Citeproc.BibTeX as BibTeX import Text.Pandoc.Citeproc.MetaValue (metaValueToReference) -import Text.Pandoc.Writers.Shared (lookupMetaString) +import Text.Pandoc.Writers.Shared (lookupMetaString, defField, + addVariablesToContext) +import Text.DocLayout (render, vcat) +import Text.DocTemplates (Context(..)) +import Text.Pandoc.Templates (renderTemplate) -- | Write BibTeX based on the references metadata from a Pandoc document. writeBibTeX :: PandocMonad m => WriterOptions -> Pandoc -> m Text @@ -43,6 +47,15 @@ writeBibTeX' variant opts (Pandoc meta _) = do let refs = case lookupMeta "references" meta of Just (MetaList xs) -> mapMaybe metaValueToReference xs _ -> [] - return $ mconcat $ - map (BibTeX.writeBibtexString opts variant mblang) refs + let main = vcat $ map (BibTeX.writeBibtexString opts variant mblang) refs + let context = defField "body" main + $ addVariablesToContext opts (mempty :: Context Text) + let colwidth = if writerWrapText opts == WrapAuto + then Just $ writerColumns opts + else Nothing + return $ render colwidth $ + case writerTemplate opts of + Nothing -> main + Just tpl -> renderTemplate tpl context + diff --git a/test/command/7067.md b/test/command/7067.md index a66e3aa1f..34b3bb8ea 100644 --- a/test/command/7067.md +++ b/test/command/7067.md @@ -20,7 +20,7 @@ references: @article{garaud, author = {Garaud, Marcel}, title = {Recherches sur les défrichements dans la Gâtine poitevine aux -XI\textsuperscript{e} et XII\textsuperscript{e} siècles}, + XI\textsuperscript{e} et XII\textsuperscript{e} siècles}, journal = {Bulletin de la Societé des antiquaires de l’Ouest}, series = {4}, volume = {9}, @@ -51,8 +51,8 @@ references: ^D @article{garaud, author = {Garaud, Marcel}, - title = {{Recherches sur les défrichements dans la Gâtine poitevine aux -XI\textsuperscript{e} et XII\textsuperscript{e} siècles}}, + title = {{Recherches sur les défrichements dans la Gâtine poitevine + aux XI\textsuperscript{e} et XII\textsuperscript{e} siècles}}, journal = {Bulletin de la Société des antiquaires de l’Ouest}, series = {4}, volume = {9}, -- cgit v1.2.3 From 84d46e352316b75415f0e9899615f931b6205324 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 1 Feb 2021 18:53:59 -0800 Subject: Add default.bibtex to repository. --- data/templates/default.bibtex | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 data/templates/default.bibtex (limited to 'data') diff --git a/data/templates/default.bibtex b/data/templates/default.bibtex new file mode 100644 index 000000000..6bf2632d8 --- /dev/null +++ b/data/templates/default.bibtex @@ -0,0 +1,10 @@ +$for(header-includes)$ +$header-includes$ +$endfor$ +$for(include-before)$ +$include-before$ +$endfor$ +$body$ +$for(include-after)$ +$include-after$ +$endfor$ -- cgit v1.2.3 From 4de9edb8e82d14a0bd8f1e8b77e9019944c1440e Mon Sep 17 00:00:00 2001 From: Andrew Dunning Date: Wed, 3 Feb 2021 16:54:11 +0000 Subject: LaTeX template: Update to iftex package (#7073) Load the iftex package directly rather than via the ifxetex and ifluatex compatibility wrappers, which have been merged into a single package that is part of the LaTeX core. The capitalization of the commands has been changed for compatibility with older versions of TeX Live that have the version of iftex by the Persian TeX Group. This had been removed in for compatibility with BasicTeX, but that is no longer an issue. --- MANUAL.txt | 5 ++--- data/templates/default.latex | 22 +++++++++++----------- test/lhs-test.latex | 6 +++--- test/lhs-test.latex+lhs | 6 +++--- test/writer.latex | 6 +++--- test/writers-lang-and-dir.latex | 12 ++++++------ 6 files changed, 28 insertions(+), 29 deletions(-) (limited to 'data') diff --git a/MANUAL.txt b/MANUAL.txt index ebed63d2c..4a82703a3 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -136,7 +136,7 @@ to output the generated LaTeX. You can then test it with `pdflatex test.tex`. When using LaTeX, the following packages need to be available (they are included with all recent versions of [TeX Live]): [`amsfonts`], [`amsmath`], [`lm`], [`unicode-math`], -[`ifxetex`], [`ifluatex`], [`listings`] (if the +[`iftex`], [`listings`] (if the `--listings` option is used), [`fancyvrb`], [`longtable`], [`booktabs`], [`graphicx`] (if the document contains images), [`hyperref`], [`xcolor`], @@ -180,8 +180,7 @@ footnotes in tables). [`graphicx`]: https://ctan.org/pkg/graphicx [`grffile`]: https://ctan.org/pkg/grffile [`hyperref`]: https://ctan.org/pkg/hyperref -[`ifluatex`]: https://ctan.org/pkg/ifluatex -[`ifxetex`]: https://ctan.org/pkg/ifxetex +[`iftex`]: https://ctan.org/pkg/iftex [`listings`]: https://ctan.org/pkg/listings [`lm`]: https://ctan.org/pkg/lm [`longtable`]: https://ctan.org/pkg/longtable diff --git a/data/templates/default.latex b/data/templates/default.latex index c567278e3..c98f53bb6 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -98,14 +98,14 @@ $endif$ $if(linestretch)$ \usepackage{setspace} $endif$ -\usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\usepackage{iftex} +\ifPDFTeX \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols \else % if luatex or xetex $if(mathspec)$ - \ifxetex + \ifXeTeX \usepackage{mathspec} \else \usepackage{unicode-math} @@ -129,7 +129,7 @@ $for(fontfamilies)$ $endfor$ $if(mathfont)$ $if(mathspec)$ - \ifxetex + \ifXeTeX \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} \else \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} @@ -139,18 +139,18 @@ $else$ $endif$ $endif$ $if(CJKmainfont)$ - \ifxetex + \ifXeTeX \usepackage{xeCJK} \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} \fi $endif$ $if(luatexjapresetoptions)$ - \ifluatex + \ifLuaTeX \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} \fi $endif$ $if(CJKmainfont)$ - \ifluatex + \ifLuaTeX \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} \fi @@ -329,7 +329,7 @@ $for(header-includes)$ $header-includes$ $endfor$ $if(lang)$ -\ifxetex +\ifXeTeX % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) \usepackage{polyglossia} \setmainlanguage[$for(polyglossia-lang.options)$$polyglossia-lang.options$$sep$,$endfor$]{$polyglossia-lang.name$} @@ -346,15 +346,15 @@ $if(babel-newcommands)$ $endif$ \fi $endif$ -\ifluatex +\ifLuaTeX \usepackage{selnolig} % disable illegal ligatures \fi $if(dir)$ -\ifxetex +\ifXeTeX % Load bidi as late as possible as it modifies e.g. graphicx \usepackage{bidi} \fi -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\ifPDFTeX \TeXXeTstate=1 \newcommand{\RL}[1]{\beginR #1\endR} \newcommand{\LR}[1]{\beginL #1\endL} diff --git a/test/lhs-test.latex b/test/lhs-test.latex index 32042b103..fdc344335 100644 --- a/test/lhs-test.latex +++ b/test/lhs-test.latex @@ -6,8 +6,8 @@ ]{article} \usepackage{amsmath,amssymb} \usepackage{lmodern} -\usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\usepackage{iftex} +\ifPDFTeX \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols @@ -81,7 +81,7 @@ \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \setcounter{secnumdepth}{-\maxdimen} % remove section numbering -\ifluatex +\ifLuaTeX \usepackage{selnolig} % disable illegal ligatures \fi diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs index 4bc674f4a..f9149ba02 100644 --- a/test/lhs-test.latex+lhs +++ b/test/lhs-test.latex+lhs @@ -6,8 +6,8 @@ ]{article} \usepackage{amsmath,amssymb} \usepackage{lmodern} -\usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\usepackage{iftex} +\ifPDFTeX \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols @@ -48,7 +48,7 @@ \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \setcounter{secnumdepth}{-\maxdimen} % remove section numbering -\ifluatex +\ifLuaTeX \usepackage{selnolig} % disable illegal ligatures \fi diff --git a/test/writer.latex b/test/writer.latex index 7fc707b27..abf772df4 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -6,8 +6,8 @@ ]{article} \usepackage{amsmath,amssymb} \usepackage{lmodern} -\usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\usepackage{iftex} +\ifPDFTeX \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols @@ -63,7 +63,7 @@ \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \setcounter{secnumdepth}{-\maxdimen} % remove section numbering -\ifluatex +\ifLuaTeX \usepackage{selnolig} % disable illegal ligatures \fi diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index 1172d23a2..d91f77325 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -7,8 +7,8 @@ ]{article} \usepackage{amsmath,amssymb} \usepackage{lmodern} -\usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\usepackage{iftex} +\ifPDFTeX \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols @@ -45,7 +45,7 @@ \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \setcounter{secnumdepth}{-\maxdimen} % remove section numbering -\ifxetex +\ifXeTeX % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic) \usepackage{polyglossia} \setmainlanguage[]{english} @@ -69,14 +69,14 @@ \newcommand{\textfrench}[2][]{\foreignlanguage{french}{#2}} \newenvironment{french}[2][]{\begin{otherlanguage}{french}}{\end{otherlanguage}} \fi -\ifluatex +\ifLuaTeX \usepackage{selnolig} % disable illegal ligatures \fi -\ifxetex +\ifXeTeX % Load bidi as late as possible as it modifies e.g. graphicx \usepackage{bidi} \fi -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\ifPDFTeX \TeXXeTstate=1 \newcommand{\RL}[1]{\beginR #1\endR} \newcommand{\LR}[1]{\beginL #1\endL} -- cgit v1.2.3 From 2c99e0e3588d5645e901346572e1b04e8fb4fa3e Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 15 Feb 2021 13:15:14 +0100 Subject: JATS writer: replace attribute "pub-type" with "publication-format". The former attribute is deprecated. --- data/templates/article.jats_publishing | 6 +++--- doc/jats.md | 11 +++++++---- test/writer.jats_archiving | 2 +- test/writer.jats_publishing | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'data') diff --git a/data/templates/article.jats_publishing b/data/templates/article.jats_publishing index 15d2e3b08..3a3a8f8cf 100644 --- a/data/templates/article.jats_publishing +++ b/data/templates/article.jats_publishing @@ -30,10 +30,10 @@ $if(journal.abbrev-title)$ $endif$ $if(journal.pissn)$ -$journal.pissn$ +$journal.pissn$ $endif$ $if(journal.eissn)$ -$journal.eissn$ +$journal.eissn$ $endif$ $-- At least one issn element is required; use empty issn as fallback $if(journal.pissn)$ @@ -130,7 +130,7 @@ $endif$ $endif$ $if(date)$ - + $if(date.day)$ $date.day$ $endif$ diff --git a/doc/jats.md b/doc/jats.md index 0faea8b06..0e717d0d8 100644 --- a/doc/jats.md +++ b/doc/jats.md @@ -173,7 +173,8 @@ Metadata Values The publication date is recorded in the document via the [``][elem:pub-date] element and its sub-elements. The - [`pub-type`][attr:pub-type] attribute is always set to `epub`. + [`publication-format`][attr:publication-format] attribute is + always set to `electronic`. `iso-8601` : ISO-8601 representation of the publication date. Used as the @@ -300,12 +301,14 @@ Metadata Values `pissn` : ISSN identifier of the publication's print version. Used as content of the [``][elem:issn] element with the - [`pub-type`][attr:pub-type] attribute set to `ppub`. + [`publication-format`][attr:publication-format] attribute + set to `print`. `eissn` : ISSN identifier of the publication's electronic version. Used as content of the [``][elem:issn] element with - the [`pub-type`][attr:pub-type] attribute set to `epub`. + the [`publication-format`][attr:publication-format] + attribute set to `electronic`. `publisher-name` : name of the publishing entity (person, company, or other). @@ -352,7 +355,7 @@ Required metadata values: [attr:kwd-group-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/kwd-group-type.html [attr:license-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/license-type.html [attr:pub-id-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/pub-id-type.html -[attr:pub-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/pub-type.html +[attr:publication-format]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/publication-format.html [attr:ref-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/ref-type.html [attr:rid]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/rid.html [attr:subj-group-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/subj-group-type.html diff --git a/test/writer.jats_archiving b/test/writer.jats_archiving index 2d06c5cab..941f5e87d 100644 --- a/test/writer.jats_archiving +++ b/test/writer.jats_archiving @@ -24,7 +24,7 @@ Anonymous - + 17 7 2006 diff --git a/test/writer.jats_publishing b/test/writer.jats_publishing index 915471576..f7d4a4720 100644 --- a/test/writer.jats_publishing +++ b/test/writer.jats_publishing @@ -24,7 +24,7 @@ Anonymous - + 17 7 2006 -- cgit v1.2.3 From b5b576184c3c1668aad0c904e186136b81a0dd54 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 15 Feb 2021 13:15:14 +0100 Subject: JATS writer: add date-type to pub-date elements --- data/templates/article.jats_publishing | 2 +- doc/jats.md | 13 ++++++++++--- test/writer.jats_archiving | 2 +- test/writer.jats_publishing | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'data') diff --git a/data/templates/article.jats_publishing b/data/templates/article.jats_publishing index 3a3a8f8cf..47fa4ac62 100644 --- a/data/templates/article.jats_publishing +++ b/data/templates/article.jats_publishing @@ -130,7 +130,7 @@ $endif$ $endif$ $if(date)$ - + $if(date.day)$ $date.day$ $endif$ diff --git a/doc/jats.md b/doc/jats.md index 0e717d0d8..95151d9f1 100644 --- a/doc/jats.md +++ b/doc/jats.md @@ -172,13 +172,13 @@ Metadata Values pass these components directly. The publication date is recorded in the document via the - [``][elem:pub-date] element and its sub-elements. The + [``] element and its sub-elements. The [`publication-format`][attr:publication-format] attribute is always set to `electronic`. `iso-8601` : ISO-8601 representation of the publication date. Used as the - value of the [`pub-date`][elem:pub-date] element's + value of the [``] element's [`iso-8601-date`][attr:iso-8601-date] attribute. This value is set automatically if pandoc can parse the @@ -192,6 +192,12 @@ Metadata Values The values are set automatically if pandoc can parse the `date` value as a date. + `type` + : The type of event marked by this date. The value is set as + the [`date-type`][attr:date-type] attribute on the + [``] element and defaults to "pub" if not + specified. + `article` : information concerning the article that identifies or describes it. The key-value pairs within this map are typically used @@ -348,6 +354,7 @@ Required metadata values: [Ringgold]: https://ringgold.com/ [attr:content-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/content-type.html +[attr:date-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/date-type.html [attr:fn-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/fn-type.html [attr:institution-id-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/institution-id-type.html [attr:iso-8601-date]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/iso-8601-date.html @@ -380,7 +387,6 @@ Required metadata values: [elem:license]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/license.html [elem:notes]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/notes.html [elem:permissions]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/permissions.html -[elem:pub-date]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/pub-date.html [elem:publisher-loc]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/publisher-loc.html [elem:publisher-name]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/publisher-name.html [elem:string-name]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/string-name.html @@ -396,3 +402,4 @@ Required metadata values: [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/institution-id.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/institution-wrap.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/institution.html +[``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/pub-date.html diff --git a/test/writer.jats_archiving b/test/writer.jats_archiving index 941f5e87d..a6ff94bcd 100644 --- a/test/writer.jats_archiving +++ b/test/writer.jats_archiving @@ -24,7 +24,7 @@ Anonymous - + 17 7 2006 diff --git a/test/writer.jats_publishing b/test/writer.jats_publishing index f7d4a4720..eb3f8faab 100644 --- a/test/writer.jats_publishing +++ b/test/writer.jats_publishing @@ -24,7 +24,7 @@ Anonymous - + 17 7 2006 -- cgit v1.2.3 From 24d7cd539ba70aa94480976a7957420c020cb19a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Feb 2021 15:48:40 -0800 Subject: LaTeX template: disable `` ?` `` and `` !` `` ligatures. These are often triggered by accident in languagegs that use ` `` ` for end quote (e.g. German). See jgm/citeproc#54. --- data/templates/default.latex | 1 + test/lhs-test.latex | 1 + test/lhs-test.latex+lhs | 1 + test/writer.latex | 1 + test/writers-lang-and-dir.latex | 1 + 5 files changed, 5 insertions(+) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index c98f53bb6..efc905741 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -181,6 +181,7 @@ $endif$ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts + \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} $if(indent)$ $else$ diff --git a/test/lhs-test.latex b/test/lhs-test.latex index fdc344335..8c91c88a2 100644 --- a/test/lhs-test.latex +++ b/test/lhs-test.latex @@ -21,6 +21,7 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts + \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs index f9149ba02..0062a8f2d 100644 --- a/test/lhs-test.latex+lhs +++ b/test/lhs-test.latex+lhs @@ -21,6 +21,7 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts + \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class diff --git a/test/writer.latex b/test/writer.latex index abf772df4..a1cefc333 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -21,6 +21,7 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts + \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index d91f77325..2c6bc0001 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -22,6 +22,7 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts + \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class -- cgit v1.2.3 From 005344fb18c9e3bc3c2601ab3b6a7d567c46f398 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 18 Feb 2021 17:03:11 -0800 Subject: Revert "LaTeX template: disable `` ?` `` and `` !` `` ligatures." This reverts commit 24d7cd539ba70aa94480976a7957420c020cb19a. --- data/templates/default.latex | 1 - test/lhs-test.latex | 1 - test/lhs-test.latex+lhs | 1 - test/writer.latex | 1 - test/writers-lang-and-dir.latex | 1 - 5 files changed, 5 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index efc905741..c98f53bb6 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -181,7 +181,6 @@ $endif$ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts - \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} $if(indent)$ $else$ diff --git a/test/lhs-test.latex b/test/lhs-test.latex index 8c91c88a2..fdc344335 100644 --- a/test/lhs-test.latex +++ b/test/lhs-test.latex @@ -21,7 +21,6 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts - \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs index 0062a8f2d..f9149ba02 100644 --- a/test/lhs-test.latex+lhs +++ b/test/lhs-test.latex+lhs @@ -21,7 +21,6 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts - \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class diff --git a/test/writer.latex b/test/writer.latex index a1cefc333..abf772df4 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -21,7 +21,6 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts - \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index 2c6bc0001..d91f77325 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -22,7 +22,6 @@ \IfFileExists{microtype.sty}{% use microtype if available \usepackage[]{microtype} \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts - \DisableLigatures[?,!]{encoding=T1} % disable ?` and !` ligatures }{} \makeatletter \@ifundefined{KOMAClassName}{% if non-KOMA class -- cgit v1.2.3 From d68bbae5520f0ad023b0d83b727e5e248ce26d67 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Fri, 19 Feb 2021 15:41:58 +0100 Subject: Update default ODT style As of now, the default style for ODT documents has a "First paragraph" style that inherits from "Standard" style and has no top or bottom margin. All subsequent paragraphs have "Text_20_body" style that inherits from "Standard" and add "0.0598in" margins on top and bottom. This makes the final document a bit ugly since the first paragraph has a small gap ("0.0598in") towards the second one, and all subsequent have double that. The proposed fix makes "First paragraph" inherit from "Text_20_body" instead so that it also has a consistent margin. Another approach would be to inherit "Text_20_body" and add a 0 margin on top. --- data/odt/styles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data') diff --git a/data/odt/styles.xml b/data/odt/styles.xml index d066b300b..54459de04 100644 --- a/data/odt/styles.xml +++ b/data/odt/styles.xml @@ -350,7 +350,7 @@ xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"> -- cgit v1.2.3 From 6b7d61488820eca1605b2e1ead43644d9be942dc Mon Sep 17 00:00:00 2001 From: maurerle Date: Sat, 20 Feb 2021 19:17:31 +0100 Subject: revealjs writer: add 'center' option for vertical slide centering. Closes #7104. --- data/templates/default.revealjs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'data') diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs index ff88a4482..e611e5b0b 100644 --- a/data/templates/default.revealjs +++ b/data/templates/default.revealjs @@ -82,6 +82,10 @@ $endif$ // Full list of configuration options available at: // https://revealjs.com/config/ Reveal.initialize({ +$if(center)$ + // Determines whether slide content should be vertically centered + center: $center$, +$endif$ $if(controls)$ // Display controls in the bottom right corner controls: $controls$, -- cgit v1.2.3 From 8123571e8efa4fc02004e9c3812b5177f9d0c8c4 Mon Sep 17 00:00:00 2001 From: Loïc Grobol Date: Fri, 26 Feb 2021 18:05:30 +0000 Subject: Wrap url colours in braces in the default LaTeX template (#7121) --- data/templates/default.latex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index c98f53bb6..50fad2a49 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -219,10 +219,10 @@ $if(keywords)$ $endif$ $if(colorlinks)$ colorlinks=true, - linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, - filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, - citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, - urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, + linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$}, + filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$}, + citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$}, + urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$}, $else$ hidelinks, $endif$ -- cgit v1.2.3 From 872b4313a14b8c5164cc85649a8a52cc3fdc41f0 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 11 Mar 2021 08:39:09 +0100 Subject: JATS templates: support 'equal-contrib' attrib for authors Authors who contributed equally to a paper may be marked with `equal-contrib`. --- data/templates/article.jats_publishing | 2 +- data/templates/default.jats_articleauthoring | 2 +- doc/jats.md | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/templates/article.jats_publishing b/data/templates/article.jats_publishing index 47fa4ac62..9bedff6af 100644 --- a/data/templates/article.jats_publishing +++ b/data/templates/article.jats_publishing @@ -86,7 +86,7 @@ $endif$ $if(author)$ $for(author)$ - + $if(author.orcid)$ $author.orcid$ $endif$ diff --git a/data/templates/default.jats_articleauthoring b/data/templates/default.jats_articleauthoring index ef2aed769..60b2ca559 100644 --- a/data/templates/default.jats_articleauthoring +++ b/data/templates/default.jats_articleauthoring @@ -19,7 +19,7 @@ $endif$ $if(author)$ $for(author)$ - + $if(author.orcid)$ $author.orcid$ $endif$ diff --git a/doc/jats.md b/doc/jats.md index 95151d9f1..c099e0a04 100644 --- a/doc/jats.md +++ b/doc/jats.md @@ -50,6 +50,13 @@ Metadata Values list must also occur as the `id` of an affiliation listed in the top-level `affiliation` list. + `equal-contrib` + : boolean attribute used to mark authors who contributed + equally to the work. The + [`equal-contrib`][attr:equal-contrib] attribute is added + to the author's [``] element if this is set to a + truthy value. + `cor-id` : identifier linking to the contributor's correspondence information. The info itself must be stored in as an item in @@ -355,6 +362,7 @@ Required metadata values: [Ringgold]: https://ringgold.com/ [attr:content-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/content-type.html [attr:date-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/date-type.html +[attr:equal-contrib]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/equal-contrib.html [attr:fn-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/fn-type.html [attr:institution-id-type]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/institution-id-type.html [attr:iso-8601-date]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/attribute/iso-8601-date.html @@ -398,6 +406,7 @@ Required metadata values: [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/addr-line.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/aff.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/city.html +[``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/contrib.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/country.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/institution-id.html [``]: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/institution-wrap.html -- cgit v1.2.3 From 3622097da360ab83112eb26b4f6231488d747a95 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 14 Mar 2021 00:09:36 -0800 Subject: Handle 'nocite' better with --biblatex and --natbib. Previously the nocite metadata field was ignored with these formats. Now it populates a `nocite-ids` template variable and causes a `\nocite` command to be issued. Closes #4585. --- data/templates/default.latex | 3 +++ src/Text/Pandoc/Writers/LaTeX.hs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 50fad2a49..830bf8012 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -372,6 +372,9 @@ $for(bibliography)$ \addbibresource{$bibliography$} $endfor$ $endif$ +$if(nocite-ids)$ +\nocite{$for(nocite-ids)$$it$$sep$, $endfor$} +$endif$ $if(csl-refs)$ \newlength{\cslhangindent} \setlength{\cslhangindent}{1.5em} diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 180aaa44d..6a205a798 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -145,6 +146,11 @@ pandocToLaTeX options (Pandoc meta blocks) = do let dirs = query (extract "dir") blocks + let nociteIds = query (\case + Cite cs _ -> map citationId cs + _ -> []) + $ lookupMetaInlines "nocite" meta + let context = defField "toc" (writerTableOfContents options) $ defField "toc-depth" (tshow (writerTOCDepth options - @@ -177,9 +183,11 @@ pandocToLaTeX options (Pandoc meta blocks) = do else id) $ (case writerCiteMethod options of Natbib -> defField "biblio-title" biblioTitle . - defField "natbib" True + defField "natbib" True . + defField "nocite-ids" nociteIds Biblatex -> defField "biblio-title" biblioTitle . - defField "biblatex" True + defField "biblatex" True . + defField "nocite-ids" nociteIds _ -> id) $ defField "colorlinks" (any hasStringValue ["citecolor", "urlcolor", "linkcolor", "toccolor", -- cgit v1.2.3 From afa801ed3fbb37f90365edaa8f4d3a96b1cc362f Mon Sep 17 00:00:00 2001 From: Florian Kohrt Date: Tue, 16 Mar 2021 17:20:54 +0100 Subject: Remove JS comment from HTML (#7154) Illegal, turn into HTML comment --- data/templates/default.revealjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs index e611e5b0b..e6d6939cd 100644 --- a/data/templates/default.revealjs +++ b/data/templates/default.revealjs @@ -69,7 +69,7 @@ $body$ - // reveal.js plugins + -- cgit v1.2.3 From 8fe7e8dd5c2667f0cac5af67ff1a02872eeb9933 Mon Sep 17 00:00:00 2001 From: Julien Dutant <34026710+jdutant@users.noreply.github.com> Date: Thu, 29 Apr 2021 03:06:13 +0100 Subject: list of figures before list of tables in LaTeX and ConTeXt templates (#7235) --- data/templates/default.context | 6 +++--- data/templates/default.latex | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'data') diff --git a/data/templates/default.context b/data/templates/default.context index 1588406fa..64de448ca 100644 --- a/data/templates/default.context +++ b/data/templates/default.context @@ -160,12 +160,12 @@ $endfor$ $if(toc)$ \completecontent $endif$ -$if(lot)$ -\completelistoftables -$endif$ $if(lof)$ \completelistoffigures $endif$ +$if(lot)$ +\completelistoftables +$endif$ $body$ diff --git a/data/templates/default.latex b/data/templates/default.latex index 830bf8012..a7f46b950 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -472,12 +472,12 @@ $endif$ } $endif$ $endif$ -$if(lot)$ -\listoftables -$endif$ $if(lof)$ \listoffigures $endif$ +$if(lot)$ +\listoftables +$endif$ $if(linestretch)$ \setstretch{$linestretch$} $endif$ -- cgit v1.2.3 From b9b22e3ce4282499c2710cb974190d775898405f Mon Sep 17 00:00:00 2001 From: badumont <52835146+badumont@users.noreply.github.com> Date: Fri, 30 Apr 2021 03:47:23 +0200 Subject: Update default.latex (#7234) Fix bad vertical spacing after the bibliography. --- data/templates/default.latex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index a7f46b950..81b2d91fe 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -384,7 +384,10 @@ $if(csl-refs)$ {% don't indent paragraphs \setlength{\parindent}{0pt} % turn on hanging indent if param 1 is 1 - \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi + \ifodd #1 + \let\oldpar\par + \def\par{\hangindent=\cslhangindent\oldpar} + \fi % set entry spacing \ifnum #2 > 0 \setlength{\parskip}{#2\baselineskip} -- cgit v1.2.3 From 96d384ac9e4458d6067a85a9347bf9d79d131f2d Mon Sep 17 00:00:00 2001 From: Florian Kohrt Date: Fri, 30 Apr 2021 03:49:17 +0200 Subject: Support toc-title in revealjs (#7171) * Support toc-title in revealjs * Add semantic HTML "nav" tag Closes #7170. As with default.html5 --- data/templates/default.revealjs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'data') diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs index e6d6939cd..e90b32899 100644 --- a/data/templates/default.revealjs +++ b/data/templates/default.revealjs @@ -59,7 +59,12 @@ $endif$ $endif$ $if(toc)$
+
$endif$ -- cgit v1.2.3 From ba4ec8c5c0d83ee68dd9cb26cdc9553a3374b1ab Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 10 May 2021 09:21:27 -0600 Subject: latex template: use non-starred names for xcolor color names. This should make svgnames and x11names work properly. Closes #6109. --- data/templates/default.latex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 81b2d91fe..f39e56c79 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -2,7 +2,7 @@ \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} \PassOptionsToPackage{hyphens}{url} $if(colorlinks)$ -\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} +\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor} $endif$ $if(dir)$ $if(latex-dir-rtl)$ -- cgit v1.2.3 From 0e5b840c2a340f8b8c2e96148046af2dfd493bcb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 14 May 2021 08:48:59 -0700 Subject: LaTeX template: Move CSL macro defs before header-includes. This allows them to be overriden by header-includes. Closes #7286. --- data/templates/default.latex | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index f39e56c79..142fe3e55 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -325,6 +325,31 @@ $endif$ $if(pagestyle)$ \pagestyle{$pagestyle$} $endif$ +$if(csl-refs)$ +\newlength{\cslhangindent} +\setlength{\cslhangindent}{1.5em} +\newlength{\csllabelwidth} +\setlength{\csllabelwidth}{3em} +\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing + {% don't indent paragraphs + \setlength{\parindent}{0pt} + % turn on hanging indent if param 1 is 1 + \ifodd #1 + \let\oldpar\par + \def\par{\hangindent=\cslhangindent\oldpar} + \fi + % set entry spacing + \ifnum #2 > 0 + \setlength{\parskip}{#2\baselineskip} + \fi + }% + {} +\usepackage{calc} +\newcommand{\CSLBlock}[1]{#1\hfill\break} +\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} +\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} +\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} +$endif$ $for(header-includes)$ $header-includes$ $endfor$ @@ -375,31 +400,6 @@ $endif$ $if(nocite-ids)$ \nocite{$for(nocite-ids)$$it$$sep$, $endfor$} $endif$ -$if(csl-refs)$ -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} -\newlength{\csllabelwidth} -\setlength{\csllabelwidth}{3em} -\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing - {% don't indent paragraphs - \setlength{\parindent}{0pt} - % turn on hanging indent if param 1 is 1 - \ifodd #1 - \let\oldpar\par - \def\par{\hangindent=\cslhangindent\oldpar} - \fi - % set entry spacing - \ifnum #2 > 0 - \setlength{\parskip}{#2\baselineskip} - \fi - }% - {} -\usepackage{calc} -\newcommand{\CSLBlock}[1]{#1\hfill\break} -\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} -\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} -\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} -$endif$ $if(csquotes)$ \usepackage{csquotes} $endif$ -- cgit v1.2.3 From 97a0ee23bc2d7ec90d193f41fb89f91bc66f6528 Mon Sep 17 00:00:00 2001 From: Thomas Hodgson Date: Sat, 15 May 2021 18:56:48 +0200 Subject: HTML-based slide shows: add support for institute (#7289) Add institute variable (string or list) to HTML-based slide formats. --- data/templates/default.dzslides | 2 +- data/templates/default.revealjs | 3 +++ data/templates/default.s5 | 3 +++ data/templates/default.slideous | 7 +++++++ data/templates/default.slidy | 5 +++++ 5 files changed, 19 insertions(+), 1 deletion(-) (limited to 'data') diff --git a/data/templates/default.dzslides b/data/templates/default.dzslides index 11103ab81..5e2749bbf 100644 --- a/data/templates/default.dzslides +++ b/data/templates/default.dzslides @@ -171,7 +171,7 @@ $if(subtitle)$

$subtitle$

$endif$
- $if(author)$$for(author)$$author$$sep$, $endfor$$endif$ · $if(date)$$date$$endif$ + $if(author)$$for(author)$$author$$sep$, $endfor$ · $endif$$if(institute)$$for(institute)$$institute$$sep$, $endfor$ · $endif$$if(date)$$date$$endif$
$endif$ diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs index e90b32899..838d5465f 100644 --- a/data/templates/default.revealjs +++ b/data/templates/default.revealjs @@ -52,6 +52,9 @@ $endif$ $for(author)$

$author$

$endfor$ +$for(institute)$ +

$institute$

+$endfor$ $if(date)$

$date$

$endif$ diff --git a/data/templates/default.s5 b/data/templates/default.s5 index d76111284..27e681fe4 100644 --- a/data/templates/default.s5 +++ b/data/templates/default.s5 @@ -61,6 +61,9 @@ $endif$ $if(author)$

$for(author)$$author$$sep$
$endfor$

$endif$ +$if(institute)$ +

$for(institute)$$institute$$sep$
$endfor$

+$endif$ $if(date)$

$date$

$endif$ diff --git a/data/templates/default.slideous b/data/templates/default.slideous index ebf582dca..70d144bc7 100644 --- a/data/templates/default.slideous +++ b/data/templates/default.slideous @@ -63,9 +63,16 @@ $if(title)$ $if(subtitle)$

$subtitle$

$endif$ +$if(author)$

$for(author)$$author$$sep$
$endfor$

+$endif$ +$if(institute)$ +

+$for(institute)$$institute$$sep$
$endfor$ +

+$endif$ $if(date)$

$date$

$endif$ diff --git a/data/templates/default.slidy b/data/templates/default.slidy index 6b9776858..a4ac97f9d 100644 --- a/data/templates/default.slidy +++ b/data/templates/default.slidy @@ -52,6 +52,11 @@ $if(author)$ $for(author)$$author$$sep$
$endfor$

$endif$ +$if(institute)$ +

+$for(institute)$$institute$$sep$
$endfor$ +

+$endif$ $if(date)$

$date$

$endif$ -- cgit v1.2.3 From 2cf971cf56cbcdfcd6ee245df0d6e9811dc3573b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 15 May 2021 10:54:05 -0700 Subject: docx writer: Remove rsids from settings.docx. Word will add these when revisions are made. But it's pointless to start out with a set of them. --- data/docx/word/settings.xml | 12 +----------- test/docx/golden/block_quotes.docx | Bin 10061 -> 9981 bytes test/docx/golden/codeblock.docx | Bin 9910 -> 9830 bytes test/docx/golden/comments.docx | Bin 10248 -> 10168 bytes test/docx/golden/custom_style_no_reference.docx | Bin 10011 -> 9931 bytes test/docx/golden/custom_style_preserve.docx | Bin 10640 -> 10560 bytes test/docx/golden/custom_style_reference.docx | Bin 12397 -> 12317 bytes test/docx/golden/definition_list.docx | Bin 9910 -> 9830 bytes .../docx/golden/document-properties-short-desc.docx | Bin 9916 -> 9835 bytes test/docx/golden/document-properties.docx | Bin 10393 -> 10314 bytes test/docx/golden/headers.docx | Bin 10049 -> 9969 bytes test/docx/golden/image.docx | Bin 26727 -> 26647 bytes test/docx/golden/inline_code.docx | Bin 9849 -> 9769 bytes test/docx/golden/inline_formatting.docx | Bin 10029 -> 9949 bytes test/docx/golden/inline_images.docx | Bin 26783 -> 26703 bytes test/docx/golden/link_in_notes.docx | Bin 10071 -> 9991 bytes test/docx/golden/links.docx | Bin 10242 -> 10162 bytes test/docx/golden/lists.docx | Bin 10308 -> 10228 bytes test/docx/golden/lists_continuing.docx | Bin 10104 -> 10024 bytes test/docx/golden/lists_multiple_initial.docx | Bin 10186 -> 10106 bytes test/docx/golden/lists_restarting.docx | Bin 10102 -> 10022 bytes test/docx/golden/nested_anchors_in_header.docx | Bin 10206 -> 10126 bytes test/docx/golden/notes.docx | Bin 10018 -> 9938 bytes test/docx/golden/raw-blocks.docx | Bin 9950 -> 9870 bytes test/docx/golden/raw-bookmarks.docx | Bin 10084 -> 10004 bytes test/docx/golden/table_one_row.docx | Bin 9920 -> 9840 bytes test/docx/golden/table_with_list_cell.docx | Bin 10238 -> 10159 bytes test/docx/golden/tables.docx | Bin 10279 -> 10200 bytes test/docx/golden/track_changes_deletion.docx | Bin 9893 -> 9813 bytes test/docx/golden/track_changes_insertion.docx | Bin 9876 -> 9796 bytes test/docx/golden/track_changes_move.docx | Bin 9910 -> 9830 bytes .../golden/track_changes_scrubbed_metadata.docx | Bin 10022 -> 9942 bytes test/docx/golden/unicode.docx | Bin 9835 -> 9755 bytes test/docx/golden/verbatim_subsuper.docx | Bin 9882 -> 9802 bytes 34 files changed, 1 insertion(+), 11 deletions(-) (limited to 'data') diff --git a/data/docx/word/settings.xml b/data/docx/word/settings.xml index afa0199c9..fca255b90 100644 --- a/data/docx/word/settings.xml +++ b/data/docx/word/settings.xml @@ -17,16 +17,6 @@ - - - - - - - - - - @@ -44,4 +34,4 @@ - \ No newline at end of file + diff --git a/test/docx/golden/block_quotes.docx b/test/docx/golden/block_quotes.docx index b6973fcfd..f5e4b6428 100644 Binary files a/test/docx/golden/block_quotes.docx and b/test/docx/golden/block_quotes.docx differ diff --git a/test/docx/golden/codeblock.docx b/test/docx/golden/codeblock.docx index f0d35d3ad..0bbe42bd7 100644 Binary files a/test/docx/golden/codeblock.docx and b/test/docx/golden/codeblock.docx differ diff --git a/test/docx/golden/comments.docx b/test/docx/golden/comments.docx index fb1c15dec..6b759b522 100644 Binary files a/test/docx/golden/comments.docx and b/test/docx/golden/comments.docx differ diff --git a/test/docx/golden/custom_style_no_reference.docx b/test/docx/golden/custom_style_no_reference.docx index 43d536b65..74e30f651 100644 Binary files a/test/docx/golden/custom_style_no_reference.docx and b/test/docx/golden/custom_style_no_reference.docx differ diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx index 8865010d1..7ee99c87b 100644 Binary files a/test/docx/golden/custom_style_preserve.docx and b/test/docx/golden/custom_style_preserve.docx differ diff --git a/test/docx/golden/custom_style_reference.docx b/test/docx/golden/custom_style_reference.docx index 10f7bf661..dfaf16e2b 100644 Binary files a/test/docx/golden/custom_style_reference.docx and b/test/docx/golden/custom_style_reference.docx differ diff --git a/test/docx/golden/definition_list.docx b/test/docx/golden/definition_list.docx index 2a7d81a34..02992c6bd 100644 Binary files a/test/docx/golden/definition_list.docx and b/test/docx/golden/definition_list.docx differ diff --git a/test/docx/golden/document-properties-short-desc.docx b/test/docx/golden/document-properties-short-desc.docx index 2fcd14908..9bfe56dca 100644 Binary files a/test/docx/golden/document-properties-short-desc.docx and b/test/docx/golden/document-properties-short-desc.docx differ diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx index 39533f42d..2a37045f2 100644 Binary files a/test/docx/golden/document-properties.docx and b/test/docx/golden/document-properties.docx differ diff --git a/test/docx/golden/headers.docx b/test/docx/golden/headers.docx index c8d67c45b..ca2c7a261 100644 Binary files a/test/docx/golden/headers.docx and b/test/docx/golden/headers.docx differ diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx index 8a7aeec10..c4447d021 100644 Binary files a/test/docx/golden/image.docx and b/test/docx/golden/image.docx differ diff --git a/test/docx/golden/inline_code.docx b/test/docx/golden/inline_code.docx index 969237cec..1824c0aae 100644 Binary files a/test/docx/golden/inline_code.docx and b/test/docx/golden/inline_code.docx differ diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx index cda936a39..82565a5b1 100644 Binary files a/test/docx/golden/inline_formatting.docx and b/test/docx/golden/inline_formatting.docx differ diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx index 69991e791..0416bcc15 100644 Binary files a/test/docx/golden/inline_images.docx and b/test/docx/golden/inline_images.docx differ diff --git a/test/docx/golden/link_in_notes.docx b/test/docx/golden/link_in_notes.docx index 40e848195..b51ec5220 100644 Binary files a/test/docx/golden/link_in_notes.docx and b/test/docx/golden/link_in_notes.docx differ diff --git a/test/docx/golden/links.docx b/test/docx/golden/links.docx index 28237a30d..ba0d100c8 100644 Binary files a/test/docx/golden/links.docx and b/test/docx/golden/links.docx differ diff --git a/test/docx/golden/lists.docx b/test/docx/golden/lists.docx index bf075805e..9632c598b 100644 Binary files a/test/docx/golden/lists.docx and b/test/docx/golden/lists.docx differ diff --git a/test/docx/golden/lists_continuing.docx b/test/docx/golden/lists_continuing.docx index e7d308e13..3269a0528 100644 Binary files a/test/docx/golden/lists_continuing.docx and b/test/docx/golden/lists_continuing.docx differ diff --git a/test/docx/golden/lists_multiple_initial.docx b/test/docx/golden/lists_multiple_initial.docx index 9763e347e..716129170 100644 Binary files a/test/docx/golden/lists_multiple_initial.docx and b/test/docx/golden/lists_multiple_initial.docx differ diff --git a/test/docx/golden/lists_restarting.docx b/test/docx/golden/lists_restarting.docx index b717ca619..af6edfe86 100644 Binary files a/test/docx/golden/lists_restarting.docx and b/test/docx/golden/lists_restarting.docx differ diff --git a/test/docx/golden/nested_anchors_in_header.docx b/test/docx/golden/nested_anchors_in_header.docx index 873e731d2..f141425f7 100644 Binary files a/test/docx/golden/nested_anchors_in_header.docx and b/test/docx/golden/nested_anchors_in_header.docx differ diff --git a/test/docx/golden/notes.docx b/test/docx/golden/notes.docx index 134cb2eaf..93b4222f6 100644 Binary files a/test/docx/golden/notes.docx and b/test/docx/golden/notes.docx differ diff --git a/test/docx/golden/raw-blocks.docx b/test/docx/golden/raw-blocks.docx index c49ed79c8..9d1aa9853 100644 Binary files a/test/docx/golden/raw-blocks.docx and b/test/docx/golden/raw-blocks.docx differ diff --git a/test/docx/golden/raw-bookmarks.docx b/test/docx/golden/raw-bookmarks.docx index 1f2cbb214..b57289fdd 100644 Binary files a/test/docx/golden/raw-bookmarks.docx and b/test/docx/golden/raw-bookmarks.docx differ diff --git a/test/docx/golden/table_one_row.docx b/test/docx/golden/table_one_row.docx index a0160cdb4..edb23cc72 100644 Binary files a/test/docx/golden/table_one_row.docx and b/test/docx/golden/table_one_row.docx differ diff --git a/test/docx/golden/table_with_list_cell.docx b/test/docx/golden/table_with_list_cell.docx index e51910770..f9cbed156 100644 Binary files a/test/docx/golden/table_with_list_cell.docx and b/test/docx/golden/table_with_list_cell.docx differ diff --git a/test/docx/golden/tables.docx b/test/docx/golden/tables.docx index 8029774a9..b585c803d 100644 Binary files a/test/docx/golden/tables.docx and b/test/docx/golden/tables.docx differ diff --git a/test/docx/golden/track_changes_deletion.docx b/test/docx/golden/track_changes_deletion.docx index 3542b8f9c..313942750 100644 Binary files a/test/docx/golden/track_changes_deletion.docx and b/test/docx/golden/track_changes_deletion.docx differ diff --git a/test/docx/golden/track_changes_insertion.docx b/test/docx/golden/track_changes_insertion.docx index b36b4485e..f18b3f85f 100644 Binary files a/test/docx/golden/track_changes_insertion.docx and b/test/docx/golden/track_changes_insertion.docx differ diff --git a/test/docx/golden/track_changes_move.docx b/test/docx/golden/track_changes_move.docx index e30ab06ae..50bdab767 100644 Binary files a/test/docx/golden/track_changes_move.docx and b/test/docx/golden/track_changes_move.docx differ diff --git a/test/docx/golden/track_changes_scrubbed_metadata.docx b/test/docx/golden/track_changes_scrubbed_metadata.docx index 11597d578..230b27006 100644 Binary files a/test/docx/golden/track_changes_scrubbed_metadata.docx and b/test/docx/golden/track_changes_scrubbed_metadata.docx differ diff --git a/test/docx/golden/unicode.docx b/test/docx/golden/unicode.docx index c7bff82e5..627276e4b 100644 Binary files a/test/docx/golden/unicode.docx and b/test/docx/golden/unicode.docx differ diff --git a/test/docx/golden/verbatim_subsuper.docx b/test/docx/golden/verbatim_subsuper.docx index c70f6946e..790278108 100644 Binary files a/test/docx/golden/verbatim_subsuper.docx and b/test/docx/golden/verbatim_subsuper.docx differ -- cgit v1.2.3 From 31b650b4ecb0901c1f8ae809165dcffa051855b2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 15 May 2021 10:56:16 -0700 Subject: docx writer settings.xml: - Set zoom to 100% by default. - Align math options more with current Word defaults (e.g. Cambria Math font). --- data/docx/word/settings.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'data') diff --git a/data/docx/word/settings.xml b/data/docx/word/settings.xml index fca255b90..5f5ef5bfa 100644 --- a/data/docx/word/settings.xml +++ b/data/docx/word/settings.xml @@ -1,6 +1,6 @@ - + @@ -19,16 +19,16 @@ - + - - + + - + -- cgit v1.2.3 From d92622ba3cae5ced69a256472d367a53fc5878a1 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sun, 16 May 2021 21:33:32 +0200 Subject: LaTeX template: define commands for zero width non-joiner character Closes: #6639 The zero-width non-joiner character is used to avoid ligatures (e.g. in German). --- data/templates/default.latex | 19 +++++++++++++++++++ src/Text/Pandoc/Writers/LaTeX.hs | 3 +-- src/Text/Pandoc/Writers/LaTeX/Types.hs | 3 ++- src/Text/Pandoc/Writers/LaTeX/Util.hs | 7 ++++--- 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 142fe3e55..04784b971 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -156,6 +156,25 @@ $if(CJKmainfont)$ \fi $endif$ \fi +$if(zero-width-non-joiner)$ +%% Support for zero-width non-joiner characters. +\makeatletter +\def\zerowidthnonjoiner{% + % Prevent ligatures and adjust kerning, but still support hyphenating. + \texorpdfstring{% + \textormath{\nobreak\discretionary{-}{}{\kern.03em}% + \ifvmode\else\nobreak\hskip\z@skip\fi}{}% + }{}% +} +\makeatother +\ifPDFTeX + \DeclareUnicodeCharacter{200C}{\zerowidthnonjoiner} +\else + \catcode`^^^^200c=\active + \protected\def ^^^^200c{\zerowidthnonjoiner} +\fi +%% End of ZWNJ support +$endif$ $if(beamer)$ $if(theme)$ \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index d8722876e..bf57937bd 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -173,6 +173,7 @@ pandocToLaTeX options (Pandoc meta blocks) = do defField "has-chapters" (stHasChapters st) $ defField "has-frontmatter" (documentClass `elem` frontmatterClasses) $ defField "listings" (writerListings options || stLHS st) $ + defField "zero-width-non-joiner" (stZwnj st) $ defField "beamer" beamer $ (if stHighlighting st then case writerHighlightStyle options of @@ -1048,5 +1049,3 @@ extractInline _ _ = [] -- Look up a key in an attribute and give a list of its values lookKey :: Text -> Attr -> [Text] lookKey key (_,_,kvs) = maybe [] T.words $ lookup key kvs - - diff --git a/src/Text/Pandoc/Writers/LaTeX/Types.hs b/src/Text/Pandoc/Writers/LaTeX/Types.hs index d598794ad..c06b7e923 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Types.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Types.hs @@ -40,7 +40,7 @@ data WriterState = , stCsquotes :: Bool -- ^ true if document uses csquotes , stHighlighting :: Bool -- ^ true if document has highlighted code , stIncremental :: Bool -- ^ true if beamer lists should be - -- displayed bit by bit + , stZwnj :: Bool -- ^ true if document has a ZWNJ character , stInternalLinks :: [Text] -- ^ list of internal link targets , stBeamer :: Bool -- ^ produce beamer , stEmptyLine :: Bool -- ^ true if no content on line @@ -74,6 +74,7 @@ startingState options = , stCsquotes = False , stHighlighting = False , stIncremental = writerIncremental options + , stZwnj = False , stInternalLinks = [] , stBeamer = False , stEmptyLine = True diff --git a/src/Text/Pandoc/Writers/LaTeX/Util.hs b/src/Text/Pandoc/Writers/LaTeX/Util.hs index 56bb792ae..c34338121 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Util.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Util.hs @@ -22,6 +22,7 @@ module Text.Pandoc.Writers.LaTeX.Util ( where import Control.Applicative ((<|>)) +import Control.Monad (when) import Text.Pandoc.Class (PandocMonad, toLang) import Text.Pandoc.Options (WriterOptions(..), isEnabled) import Text.Pandoc.Writers.LaTeX.Types (LW, WriterState(..)) @@ -30,7 +31,7 @@ import Text.Pandoc.Highlighting (toListingsLanguage) import Text.DocLayout import Text.Pandoc.Definition import Text.Pandoc.ImageSize (showFl) -import Control.Monad.State.Strict (gets) +import Control.Monad.State.Strict (gets, modify) import Data.Text (Text) import qualified Data.Text as T import Text.Pandoc.Extensions (Extension(Ext_smart)) @@ -49,6 +50,8 @@ data StringContext = TextString stringToLaTeX :: PandocMonad m => StringContext -> Text -> LW m Text stringToLaTeX context zs = do opts <- gets stOptions + when ('\x200c' `elemText` zs) $ + modify (\s -> s { stZwnj = True }) return $ T.pack $ foldr (go opts context) mempty $ T.unpack $ if writerPreferAscii opts @@ -270,5 +273,3 @@ mbBraced :: Text -> Text mbBraced x = if not (T.all isAlphaNum x) then "{" <> x <> "}" else x - - -- cgit v1.2.3 From cc088687b4013c2b8b744eb337ed04fc63f315f2 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 16 May 2021 14:35:13 -0700 Subject: LaTeX template: move title, author, date up to top of preamble. This allows header-includes to use them, and puts them in a position where you can see them immediately. Closes #7295. --- data/templates/default.latex | 58 ++++++++++++++++++++--------------------- test/lhs-test.latex | 6 ++--- test/lhs-test.latex+lhs | 6 ++--- test/writer.latex | 8 +++--- test/writers-lang-and-dir.latex | 6 ++--- 5 files changed, 42 insertions(+), 42 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 04784b971..61402c605 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -36,6 +36,35 @@ $for(classoption)$ $classoption$$sep$, $endfor$ ]{$documentclass$} +$if(title)$ +\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} +$endif$ +$if(subtitle)$ +$if(beamer)$ +$else$ +\usepackage{etoolbox} +\makeatletter +\providecommand{\subtitle}[1]{% add subtitle to \maketitle + \apptocmd{\@title}{\par {\large #1 \par}}{}{} +} +\makeatother +$endif$ +\subtitle{$subtitle$} +$endif$ +\author{$for(author)$$author$$sep$ \and $endfor$} +\date{$date$} +$if(beamer)$ +$if(institute)$ +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +$if(titlegraphic)$ +\titlegraphic{\includegraphics{$titlegraphic$}} +$endif$ +$if(logo)$ +\logo{\includegraphics{$logo$}} +$endif$ +$endif$ + $if(beamer)$ $if(background-image)$ \usebackgroundtemplate{% @@ -423,35 +452,6 @@ $if(csquotes)$ \usepackage{csquotes} $endif$ -$if(title)$ -\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} -$endif$ -$if(subtitle)$ -$if(beamer)$ -$else$ -\usepackage{etoolbox} -\makeatletter -\providecommand{\subtitle}[1]{% add subtitle to \maketitle - \apptocmd{\@title}{\par {\large #1 \par}}{}{} -} -\makeatother -$endif$ -\subtitle{$subtitle$} -$endif$ -\author{$for(author)$$author$$sep$ \and $endfor$} -\date{$date$} -$if(beamer)$ -$if(institute)$ -\institute{$for(institute)$$institute$$sep$ \and $endfor$} -$endif$ -$if(titlegraphic)$ -\titlegraphic{\includegraphics{$titlegraphic$}} -$endif$ -$if(logo)$ -\logo{\includegraphics{$logo$}} -$endif$ -$endif$ - \begin{document} $if(has-frontmatter)$ \frontmatter diff --git a/test/lhs-test.latex b/test/lhs-test.latex index fdc344335..20bc6ae19 100644 --- a/test/lhs-test.latex +++ b/test/lhs-test.latex @@ -4,6 +4,9 @@ % \documentclass[ ]{article} +\author{} +\date{} + \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -85,9 +88,6 @@ \usepackage{selnolig} % disable illegal ligatures \fi -\author{} -\date{} - \begin{document} \hypertarget{lhs-test}{% diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs index f9149ba02..327dac4ef 100644 --- a/test/lhs-test.latex+lhs +++ b/test/lhs-test.latex+lhs @@ -4,6 +4,9 @@ % \documentclass[ ]{article} +\author{} +\date{} + \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -52,9 +55,6 @@ \usepackage{selnolig} % disable illegal ligatures \fi -\author{} -\date{} - \begin{document} \hypertarget{lhs-test}{% diff --git a/test/writer.latex b/test/writer.latex index abf772df4..468c271bc 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -4,6 +4,10 @@ % \documentclass[ ]{article} +\title{Pandoc Test Suite} +\author{John MacFarlane \and Anonymous} +\date{July 17, 2006} + \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -67,10 +71,6 @@ \usepackage{selnolig} % disable illegal ligatures \fi -\title{Pandoc Test Suite} -\author{John MacFarlane \and Anonymous} -\date{July 17, 2006} - \begin{document} \maketitle diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index d91f77325..e06fe05ed 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -5,6 +5,9 @@ \documentclass[ english, ]{article} +\author{} +\date{} + \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -84,9 +87,6 @@ \newenvironment{LTR}{\beginL}{\endL} \fi -\author{} -\date{} - \begin{document} \hypertarget{empty-divs-and-spans}{% -- cgit v1.2.3 From fa23effe2567183ec424feda55f507e27f50f7c8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 17 May 2021 20:43:41 -0700 Subject: LaTeX template: improve treatment of CSL entry-spacing. Previously with the default template settings (`indent` variable not set), we would get interparagraph spaces separating bib entries even with `entry-spacing="0"`. On the other hand, setting `entry-spacing="2"` gave ridiculously large spacing. This change makes the spacing caused by `entry-spacing` a multiple of `\parskip` by default, which gives aesthetically reasonable output. Those who want a larger or smaller unit (e.g. because they use `indent` which sets `\parskip` to 0) may `\setlength{\cslentryspacingunit}{10pt}` in header-includes to override the defaults. Closes #7296. --- data/templates/default.latex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 61402c605..60f9972c2 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -378,6 +378,8 @@ $if(csl-refs)$ \setlength{\cslhangindent}{1.5em} \newlength{\csllabelwidth} \setlength{\csllabelwidth}{3em} +\newlength{\cslentryspacingunit} % times entry-spacing +\setlength{\cslentryspacingunit}{\parskip} \newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing {% don't indent paragraphs \setlength{\parindent}{0pt} @@ -387,9 +389,7 @@ $if(csl-refs)$ \def\par{\hangindent=\cslhangindent\oldpar} \fi % set entry spacing - \ifnum #2 > 0 - \setlength{\parskip}{#2\baselineskip} - \fi + \setlength{\parskip}{#2\cslentryspacingunit} }% {} \usepackage{calc} -- cgit v1.2.3 From 183ce584779b344ad6a6a3e085ddfdb00faf62aa Mon Sep 17 00:00:00 2001 From: Denis Maier Date: Thu, 20 May 2021 18:59:53 +0200 Subject: ConTeXt reader: improve ordered lists (#7304) Closes #5016 - change ordered list from itemize to enumerate - adds new itemgroup for ordered lists - add fontfeature for table figures - remove width from itemize in context writer --- data/templates/default.context | 4 ++ src/Text/Pandoc/Writers/ConTeXt.hs | 14 ++----- test/writer.context | 80 ++++++++++++++++++++------------------ test/writers-lang-and-dir.context | 4 ++ 4 files changed, 53 insertions(+), 49 deletions(-) (limited to 'data') diff --git a/data/templates/default.context b/data/templates/default.context index 64de448ca..df39130b2 100644 --- a/data/templates/default.context +++ b/data/templates/default.context @@ -51,6 +51,7 @@ $endif$ % use microtypography \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes] +\definefontfeature[default:tnum][default][tnum=yes, pnum=no] \definefontfeature[smallcaps][script=latn, protrusion=quality, expansion=quality, smcp=yes, onum=yes, pnum=yes] \setupalign[hz,hanging] \setupitaliccorrection[global, always] @@ -97,6 +98,9 @@ $endif$ \setupitemize[autointro] % prevent orphan list intro \setupitemize[indentnext=no] +\defineitemgroup[enumerate] +\setupenumerate[each][fit][itemalign=left,distance=.5em,style={\feature[+][default:tnum]}] + \setupfloat[figure][default={here,nonumber}] \setupfloat[table][default={here,nonumber}] diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 57d752a67..3cafcefba 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -16,7 +16,6 @@ module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where import Control.Monad.State.Strict import Data.Char (ord, isDigit) import Data.List (intersperse) -import Data.List.NonEmpty (nonEmpty) import Data.Maybe (mapMaybe) import Data.Text (Text) import qualified Data.Text as T @@ -233,14 +232,7 @@ blockToConTeXt (OrderedList (start, style', delim) lst) = do Period -> "stopper=." OneParen -> "stopper=)" TwoParens -> "left=(,stopper=)" - let width = maybe 0 maximum $ nonEmpty $ map T.length $ - take (length contents) - (orderedListMarkers (start, style', delim)) - let width' = (toEnum width + 1) / 2 - let width'' = if width' > (1.5 :: Double) - then "width=" <> tshow width' <> "em" - else "" - let specs2Items = filter (not . T.null) [start', delim', width''] + let specs2Items = filter (not . T.null) [start', delim'] let specs2 = if null specs2Items then "" else "[" <> T.intercalate "," specs2Items <> "]" @@ -254,8 +246,8 @@ blockToConTeXt (OrderedList (start, style', delim) lst) = do UpperAlpha -> 'A') : if isTightList lst then ",packed]" else "]" let specs = T.pack style'' <> specs2 - return $ "\\startitemize" <> literal specs $$ vcat contents $$ - "\\stopitemize" <> blankline + return $ "\\startenumerate" <> literal specs $$ vcat contents $$ + "\\stopenumerate" <> blankline blockToConTeXt (DefinitionList lst) = liftM vcat $ mapM defListItemToConTeXt lst blockToConTeXt HorizontalRule = return $ "\\thinrule" <> blankline diff --git a/test/writer.context b/test/writer.context index 77570c249..78667813b 100644 --- a/test/writer.context +++ b/test/writer.context @@ -17,6 +17,7 @@ % use microtypography \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes] +\definefontfeature[default:tnum][default][tnum=yes, pnum=no] \definefontfeature[smallcaps][script=latn, protrusion=quality, expansion=quality, smcp=yes, onum=yes, pnum=yes] \setupalign[hz,hanging] \setupitaliccorrection[global, always] @@ -48,6 +49,9 @@ \setupitemize[autointro] % prevent orphan list intro \setupitemize[indentnext=no] +\defineitemgroup[enumerate] +\setupenumerate[each][fit][itemalign=left,distance=.5em,style={\feature[+][default:tnum]}] + \setupfloat[figure][default={here,nonumber}] \setupfloat[table][default={here,nonumber}] @@ -133,12 +137,12 @@ sub status { A list: -\startitemize[n,packed][stopper=.] +\startenumerate[n,packed][stopper=.] \item item one \item item two -\stopitemize +\stopenumerate Nested block quotes: @@ -255,51 +259,51 @@ Minuses loose: Tight: -\startitemize[n,packed][stopper=.] +\startenumerate[n,packed][stopper=.] \item First \item Second \item Third -\stopitemize +\stopenumerate and: -\startitemize[n,packed][stopper=.] +\startenumerate[n,packed][stopper=.] \item One \item Two \item Three -\stopitemize +\stopenumerate Loose using tabs: -\startitemize[n][stopper=.] +\startenumerate[n][stopper=.] \item First \item Second \item Third -\stopitemize +\stopenumerate and using spaces: -\startitemize[n][stopper=.] +\startenumerate[n][stopper=.] \item One \item Two \item Three -\stopitemize +\stopenumerate Multiple paragraphs: -\startitemize[n][stopper=.] +\startenumerate[n][stopper=.] \item Item 1, graf one. @@ -308,7 +312,7 @@ Multiple paragraphs: Item 2. \item Item 3. -\stopitemize +\stopenumerate \subsection[title={Nested},reference={nested}] @@ -327,7 +331,7 @@ Multiple paragraphs: Here's another: -\startitemize[n,packed][stopper=.] +\startenumerate[n,packed][stopper=.] \item First \item @@ -342,11 +346,11 @@ Here's another: \stopitemize \item Third -\stopitemize +\stopenumerate Same thing but with paragraphs: -\startitemize[n][stopper=.] +\startenumerate[n][stopper=.] \item First \item @@ -362,7 +366,7 @@ Same thing but with paragraphs: \stopitemize \item Third -\stopitemize +\stopenumerate \subsection[title={Tabs and spaces},reference={tabs-and-spaces}] @@ -382,7 +386,7 @@ Same thing but with paragraphs: \subsection[title={Fancy list markers},reference={fancy-list-markers}] -\startitemize[n][start=2,left=(,stopper=),width=2.0em] +\startenumerate[n][start=2,left=(,stopper=)] \item begins with 2 \item @@ -390,51 +394,51 @@ Same thing but with paragraphs: with a continuation - \startitemize[r,packed][start=4,stopper=.,width=2.0em] + \startenumerate[r,packed][start=4,stopper=.] \item sublist with roman numerals, starting with 4 \item more items - \startitemize[A,packed][left=(,stopper=),width=2.0em] + \startenumerate[A,packed][left=(,stopper=)] \item a subsublist \item a subsublist - \stopitemize - \stopitemize -\stopitemize + \stopenumerate + \stopenumerate +\stopenumerate Nesting: -\startitemize[A,packed][stopper=.] +\startenumerate[A,packed][stopper=.] \item Upper Alpha - \startitemize[R,packed][stopper=.] + \startenumerate[R,packed][stopper=.] \item Upper Roman. - \startitemize[n,packed][start=6,left=(,stopper=),width=2.0em] + \startenumerate[n,packed][start=6,left=(,stopper=)] \item Decimal start with 6 - \startitemize[a,packed][start=3,stopper=)] + \startenumerate[a,packed][start=3,stopper=)] \item Lower alpha with paren - \stopitemize - \stopitemize - \stopitemize -\stopitemize + \stopenumerate + \stopenumerate + \stopenumerate +\stopenumerate Autonumbering: -\startitemize[n,packed] +\startenumerate[n,packed] \item Autonumber. \item More. - \startitemize[a,packed] + \startenumerate[a,packed] \item Nested. - \stopitemize -\stopitemize + \stopenumerate +\stopenumerate Should not be a list item: @@ -547,12 +551,12 @@ Blank line after term, indented marker, alternate markers: \startdescription{orange} orange fruit - \startitemize[n,packed][stopper=.] + \startenumerate[n,packed][stopper=.] \item sublist \item sublist - \stopitemize + \stopenumerate \stopdescription \section[title={HTML Blocks},reference={html-blocks}] @@ -897,10 +901,10 @@ note{]} Here is an inline note.\footnote{This is {\em easier} to type. Inline Notes can go in quotes.\footnote{In quote.} \stopblockquote -\startitemize[n,packed][stopper=.] +\startenumerate[n,packed][stopper=.] \item And in list items.\footnote{In list.} -\stopitemize +\stopenumerate This paragraph should not be part of the note, as it is not indented. diff --git a/test/writers-lang-and-dir.context b/test/writers-lang-and-dir.context index c4bff1a01..c01ecab58 100644 --- a/test/writers-lang-and-dir.context +++ b/test/writers-lang-and-dir.context @@ -15,6 +15,7 @@ % use microtypography \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes] +\definefontfeature[default:tnum][default][tnum=yes, pnum=no] \definefontfeature[smallcaps][script=latn, protrusion=quality, expansion=quality, smcp=yes, onum=yes, pnum=yes] \setupalign[hz,hanging] \setupitaliccorrection[global, always] @@ -46,6 +47,9 @@ \setupitemize[autointro] % prevent orphan list intro \setupitemize[indentnext=no] +\defineitemgroup[enumerate] +\setupenumerate[each][fit][itemalign=left,distance=.5em,style={\feature[+][default:tnum]}] + \setupfloat[figure][default={here,nonumber}] \setupfloat[table][default={here,nonumber}] -- cgit v1.2.3 From 3a1988b6b2c08fa8a23ae5b6ce355b9b4e0f3dbe Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 20 May 2021 17:17:15 -0700 Subject: reveal.js template: use `hash: true` by default rather than... `history: true`. Closes #6968. Setting `hash: true` is enough to get linkability to a particular page of the slide show. --- data/templates/default.revealjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs index 838d5465f..8a77674dd 100644 --- a/data/templates/default.revealjs +++ b/data/templates/default.revealjs @@ -124,17 +124,17 @@ $if(showSlideNumber)$ // 'all', 'print', or 'speaker' showSlideNumber: '$showSlideNumber$', $endif$ -$if(hash)$ // Add the current slide number to the URL hash so that reloading the // page/copying the URL will return you to the same slide - hash: $hash$, -$endif$ + hash: $if(hash)$$hash$$else$true$endif$, $if(hashOneBasedIndex)$ // Start with 1 for the hash rather than 0 hashOneBasedIndex: $hashOneBasedIndex$, $endif$ +$if(history)$ // Push each slide change to the browser history - history: $if(history)$$history$$else$true$endif$, + history: $history$, +$endif$ $if(keyboard)$ // Enable keyboard shortcuts for navigation keyboard: $keyboard$, -- cgit v1.2.3 From 14b2eb2aeb21b3dee7d07c7348ebd2c586d6a866 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 21 Jun 2021 16:40:52 -0700 Subject: reveal.js writer: better handling of options. Previously it was impossible to specify false values for options that default to true; setting the option to false just caused the portion of the template setting the option to be omitted. Now we prepopulate all the variables with their default values, including them unconditionally and allowing them to be overridden. --- data/templates/default.revealjs | 198 ++++++++++++++-------------------------- src/Text/Pandoc/Writers/HTML.hs | 50 ++++++++++ 2 files changed, 120 insertions(+), 128 deletions(-) (limited to 'data') diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs index 8a77674dd..203983522 100644 --- a/data/templates/default.revealjs +++ b/data/templates/default.revealjs @@ -90,256 +90,198 @@ $endif$ // Full list of configuration options available at: // https://revealjs.com/config/ Reveal.initialize({ -$if(center)$ - // Determines whether slide content should be vertically centered - center: $center$, -$endif$ -$if(controls)$ // Display controls in the bottom right corner controls: $controls$, -$endif$ -$if(controlsTutorial)$ + // Help the user learn the controls by providing hints, for example by // bouncing the down arrow when they first encounter a vertical slide controlsTutorial: $controlsTutorial$, -$endif$ -$if(controlsLayout)$ + // Determines where controls appear, "edges" or "bottom-right" controlsLayout: '$controlsLayout$', -$endif$ -$if(controlsBackArrows)$ + // Visibility rule for backwards navigation arrows; "faded", "hidden" // or "visible" controlsBackArrows: '$controlsBackArrows$', -$endif$ -$if(progress)$ + // Display a presentation progress bar progress: $progress$, -$endif$ -$if(slideNumber)$ + // Display the page number of the current slide slideNumber: $slideNumber$, -$endif$ -$if(showSlideNumber)$ + // 'all', 'print', or 'speaker' showSlideNumber: '$showSlideNumber$', -$endif$ + // Add the current slide number to the URL hash so that reloading the // page/copying the URL will return you to the same slide - hash: $if(hash)$$hash$$else$true$endif$, -$if(hashOneBasedIndex)$ + hash: $hash$, + // Start with 1 for the hash rather than 0 hashOneBasedIndex: $hashOneBasedIndex$, -$endif$ -$if(history)$ + + // Flags if we should monitor the hash and change slides accordingly + respondToHashChanges: $respondToHashChanges$, + // Push each slide change to the browser history history: $history$, -$endif$ -$if(keyboard)$ + // Enable keyboard shortcuts for navigation keyboard: $keyboard$, -$endif$ -$if(overview)$ + // Enable the slide overview mode overview: $overview$, -$endif$ -$if(center)$ + + // Disables the default reveal.js slide layout (scaling and centering) + // so that you can use custom CSS layout + disableLayout: false, + // Vertical centering of slides center: $center$, -$endif$ -$if(touch)$ + // Enables touch navigation on devices with touch input touch: $touch$, -$endif$ -$if(loop)$ + // Loop the presentation loop: $loop$, -$endif$ -$if(rtl)$ + // Change the presentation direction to be RTL rtl: $rtl$, -$endif$ -$if(navigationMode)$ + // see https://revealjs.com/vertical-slides/#navigation-mode navigationMode: '$navigationMode$', -$endif$ -$if(shuffle)$ + // Randomizes the order of slides each time the presentation loads shuffle: $shuffle$, -$endif$ -$if(fragments)$ + // Turns fragments on and off globally fragments: $fragments$, -$endif$ -$if(fragmentInURL)$ + // Flags whether to include the current fragment in the URL, // so that reloading brings you to the same fragment position fragmentInURL: $fragmentInURL$, -$endif$ -$if(embedded)$ + // Flags if the presentation is running in an embedded mode, // i.e. contained within a limited portion of the screen embedded: $embedded$, -$endif$ -$if(help)$ + // Flags if we should show a help overlay when the questionmark // key is pressed help: $help$, -$endif$ -$if(pause)$ - // Flags if it should be possible to pause the presentation (blackout) - pause: $pause$, -$endif$ -$if(showNotes)$ + + // Flags if it should be possible to pause the presentation (blackout) + pause: $pause$, + // Flags if speaker notes should be visible to all viewers showNotes: $showNotes$, -$endif$ -$if(autoPlayMedia)$ - // Global override for autoplaying embedded media (video/audio/iframe) - // - null: Media will only autoplay if data-autoplay is present - // - true: All media will autoplay, regardless of individual setting - // - false: No media will autoplay, regardless of individual setting + + // Global override for autoplaying embedded media (null/true/false) autoPlayMedia: $autoPlayMedia$, -$endif$ -$if(preloadIframes)$ - // Global override for preloading lazy-loaded iframes - // - null: Iframes with data-src AND data-preload will be loaded when within - // the viewDistance, iframes with only data-src will be loaded when visible - // - true: All iframes with data-src will be loaded when within the viewDistance - // - false: All iframes with data-src will be loaded only when visible + + // Global override for preloading lazy-loaded iframes (null/true/false) preloadIframes: $preloadIframes$, -$endif$ -$if(autoSlide)$ + // Number of milliseconds between automatically proceeding to the // next slide, disabled when set to 0, this value can be overwritten // by using a data-autoslide attribute on your slides autoSlide: $autoSlide$, -$endif$ -$if(autoSlideStoppable)$ + // Stop auto-sliding after user input autoSlideStoppable: $autoSlideStoppable$, -$endif$ -$if(autoSlideMethod)$ + // Use this method for navigation when auto-sliding autoSlideMethod: $autoSlideMethod$, -$endif$ -$if(defaultTiming)$ + // Specify the average time in seconds that you think you will spend // presenting each slide. This is used to show a pacing timer in the // speaker view defaultTiming: $defaultTiming$, -$endif$ -$if(totalTime)$ - // Specify the total time in seconds that is available to - // present. If this is set to a nonzero value, the pacing - // timer will work out the time available for each slide, - // instead of using the defaultTiming value - totalTime: $totalTime$, -$endif$ -$if(minimumTimePerSlide)$ - // Specify the minimum amount of time you want to allot to - // each slide, if using the totalTime calculation method. If - // the automated time allocation causes slide pacing to fall - // below this threshold, then you will see an alert in the - // speaker notes window - minimumTimePerSlide: $minimumTimePerSlide$, -$endif$ -$if(mouseWheel)$ + // Enable slide navigation via mouse wheel mouseWheel: $mouseWheel$, -$endif$ -$if(rollingLinks)$ - // Apply a 3D roll to links on hover - rollingLinks: $rollingLinks$, -$endif$ -$if(hideInactiveCursor)$ + + // The display mode that will be used to show slides + display: '$display$', + // Hide cursor if inactive hideInactiveCursor: $hideInactiveCursor$, -$endif$ -$if(hideCursorTime)$ + // Time before the cursor is hidden (in ms) hideCursorTime: $hideCursorTime$, -$endif$ -$if(hideAddressBar)$ - // Hides the address bar on mobile devices - hideAddressBar: $hideAddressBar$, -$endif$ -$if(previewLinks)$ + // Opens links in an iframe preview overlay previewLinks: $previewLinks$, -$endif$ -$if(transition)$ - // Transition style - transition: '$transition$', // none/fade/slide/convex/concave/zoom -$endif$ -$if(transitionSpeed)$ - // Transition speed - transitionSpeed: '$transitionSpeed$', // default/fast/slow -$endif$ -$if(backgroundTransition)$ + + // Transition style (none/fade/slide/convex/concave/zoom) + transition: '$transition$', + + // Transition speed (default/fast/slow) + transitionSpeed: '$transitionSpeed$', + // Transition style for full page slide backgrounds - backgroundTransition: '$backgroundTransition$', // none/fade/slide/convex/concave/zoom -$endif$ -$if(viewDistance)$ + // (none/fade/slide/convex/concave/zoom) + backgroundTransition: '$backgroundTransition$', + // Number of slides away from the current that are visible viewDistance: $viewDistance$, -$endif$ -$if(mobileViewDistance)$ + // Number of slides away from the current that are visible on mobile // devices. It is advisable to set this to a lower number than // viewDistance in order to save resources. mobileViewDistance: $mobileViewDistance$, -$endif$ $if(parallaxBackgroundImage)$ + // Parallax background image parallaxBackgroundImage: '$parallaxBackgroundImage$', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" $else$ $if(background-image)$ + // Parallax background image parallaxBackgroundImage: '$background-image$', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" $endif$ $endif$ $if(parallaxBackgroundSize)$ + // Parallax background size parallaxBackgroundSize: '$parallaxBackgroundSize$', // CSS syntax, e.g. "2100px 900px" $endif$ $if(parallaxBackgroundHorizontal)$ + // Amount to move parallax background (horizontal and vertical) on slide change // Number, e.g. 100 parallaxBackgroundHorizontal: $parallaxBackgroundHorizontal$, $endif$ $if(parallaxBackgroundVertical)$ + parallaxBackgroundVertical: $parallaxBackgroundVertical$, $endif$ $if(width)$ + // The "normal" size of the presentation, aspect ratio will be preserved // when the presentation is scaled to fit different resolutions. Can be // specified using percentage units. width: $width$, $endif$ $if(height)$ + height: $height$, $endif$ $if(margin)$ + // Factor of the display size that should remain empty around the content margin: $margin$, $endif$ $if(minScale)$ + // Bounds for smallest/largest possible scale to apply to content minScale: $minScale$, $endif$ $if(maxScale)$ + maxScale: $maxScale$, $endif$ -$if(zoomKey)$ - // Modifier key used to click-zoom to part of the slide - zoomKey: '$zoomKey$', -$endif$ -$if(display)$ - // The display mode that will be used to show slides - display: '$display$', -$endif$ $if(mathjax)$ + math: { mathjax: '$mathjaxurl$', config: 'TeX-AMS_HTML-full', diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index b1dd9a659..4d513df3b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -317,6 +317,10 @@ pandocToHtml opts (Pandoc meta blocks) = do | otherwise -> mempty Nothing -> mempty let mCss :: Maybe [Text] = lookupContext "css" metadata + let true :: Text + true = "true" + let false :: Text + false = "false" let context = (if stHighlighting st then case writerHighlightStyle opts of Just sty -> defField "highlighting-css" @@ -344,6 +348,52 @@ pandocToHtml opts (Pandoc meta blocks) = do PlainMath -> defField "displaymath-css" True WebTeX _ -> defField "displaymath-css" True _ -> id) . + (if slideVariant == RevealJsSlides + then -- set boolean options explicitly, since + -- template can't distinguish False/undefined + defField "controls" true . + defField "controlsTutorial" true . + defField "controlsLayout" ("bottom-right" :: Text) . + defField "controlsBackArrows" ("faded" :: Text) . + defField "progress" true . + defField "slideNumber" false . + defField "showSlideNumber" ("all" :: Text) . + defField "hashOneBasedIndex" false . + defField "hash" false . + defField "respondToHashChanges" true . + defField "history" false . + defField "keyboard" true . + defField "overview" true . + defField "disableLayout" false . + defField "center" true . + defField "touch" true . + defField "loop" false . + defField "rtl" false . + defField "navigationMode" ("default" :: Text) . + defField "shuffle" false . + defField "fragments" true . + defField "fragmentInURL" true . + defField "embedded" false . + defField "help" true . + defField "pause" true . + defField "showNotes" false . + defField "autoPlayMedia" ("null" :: Text) . + defField "preloadIframes" ("null" :: Text) . + defField "autoSlide" ("0" :: Text) . + defField "autoSlideStoppable" true . + defField "autoSlideMethod" ("null" :: Text) . + defField "defaultTiming" ("null" :: Text) . + defField "mouseWheel" false . + defField "display" ("block" :: Text) . + defField "hideInactiveCursor" true . + defField "hideCursorTime" ("5000" :: Text) . + defField "previewLinks" false . + defField "transition" ("slide" :: Text) . + defField "transitionSpeed" ("default" :: Text) . + defField "backgroundTransition" ("fade" :: Text) . + defField "viewDistance" ("3" :: Text) . + defField "mobileViewDistance" ("2" :: Text) + else id) . defField "document-css" (isNothing mCss && slideVariant == NoSlides) . defField "quotes" (stQuotes st) . -- for backwards compatibility we populate toc -- cgit v1.2.3 From 972db3cdcac19bca0dd4e0957514a48bbf1feacb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 3 Jul 2021 15:21:43 -0700 Subject: Revert "LaTeX template: move title, author, date up to top of preamble." This reverts commit cc088687b4013c2b8b744eb337ed04fc63f315f2 and PR #7295. This fixes issues people had when using LaTeX commands defined later in the preamble (or in some cases UTF-8 text) in the title or author fields. Closes #7422. --- data/templates/default.latex | 58 ++++++++++++++++++++--------------------- test/lhs-test.latex | 6 ++--- test/lhs-test.latex+lhs | 6 ++--- test/writer.latex | 8 +++--- test/writers-lang-and-dir.latex | 6 ++--- 5 files changed, 42 insertions(+), 42 deletions(-) (limited to 'data') diff --git a/data/templates/default.latex b/data/templates/default.latex index 60f9972c2..d06701675 100644 --- a/data/templates/default.latex +++ b/data/templates/default.latex @@ -36,35 +36,6 @@ $for(classoption)$ $classoption$$sep$, $endfor$ ]{$documentclass$} -$if(title)$ -\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} -$endif$ -$if(subtitle)$ -$if(beamer)$ -$else$ -\usepackage{etoolbox} -\makeatletter -\providecommand{\subtitle}[1]{% add subtitle to \maketitle - \apptocmd{\@title}{\par {\large #1 \par}}{}{} -} -\makeatother -$endif$ -\subtitle{$subtitle$} -$endif$ -\author{$for(author)$$author$$sep$ \and $endfor$} -\date{$date$} -$if(beamer)$ -$if(institute)$ -\institute{$for(institute)$$institute$$sep$ \and $endfor$} -$endif$ -$if(titlegraphic)$ -\titlegraphic{\includegraphics{$titlegraphic$}} -$endif$ -$if(logo)$ -\logo{\includegraphics{$logo$}} -$endif$ -$endif$ - $if(beamer)$ $if(background-image)$ \usebackgroundtemplate{% @@ -452,6 +423,35 @@ $if(csquotes)$ \usepackage{csquotes} $endif$ +$if(title)$ +\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} +$endif$ +$if(subtitle)$ +$if(beamer)$ +$else$ +\usepackage{etoolbox} +\makeatletter +\providecommand{\subtitle}[1]{% add subtitle to \maketitle + \apptocmd{\@title}{\par {\large #1 \par}}{}{} +} +\makeatother +$endif$ +\subtitle{$subtitle$} +$endif$ +\author{$for(author)$$author$$sep$ \and $endfor$} +\date{$date$} +$if(beamer)$ +$if(institute)$ +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +$if(titlegraphic)$ +\titlegraphic{\includegraphics{$titlegraphic$}} +$endif$ +$if(logo)$ +\logo{\includegraphics{$logo$}} +$endif$ +$endif$ + \begin{document} $if(has-frontmatter)$ \frontmatter diff --git a/test/lhs-test.latex b/test/lhs-test.latex index 20bc6ae19..fdc344335 100644 --- a/test/lhs-test.latex +++ b/test/lhs-test.latex @@ -4,9 +4,6 @@ % \documentclass[ ]{article} -\author{} -\date{} - \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -88,6 +85,9 @@ \usepackage{selnolig} % disable illegal ligatures \fi +\author{} +\date{} + \begin{document} \hypertarget{lhs-test}{% diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs index 327dac4ef..f9149ba02 100644 --- a/test/lhs-test.latex+lhs +++ b/test/lhs-test.latex+lhs @@ -4,9 +4,6 @@ % \documentclass[ ]{article} -\author{} -\date{} - \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -55,6 +52,9 @@ \usepackage{selnolig} % disable illegal ligatures \fi +\author{} +\date{} + \begin{document} \hypertarget{lhs-test}{% diff --git a/test/writer.latex b/test/writer.latex index 468c271bc..abf772df4 100644 --- a/test/writer.latex +++ b/test/writer.latex @@ -4,10 +4,6 @@ % \documentclass[ ]{article} -\title{Pandoc Test Suite} -\author{John MacFarlane \and Anonymous} -\date{July 17, 2006} - \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -71,6 +67,10 @@ \usepackage{selnolig} % disable illegal ligatures \fi +\title{Pandoc Test Suite} +\author{John MacFarlane \and Anonymous} +\date{July 17, 2006} + \begin{document} \maketitle diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex index e06fe05ed..d91f77325 100644 --- a/test/writers-lang-and-dir.latex +++ b/test/writers-lang-and-dir.latex @@ -5,9 +5,6 @@ \documentclass[ english, ]{article} -\author{} -\date{} - \usepackage{amsmath,amssymb} \usepackage{lmodern} \usepackage{iftex} @@ -87,6 +84,9 @@ \newenvironment{LTR}{\beginL}{\endL} \fi +\author{} +\date{} + \begin{document} \hypertarget{empty-divs-and-spans}{% -- cgit v1.2.3 From de4da56079663dd31464525c23be3db1c0631f11 Mon Sep 17 00:00:00 2001 From: Mauro Bieg Date: Fri, 2 Jul 2021 09:27:15 +0200 Subject: document-css: reset overflow-wrap on code blocks fixes #7423 --- data/templates/styles.html | 3 ++- test/lhs-test.html | 3 ++- test/lhs-test.html+lhs | 3 ++- test/writer.html4 | 3 ++- test/writer.html5 | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) (limited to 'data') diff --git a/data/templates/styles.html b/data/templates/styles.html index e744d83b8..d26a39cf9 100644 --- a/data/templates/styles.html +++ b/data/templates/styles.html @@ -14,7 +14,7 @@ body { padding-top: $if(margin-top)$$margin-top$$else$50px$endif$; padding-bottom: $if(margin-bottom)$$margin-bottom$$else$50px$endif$; hyphens: auto; - word-wrap: break-word; + overflow-wrap: break-word; text-rendering: optimizeLegibility; font-kerning: normal; } @@ -93,6 +93,7 @@ $endif$ pre code { padding: 0; overflow: visible; + overflow-wrap: normal; } .sourceCode { background-color: transparent; diff --git a/test/lhs-test.html b/test/lhs-test.html index 89b49913e..be06d31c9 100644 --- a/test/lhs-test.html +++ b/test/lhs-test.html @@ -21,7 +21,7 @@ padding-top: 50px; padding-bottom: 50px; hyphens: auto; - word-wrap: break-word; + overflow-wrap: break-word; text-rendering: optimizeLegibility; font-kerning: normal; } @@ -92,6 +92,7 @@ pre code { padding: 0; overflow: visible; + overflow-wrap: normal; } .sourceCode { background-color: transparent; diff --git a/test/lhs-test.html+lhs b/test/lhs-test.html+lhs index ddd08e98a..4b37aca53 100644 --- a/test/lhs-test.html+lhs +++ b/test/lhs-test.html+lhs @@ -21,7 +21,7 @@ padding-top: 50px; padding-bottom: 50px; hyphens: auto; - word-wrap: break-word; + overflow-wrap: break-word; text-rendering: optimizeLegibility; font-kerning: normal; } @@ -92,6 +92,7 @@ pre code { padding: 0; overflow: visible; + overflow-wrap: normal; } .sourceCode { background-color: transparent; diff --git a/test/writer.html4 b/test/writer.html4 index 76578249a..215a1efb9 100644 --- a/test/writer.html4 +++ b/test/writer.html4 @@ -24,7 +24,7 @@ padding-top: 50px; padding-bottom: 50px; hyphens: auto; - word-wrap: break-word; + overflow-wrap: break-word; text-rendering: optimizeLegibility; font-kerning: normal; } @@ -95,6 +95,7 @@ pre code { padding: 0; overflow: visible; + overflow-wrap: normal; } .sourceCode { background-color: transparent; diff --git a/test/writer.html5 b/test/writer.html5 index cb9333efa..387df4058 100644 --- a/test/writer.html5 +++ b/test/writer.html5 @@ -24,7 +24,7 @@ padding-top: 50px; padding-bottom: 50px; hyphens: auto; - word-wrap: break-word; + overflow-wrap: break-word; text-rendering: optimizeLegibility; font-kerning: normal; } @@ -95,6 +95,7 @@ pre code { padding: 0; overflow: visible; + overflow-wrap: normal; } .sourceCode { background-color: transparent; -- cgit v1.2.3