git.iko.soy/typeable/pandoc
on master help sign in
Ms writer: better placement of header anchors.
commitd9e8e84be0fb873b90abc8cc43e66f83f17e0d83 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 26 Mar 2017, 10:44 (10 years ago) parente8d8d87
2 files changed+36−40
src/Text/Pandoc/Writers/Ms.hs+5−9 test/writer.ms+31−31
src/Text/Pandoc/Writers/Ms.hs+5−9
@@ -29,16 +29,12 @@ Conversion of 'Pandoc' documents to groff ms format.
2929
3030TODO:
3131
32−[ ] is there a way to avoid the extra space between internal links
33− and following punctuation?
34− internal links followed by a space also cause bad formatting
35− (a line break)
36− but adding \c at the end of the link text doesn't seem to work
32+[ ] external links
33+ http://pipeline.lbl.gov/code/3rd_party/licenses.win/groff/1.19.2/pdf/pdfmark.pdf
3734[ ] manually create TOC including internal links and pdf outline
3835 bookmarks? See
3936 http://pipeline.lbl.gov/code/3rd_party/licenses.win/groff/1.19.2/pdf/pdfmark.pdf
4037[ ] is there a better way to do strikeout?
41−[ ] options for hyperlink rendering (currently footnote)
4238[ ] tight/loose list distinction
4339-}
4440
@@ -250,7 +246,7 @@ blockToMs _ HorizontalRule = do
250246 return $ text ".HLINE"
251247blockToMs opts (Header level (ident,classes,_) inlines) = do
252248 setFirstPara
253− contents <- inlineListToMs' opts inlines
249+ contents <- inlineListToMs' opts $ map breakToSpace inlines
254250 let anchor = if null ident
255251 then empty
256252 else nowrap $
@@ -266,9 +262,9 @@ blockToMs opts (Header level (ident,classes,_) inlines) = do
266262 then ".NH"
267263 else ".SH"
268264 modify $ \st -> st{ stFirstPara = True }
269− return $ anchor $$
270− (text heading <> space <> text (show level)) $$
265+ return $ (text heading <> space <> text (show level)) $$
271266 contents $$
267+ anchor $$
272268 tocEntry
273269blockToMs _ (CodeBlock _ str) = do
274270 setFirstPara
test/writer.ms+31−31
@@ -60,41 +60,41 @@ This is a set of tests for pandoc.
6060Most of them are adapted from
6161John Gruber's markdown test suite.
6262.HLINE
63−.pdfhref M "headers"
6463.SH 1
6564Headers
66−.pdfhref M "level-2-with-an-embedded-link"
65+.pdfhref M "headers"
6766.SH 2
6867Level 2 with an embedded link
69−.pdfhref M "level-3-with-emphasis"
68+.pdfhref M "level-2-with-an-embedded-link"
7069.SH 3
7170Level 3 with \f[I]emphasis\f[]
72−.pdfhref M "level-4"
71+.pdfhref M "level-3-with-emphasis"
7372.SH 4
7473Level 4
75−.pdfhref M "level-5"
74+.pdfhref M "level-4"
7675.SH 5
7776Level 5
78−.pdfhref M "level-1"
77+.pdfhref M "level-5"
7978.SH 1
8079Level 1
81−.pdfhref M "level-2-with-emphasis"
80+.pdfhref M "level-1"
8281.SH 2
8382Level 2 with \f[I]emphasis\f[]
84−.pdfhref M "level-3"
83+.pdfhref M "level-2-with-emphasis"
8584.SH 3
8685Level 3
86+.pdfhref M "level-3"
8787.LP
8888with no blank line
89−.pdfhref M "level-2"
9089.SH 2
9190Level 2
91+.pdfhref M "level-2"
9292.LP
9393with no blank line
9494.HLINE
95−.pdfhref M "paragraphs"
9695.SH 1
9796Paragraphs
97+.pdfhref M "paragraphs"
9898.LP
9999Here's a regular paragraph.
100100.PP
@@ -113,9 +113,9 @@ There should be a hard line break
113113.br
114114here.
115115.HLINE
116−.pdfhref M "block-quotes"
117116.SH 1
118117Block Quotes
118+.pdfhref M "block-quotes"
119119.LP
120120E\-mail style:
121121.RS
@@ -157,9 +157,9 @@ This should not be a block quote: 2
157157.PP
158158And a following paragraph.
159159.HLINE
160−.pdfhref M "code-blocks"
161160.SH 1
162161Code Blocks
162+.pdfhref M "code-blocks"
163163.LP
164164Code:
165165.IP
@@ -185,12 +185,12 @@ These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{
185185\f[]
186186.fi
187187.HLINE
188−.pdfhref M "lists"
189188.SH 1
190189Lists
191−.pdfhref M "unordered"
190+.pdfhref M "lists"
192191.SH 2
193192Unordered
193+.pdfhref M "unordered"
194194.LP
195195Asterisks tight:
196196.IP \[bu] 2
@@ -239,9 +239,9 @@ Minus 1
239239Minus 2
240240.IP \[bu] 2
241241Minus 3
242−.pdfhref M "ordered"
243242.SH 2
244243Ordered
244+.pdfhref M "ordered"
245245.LP
246246Tight:
247247.IP "1." 3
@@ -289,9 +289,9 @@ back.
289289Item 2.
290290.IP "3." 3
291291Item 3.
292−.pdfhref M "nested"
293292.SH 2
294293Nested
294+.pdfhref M "nested"
295295.IP \[bu] 2
296296Tab
297297.RS 2
@@ -334,9 +334,9 @@ Foe
334334.RE
335335.IP "3." 3
336336Third
337−.pdfhref M "tabs-and-spaces"
338337.SH 2
339338Tabs and spaces
339+.pdfhref M "tabs-and-spaces"
340340.IP \[bu] 2
341341this is a list item
342342indented with tabs
@@ -351,9 +351,9 @@ indented with tabs
351351this is an example list item
352352indented with spaces
353353.RE
354−.pdfhref M "fancy-list-markers"
355354.SH 2
356355Fancy list markers
356+.pdfhref M "fancy-list-markers"
357357.IP "(2)" 4
358358begins with 2
359359.IP "(3)" 4
@@ -407,9 +407,9 @@ M.A.\ 2007
407407B.
408408Williams
409409.HLINE
410−.pdfhref M "definition-lists"
411410.SH 1
412411Definition Lists
412+.pdfhref M "definition-lists"
413413.LP
414414Tight using spaces:
415415.IP "apple"
@@ -524,9 +524,9 @@ sublist
524524.IP "2." 3
525525sublist
526526.RE
527−.pdfhref M "html-blocks"
528527.SH 1
529528HTML Blocks
529+.pdfhref M "html-blocks"
530530.LP
531531Simple block on one line:
532532foo
@@ -589,9 +589,9 @@ Code:
589589.LP
590590Hr's:
591591.HLINE
592−.pdfhref M "inline-markup"
593592.SH 1
594593Inline Markup
594+.pdfhref M "inline-markup"
595595.LP
596596This is \f[I]emphasized\f[], and so \f[I]is this\f[].
597597.PP
@@ -619,9 +619,9 @@ Subscripts: H\*<2\*>O, H\*<23\*>O, H\*<many\ of\ them\*>O.
619619These should not be superscripts or subscripts,
620620because of the unescaped spaces: a^b c^d, a~b c~d.
621621.HLINE
622−.pdfhref M "smart-quotes-ellipses-dashes"
623622.SH 1
624623Smart quotes, ellipses, dashes
624+.pdfhref M "smart-quotes-ellipses-dashes"
625625.LP
626626\[lq]Hello,\[rq] said the spider.
627627\[lq]`Shelob' is my name.\[rq]
@@ -645,9 +645,9 @@ Dashes between numbers: 5\[en]7, 255\[en]66, 1987\[en]1999.
645645.PP
646646Ellipses\&...and\&...and\&....
647647.HLINE
648−.pdfhref M "latex"
649648.SH 1
650649LaTeX
650+.pdfhref M "latex"
651651.IP \[bu] 2
652652.IP \[bu] 2
653653|2 + 2 = 4|
@@ -681,9 +681,9 @@ Escaped \f[C]$\f[]: $73 \f[I]this should be emphasized\f[] 23$.
681681.LP
682682Here's a LaTeX table:
683683.HLINE
684−.pdfhref M "special-characters"
685684.SH 1
686685Special Characters
686+.pdfhref M "special-characters"
687687.LP
688688Here is some unicode:
689689.IP \[bu] 2
@@ -739,12 +739,12 @@ Plus: +
739739.PP
740740Minus: \-
741741.HLINE
742−.pdfhref M "links"
743742.SH 1
744743Links
745−.pdfhref M "explicit"
744+.pdfhref M "links"
746745.SH 2
747746Explicit
747+.pdfhref M "explicit"
748748.LP
749749Just a URL.
750750.PP
@@ -766,9 +766,9 @@ mailto:nobody\@nowhere.net
766766.FE
767767.PP
768768Empty.
769−.pdfhref M "reference"
770769.SH 2
771770Reference
771+.pdfhref M "reference"
772772.LP
773773Foo bar.
774774.PP
@@ -797,9 +797,9 @@ This should [not][] be a link.
797797Foo bar.
798798.PP
799799Foo biz.
800−.pdfhref M "with-ampersands"
801800.SH 2
802801With ampersands
802+.pdfhref M "with-ampersands"
803803.LP
804804Here's a link with an ampersand in the URL\**.
805805.FS
@@ -814,9 +814,9 @@ http://att.com/
814814Here's an inline link.
815815.PP
816816Here's an inline link in pointy braces.
817−.pdfhref M "autolinks"
818817.SH 2
819818Autolinks
819+.pdfhref M "autolinks"
820820.LP
821821With an ampersand: http://example.com/?foo=1&bar=2
822822.IP \[bu] 2
@@ -840,9 +840,9 @@ or\ here:\ <http://example.com/>
840840\f[]
841841.fi
842842.HLINE
843−.pdfhref M "images"
844843.SH 1
845844Images
845+.pdfhref M "images"
846846.LP
847847From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902):
848848.PP
@@ -850,9 +850,9 @@ From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902):
850850.PP
851851Here is a movie [IMAGE: movie] icon.
852852.HLINE
853−.pdfhref M "footnotes"
854853.SH 1
855854Footnotes
855+.pdfhref M "footnotes"
856856.LP
857857Here is a footnote reference,\**
858858.FS