Ms writer improvements:

- added some variables to the default template.
- cleaner output for images (stringify alt text).
This commit is contained in:
John MacFarlane 2017-04-04 17:21:02 +02:00
parent 65b692b413
commit 48729f9715
4 changed files with 30 additions and 22 deletions

View file

@ -1508,6 +1508,21 @@ Variables for man pages
`hyphenate`
: if `true` (the default), hyphenation will be used
Variables for ms
----------------
`pointsize`
: point size (e.g. `10p`)
`lineheight`
: line height (e.g. `12p`)
`fontfamily`
: font family (e.g. `T` or `P`)
`indent`
: paragraph indent (e.g. `2m`)
Using variables in templates
----------------------------

View file

@ -27,13 +27,13 @@ $endif$
.\" header/footer width
.nr LT \n[LL]
.\" point size
.nr PS 10p
.nr PS $if(pointsize)$$pointsize$$else$10p$endif$
.\" line height
.nr VS 12p
.nr VS $if(lineheight)$$lineheight$$else$12p$endif$
.\" font family: A, BM, H, HN, N, P, T, ZCM
.fam T
.fam $if(fontfamily)$$fontfamily$$else$T$endif$
.\" paragraph indent
.nr PI 2m
.nr PI $if(indent)$$indent$$else$2m$endif$
.\" interparagraph space
.nr PD 0.33v
.\" footnote width

View file

@ -516,10 +516,9 @@ inlineToMs opts (Link _ txt (src, _)) = do
doubleQuotes (text (escapeUri src)) <> text " -A " <>
doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>
text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"
inlineToMs opts (Image attr alternate (source, tit)) = do
let alt = if null alternate then [Str "image"] else alternate
linkPart <- inlineToMs opts (Link attr alt (source, tit))
return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'
inlineToMs _ (Image _ alternate (_, _)) =
return $ char '[' <> text "IMAGE: " <>
text (escapeString (stringify alternate)) <> char ']'
inlineToMs _ (Note contents) = do
modify $ \st -> st{ stNotes = contents : stNotes st }
return $ text "\\**"

View file

@ -17,15 +17,15 @@
.\" left margin
.nr PO 1.25i
.\" top margin
.nr HM 1.25in
.nr HM 1.25i
.\" bottom margin
.nr FM 1.25in
.nr FM 1.25i
.\" header/footer width
.nr LT \n[LL]
.\" point size (pt x 1000)
.nr PS 10000
.\" line height (pt x 1000)
.nr VS 12000
.\" point size
.nr PS 10p
.\" line height
.nr VS 12p
.\" font family: A, BM, H, HN, N, P, T, ZCM
.fam T
.\" paragraph indent
@ -969,15 +969,9 @@ Images
.LP
From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902):
.PP
[IMAGE: \c
.pdfhref W -D "lalune.jpg" -A "\c" \
-- "lalune"
\&]
[IMAGE: lalune]
.PP
Here is a movie [IMAGE: \c
.pdfhref W -D "movie.jpg" -A "\c" \
-- "movie"
\&] icon.
Here is a movie [IMAGE: movie] icon.
.HLINE
.SH 1
Footnotes