git.iko.soy/typeable/pandoc
on master help sign in
Ms writer improvements:

- added some variables to the default template. - cleaner output for images (stringify alt text).

commit48729f9715f4deec6d621c363fd4d16d089497b2 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 4 Apr 2017, 17:21 (10 years ago) parent65b692b
4 files changed+30−22
MANUAL.txt+15 data/templates/default.ms+4−4 src/Text/Pandoc/Writers/Ms.hs+3−4 test/writer.ms+8−14
MANUAL.txt+15
@@ -1508,6 +1508,21 @@ Variables for man pages
15081508`hyphenate`
15091509: if `true` (the default), hyphenation will be used
15101510
1511+Variables for ms
1512+----------------
1513+
1514+`pointsize`
1515+: point size (e.g. `10p`)
1516+
1517+`lineheight`
1518+: line height (e.g. `12p`)
1519+
1520+`fontfamily`
1521+: font family (e.g. `T` or `P`)
1522+
1523+`indent`
1524+: paragraph indent (e.g. `2m`)
1525+
15111526Using variables in templates
15121527----------------------------
15131528
data/templates/default.ms+4−4
@@ -27,13 +27,13 @@ $endif$
2727.\" header/footer width
2828.nr LT \n[LL]
2929.\" point size
30−.nr PS 10p
30+.nr PS $if(pointsize)$$pointsize$$else$10p$endif$
3131.\" line height
32−.nr VS 12p
32+.nr VS $if(lineheight)$$lineheight$$else$12p$endif$
3333.\" font family: A, BM, H, HN, N, P, T, ZCM
34−.fam T
34+.fam $if(fontfamily)$$fontfamily$$else$T$endif$
3535.\" paragraph indent
36−.nr PI 2m
36+.nr PI $if(indent)$$indent$$else$2m$endif$
3737.\" interparagraph space
3838.nr PD 0.33v
3939.\" footnote width
src/Text/Pandoc/Writers/Ms.hs+3−4
@@ -516,10 +516,9 @@ inlineToMs opts (Link _ txt (src, _)) = do
516516 doubleQuotes (text (escapeUri src)) <> text " -A " <>
517517 doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>
518518 text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"
519−inlineToMs opts (Image attr alternate (source, tit)) = do
520− let alt = if null alternate then [Str "image"] else alternate
521− linkPart <- inlineToMs opts (Link attr alt (source, tit))
522− return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'
519+inlineToMs _ (Image _ alternate (_, _)) =
520+ return $ char '[' <> text "IMAGE: " <>
521+ text (escapeString (stringify alternate)) <> char ']'
523522inlineToMs _ (Note contents) = do
524523 modify $ \st -> st{ stNotes = contents : stNotes st }
525524 return $ text "\\**"
test/writer.ms+8−14
@@ -17,15 +17,15 @@
1717.\" left margin
1818.nr PO 1.25i
1919.\" top margin
20−.nr HM 1.25in
20+.nr HM 1.25i
2121.\" bottom margin
22−.nr FM 1.25in
22+.nr FM 1.25i
2323.\" header/footer width
2424.nr LT \n[LL]
25−.\" point size (pt x 1000)
26−.nr PS 10000
27−.\" line height (pt x 1000)
28−.nr VS 12000
25+.\" point size
26+.nr PS 10p
27+.\" line height
28+.nr VS 12p
2929.\" font family: A, BM, H, HN, N, P, T, ZCM
3030.fam T
3131.\" paragraph indent
@@ -969,15 +969,9 @@ Images
969969.LP
970970From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902):
971971.PP
972−[IMAGE: \c
973−.pdfhref W -D "lalune.jpg" -A "\c" \
974− -- "lalune"
975−\&]
972+[IMAGE: lalune]
976973.PP
977−Here is a movie [IMAGE: \c
978−.pdfhref W -D "movie.jpg" -A "\c" \
979− -- "movie"
980−\&] icon.
974+Here is a movie [IMAGE: movie] icon.
981975.HLINE
982976.SH 1
983977Footnotes