Ms writer: Hyperlink table of contents and other improvements.
This commit is contained in:
parent
0ae448e638
commit
0eb62f03fe
3 changed files with 46 additions and 13 deletions
|
@ -42,6 +42,17 @@
|
||||||
.ds PDFHREF.COLOUR 0.35 0.00 0.60
|
.ds PDFHREF.COLOUR 0.35 0.00 0.60
|
||||||
.\" border for links (default none)
|
.\" border for links (default none)
|
||||||
.ds PDFHREF.BORDER 0 0 0
|
.ds PDFHREF.BORDER 0 0 0
|
||||||
|
.\" point size difference between heading levels
|
||||||
|
.nr PSINCR 1p
|
||||||
|
.\" heading level above which point size no longer changes
|
||||||
|
.nr GROWPS 2
|
||||||
|
.\" comment these out if you want a dot after section numbers:
|
||||||
|
.als SN SN-NO-DOT
|
||||||
|
.als SN-STYLE SN-NO-DOT
|
||||||
|
.\" pdf outline fold level
|
||||||
|
.nr PDFOUTLINE.FOLDLEVEL 3
|
||||||
|
.\" start out in outline view
|
||||||
|
.pdfview /PageMode /UseOutlines
|
||||||
.\" ***************************************************************
|
.\" ***************************************************************
|
||||||
.\" PDF metadata
|
.\" PDF metadata
|
||||||
.pdfinfo /Title "$title-meta$"
|
.pdfinfo /Title "$title-meta$"
|
||||||
|
@ -85,7 +96,6 @@ $endfor$
|
||||||
.1C
|
.1C
|
||||||
$body$
|
$body$
|
||||||
$if(toc)$
|
$if(toc)$
|
||||||
$toc$
|
|
||||||
.TC
|
.TC
|
||||||
$endif$
|
$endif$
|
||||||
$for(include-after)$
|
$for(include-after)$
|
||||||
|
|
|
@ -116,7 +116,7 @@ pandocToMs opts (Pandoc meta blocks) = do
|
||||||
-- | Association list of characters to escape.
|
-- | Association list of characters to escape.
|
||||||
msEscapes :: Map.Map Char String
|
msEscapes :: Map.Map Char String
|
||||||
msEscapes = Map.fromList $
|
msEscapes = Map.fromList $
|
||||||
[ ('\160', "\\ ")
|
[ ('\160', "\\~")
|
||||||
, ('\'', "\\[aq]")
|
, ('\'', "\\[aq]")
|
||||||
, ('`', "\\`")
|
, ('`', "\\`")
|
||||||
, ('\8217', "'")
|
, ('\8217', "'")
|
||||||
|
@ -245,22 +245,34 @@ blockToMs _ HorizontalRule = do
|
||||||
blockToMs opts (Header level (ident,classes,_) inlines) = do
|
blockToMs opts (Header level (ident,classes,_) inlines) = do
|
||||||
setFirstPara
|
setFirstPara
|
||||||
contents <- inlineListToMs' opts $ map breakToSpace inlines
|
contents <- inlineListToMs' opts $ map breakToSpace inlines
|
||||||
|
let (heading, secnum) = if writerNumberSections opts &&
|
||||||
|
"unnumbered" `notElem` classes
|
||||||
|
then (".NH", "\\*[SN]")
|
||||||
|
else (".SH", "")
|
||||||
let anchor = if null ident
|
let anchor = if null ident
|
||||||
then empty
|
then empty
|
||||||
else nowrap $
|
else nowrap $
|
||||||
text ".pdfhref M " <> doubleQuotes (text ident)
|
text ".pdfhref M " <> doubleQuotes (text ident)
|
||||||
let bookmark = text ".pdfhref O " <> text (show level ++ " ") <>
|
let bookmark = text ".pdfhref O " <> text (show level ++ " ") <>
|
||||||
doubleQuotes (text (escapeString (stringify inlines)))
|
doubleQuotes (text $ secnum ++
|
||||||
|
(if null secnum
|
||||||
|
then ""
|
||||||
|
else " ") ++
|
||||||
|
escapeString (stringify inlines))
|
||||||
|
let backlink = nowrap (text ".pdfhref L -D " <>
|
||||||
|
doubleQuotes (text ident) <> space <> text "\\") <> cr <>
|
||||||
|
text " -- "
|
||||||
let tocEntry = if writerTableOfContents opts &&
|
let tocEntry = if writerTableOfContents opts &&
|
||||||
level <= writerTOCDepth opts
|
level <= writerTOCDepth opts
|
||||||
then text ".XS" $$
|
then text ".XS"
|
||||||
(text (replicate level '\t') <> contents) $$
|
$$ backlink <> doubleQuotes (
|
||||||
text ".XE"
|
nowrap ((text (replicate level '\t') <>
|
||||||
|
(if null secnum
|
||||||
|
then empty
|
||||||
|
else text secnum <> text "\\~\\~")
|
||||||
|
<> contents)))
|
||||||
|
$$ text ".XE"
|
||||||
else empty
|
else empty
|
||||||
let heading = if writerNumberSections opts &&
|
|
||||||
"unnumbered" `notElem` classes
|
|
||||||
then ".NH"
|
|
||||||
else ".SH"
|
|
||||||
modify $ \st -> st{ stFirstPara = True }
|
modify $ \st -> st{ stFirstPara = True }
|
||||||
return $ (text heading <> space <> text (show level)) $$
|
return $ (text heading <> space <> text (show level)) $$
|
||||||
contents $$
|
contents $$
|
||||||
|
|
|
@ -42,6 +42,17 @@
|
||||||
.ds PDFHREF.COLOUR 0.35 0.00 0.60
|
.ds PDFHREF.COLOUR 0.35 0.00 0.60
|
||||||
.\" border for links (default none)
|
.\" border for links (default none)
|
||||||
.ds PDFHREF.BORDER 0 0 0
|
.ds PDFHREF.BORDER 0 0 0
|
||||||
|
.\" point size difference between heading levels
|
||||||
|
.nr PSINCR 1p
|
||||||
|
.\" heading level above which point size no longer changes
|
||||||
|
.nr GROWPS 2
|
||||||
|
.\" comment these out if you want a dot after section numbers:
|
||||||
|
.als SN SN-NO-DOT
|
||||||
|
.als SN-STYLE SN-NO-DOT
|
||||||
|
.\" pdf outline fold level
|
||||||
|
.nr PDFOUTLINE.FOLDLEVEL 3
|
||||||
|
.\" start out in outline view
|
||||||
|
.pdfview /PageMode /UseOutlines
|
||||||
.\" ***************************************************************
|
.\" ***************************************************************
|
||||||
.\" PDF metadata
|
.\" PDF metadata
|
||||||
.pdfinfo /Title "Pandoc Test Suite"
|
.pdfinfo /Title "Pandoc Test Suite"
|
||||||
|
@ -427,7 +438,7 @@ Nested.
|
||||||
.LP
|
.LP
|
||||||
Should not be a list item:
|
Should not be a list item:
|
||||||
.PP
|
.PP
|
||||||
M.A.\ 2007
|
M.A.\~2007
|
||||||
.PP
|
.PP
|
||||||
B.
|
B.
|
||||||
Williams
|
Williams
|
||||||
|
@ -643,9 +654,9 @@ This is code: \f[C]>\f[], \f[C]$\f[], \f[C]\\\f[], \f[C]\\$\f[],
|
||||||
.PP
|
.PP
|
||||||
\m[strikecolor]This is \f[I]strikeout\f[].\m[]
|
\m[strikecolor]This is \f[I]strikeout\f[].\m[]
|
||||||
.PP
|
.PP
|
||||||
Superscripts: a\*{bc\*}d a\*{\f[I]hello\f[]\*} a\*{hello\ there\*}.
|
Superscripts: a\*{bc\*}d a\*{\f[I]hello\f[]\*} a\*{hello\~there\*}.
|
||||||
.PP
|
.PP
|
||||||
Subscripts: H\*<2\*>O, H\*<23\*>O, H\*<many\ of\ them\*>O.
|
Subscripts: H\*<2\*>O, H\*<23\*>O, H\*<many\~of\~them\*>O.
|
||||||
.PP
|
.PP
|
||||||
These should not be superscripts or subscripts,
|
These should not be superscripts or subscripts,
|
||||||
because of the unescaped spaces: a\[ha]b c\[ha]d, a\[ti]b c\[ti]d.
|
because of the unescaped spaces: a\[ha]b c\[ha]d, a\[ti]b c\[ti]d.
|
||||||
|
|
Loading…
Reference in a new issue