Skip to content

Commit 6ac7e0b

Browse files
committed
Merge branch 'main' of github.com:jgm/pandoc into feature/8986-image-meta
2 parents 05584c0 + 76cd115 commit 6ac7e0b

File tree

17 files changed

+123
-54
lines changed

17 files changed

+123
-54
lines changed

MANUAL.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ When using LaTeX, the following packages need to be available
139139
[`iftex`], [`listings`] (if the
140140
`--listings` option is used), [`fancyvrb`], [`longtable`],
141141
[`booktabs`], [`graphicx`] (if the document
142-
contains images), [`hyperref`], [`xcolor`],
142+
contains images), [`bookmark`], [`xcolor`],
143143
[`soul`], [`geometry`] (with the `geometry` variable set),
144144
[`setspace`] (with `linestretch`), and
145145
[`babel`] (with `lang`). If `CJKmainfont` is set, [`xeCJK`]
@@ -157,9 +157,8 @@ output quality if present, but pandoc does not require them to
157157
be present: [`upquote`] (for straight quotes in verbatim
158158
environments), [`microtype`] (for better spacing adjustments),
159159
[`parskip`] (for better inter-paragraph spaces), [`xurl`] (for
160-
better line breaks in URLs), [`bookmark`] (for better PDF
161-
bookmarks), and [`footnotehyper`] or [`footnote`] (to allow
162-
footnotes in tables).
160+
better line breaks in URLs), and [`footnotehyper`] or
161+
[`footnote`] (to allow footnotes in tables).
163162

164163
[TeX Live]: https://www.tug.org/texlive/
165164
[`amsfonts`]: https://ctan.org/pkg/amsfonts

data/templates/default.latex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ $endif$
425425
$if(csquotes)$
426426
\usepackage{csquotes}
427427
$endif$
428-
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
428+
\usepackage{bookmark}
429429
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
430430
\urlstyle{$if(urlstyle)$$urlstyle$$else$same$endif$}
431431
$if(links-as-notes)$

src/Text/Pandoc/Citeproc.hs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ processCitations (Pandoc meta bs) = do
7676
let citations = getCitations locale otherIdsMap $ Pandoc meta' bs
7777

7878

79-
let linkCites = maybe False truish $ lookupMeta "link-citations" meta
79+
let linkCites = maybe False truish (lookupMeta "link-citations" meta) &&
80+
-- don't link citations if no bibliography to link to:
81+
not (maybe False truish (lookupMeta "suppress-bibliography" meta))
8082
let linkBib = maybe True truish $ lookupMeta "link-bibliography" meta
8183
let opts = defaultCiteprocOptions{ linkCitations = linkCites
8284
, linkBibliography = linkBib }
@@ -479,9 +481,9 @@ isYesValue _ = False
479481
insertRefs :: [(Text,Text)] -> [Text] -> [Block] -> Pandoc -> Pandoc
480482
insertRefs _ _ [] d = d
481483
insertRefs refkvs refclasses refs (Pandoc meta bs) =
482-
if isRefRemove meta
483-
then Pandoc meta bs
484-
else case runState (walkM go (Pandoc meta bs)) False of
484+
case lookupMeta "suppress-bibliography" meta of
485+
Just x | truish x -> Pandoc meta bs
486+
_ -> case runState (walkM go (Pandoc meta bs)) False of
485487
(d', True) -> d'
486488
(Pandoc meta' bs', False)
487489
-> Pandoc meta' $
@@ -517,10 +519,6 @@ refTitle meta =
517519
Just (MetaBlocks [Para ils]) -> Just ils
518520
_ -> Nothing
519521

520-
isRefRemove :: Meta -> Bool
521-
isRefRemove meta =
522-
maybe False truish $ lookupMeta "suppress-bibliography" meta
523-
524522
legacyDateRanges :: Reference Inlines -> Reference Inlines
525523
legacyDateRanges ref =
526524
ref{ referenceVariables = M.map go $ referenceVariables ref }

src/Text/Pandoc/PDF.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ tex2pdf :: (PandocMonad m, MonadIO m)
267267
tex2pdf program args tmpDir source = do
268268
let numruns | takeBaseName program == "latexmk" = 1
269269
| "\\tableofcontents" `T.isInfixOf` source = 3 -- to get page numbers
270-
| otherwise = 2 -- 1 run won't give you PDF bookmarks
270+
| otherwise = 1
271271
(exit, log', mbPdf) <- runTeXProgram program args numruns tmpDir source
272272
case (exit, mbPdf) of
273273
(ExitFailure _, _) -> do

src/Text/Pandoc/Readers/Markdown.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ referenceLink constructor (lab, raw) = do
19281928
<|>
19291929
try ((guardDisabled Ext_spaced_reference_links <|> spnl) >> reference)
19301930
when (raw' == "") $ guardEnabled Ext_shortcut_reference_links
1931+
!attr <- option nullAttr $ guardEnabled Ext_link_attributes >> attributes
19311932
let !labIsRef = raw' == "" || raw' == "[]"
19321933
let (exclam, rawsuffix) =
19331934
case T.uncons raw of
@@ -1956,11 +1957,11 @@ referenceLink constructor (lab, raw) = do
19561957
then do
19571958
headerKeys <- asksF stateHeaderKeys
19581959
case M.lookup key headerKeys of
1959-
Just ((src, tit), _) -> constructor nullAttr src tit <$> lab
1960+
Just ((src, tit), _) -> constructor attr src tit <$> lab
19601961
Nothing -> makeFallback
19611962
else makeFallback
1962-
Just ((src,tit), attr) ->
1963-
constructor attr src tit <$> lab
1963+
Just ((src,tit), defattr) ->
1964+
constructor (combineAttr attr defattr) src tit <$> lab
19641965

19651966
dropBrackets :: Text -> Text
19661967
dropBrackets = dropRB . dropLB

src/Text/Pandoc/RoffChar.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ standardEscapes =
3434
, ('`', "\\[ga]")
3535
, ('^', "\\[ha]")
3636
, ('~', "\\[ti]")
37+
, ('-', "\\-")
3738
, ('\\', "\\[rs]")
3839
, ('@', "\\[at]") -- because we use @ as a table and math delimiter
3940
, ('\x2026', "\\&...") -- because u2026 doesn't render on tty

src/Text/Pandoc/Shared.hs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module Text.Pandoc.Shared (
5050
linesToPara,
5151
figureDiv,
5252
makeSections,
53+
combineAttr,
5354
uniqueIdent,
5455
inlineListToIdentifier,
5556
textToIdentifier,
@@ -562,13 +563,15 @@ makeSections numbering mbBaseLevel bs =
562563
go (x:xs) = (x :) <$> go xs
563564
go [] = return []
564565

565-
combineAttr :: Attr -> Attr -> Attr
566-
combineAttr (id1, classes1, kvs1) (id2, classes2, kvs2) =
567-
(if T.null id1 then id2 else id1,
568-
nubOrd (classes1 ++ classes2),
569-
foldr (\(k,v) kvs -> case lookup k kvs of
570-
Nothing -> (k,v):kvs
571-
Just _ -> kvs) mempty (kvs1 ++ kvs2))
566+
-- | Combine two 'Attr'. Classes are concatenated. For the id and key-value
567+
-- attributes, the first one takes precedence in case of duplicates.
568+
combineAttr :: Attr -> Attr -> Attr
569+
combineAttr (id1, classes1, kvs1) (id2, classes2, kvs2) =
570+
(if T.null id1 then id2 else id1,
571+
nubOrd (classes1 ++ classes2),
572+
foldr (\(k,v) kvs -> case lookup k kvs of
573+
Nothing -> (k,v):kvs
574+
Just _ -> kvs) kvs1 kvs2)
572575

573576
headerLtEq :: Int -> Block -> Bool
574577
headerLtEq level (Header l _ _) = l <= level

src/Text/Pandoc/Writers/JATS.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ docToJATS opts (Pandoc meta blocks') = do
113113
$ ensureReferenceHeader blocks'
114114
let splitBackBlocks b@(Div ("refs",_,_) _) (fs, bs) = (fs, b:bs)
115115
splitBackBlocks (Div (ident,("section":_),_)
116-
[ Header lev (_,hcls,hkvs) hils
117-
, (Div rattrs@("refs",_,_) rs)
118-
]) (fs, bs)
119-
= (fs, Div rattrs
120-
(Header lev (ident,hcls,hkvs) hils : rs) : bs)
116+
( Header lev (_,hcls,hkvs) hils
117+
: (Div rattrs@("refs",_,_) rs)
118+
: rest
119+
)) (fs, bs)
120+
= (fs ++ rest,
121+
Div rattrs
122+
(Header lev (ident,hcls,hkvs) hils : rs) : bs)
121123
splitBackBlocks b (fs, bs) = (b:fs, bs)
122124
let (bodyblocks, backblocks) = foldr splitBackBlocks ([],[]) blocks
123125
let colwidth = if writerWrapText opts == WrapAuto

src/Text/Pandoc/Writers/Ms.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ blockToMs opts (Figure figattr (Caption _ caption) body) =
313313
".pdf" -> ".PDFPIC"
314314
_ -> "\\\" .IMAGE"
315315
return $ nowrap (literal cmd <+>
316-
doubleQuotes (literal (escapeStr opts src)) <>
316+
doubleQuotes (literal src) <>
317317
sizeAttrs) $$
318318
literal (".ce " <> tshow captlines) $$
319319
capt $$

test/command/5620.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
: Write output to *OUTFILE* instead of `stdout`(3)
55
^D
66
.TP
7-
\f[CR]-o\f[R], \f[CR]--output=\f[R]\f[I]OUTFILE\f[R]
7+
\f[CR]\-o\f[R], \f[CR]\-\-output=\f[R]\f[I]OUTFILE\f[R]
88
Write output to \f[I]OUTFILE\f[R] instead of \f[CR]stdout\f[R](3)
99
```

0 commit comments

Comments
 (0)