diff --git a/out-groffmm.go b/out-groffmm.go index 4a5ec00..2687121 100644 --- a/out-groffmm.go +++ b/out-groffmm.go @@ -26,8 +26,9 @@ import ( type troffOut struct { baseWriter - inListItem bool - escape *strings.Replacer + strikeMacroWritten bool + inListItem bool + escape *strings.Replacer } // Returns a formatter that writes the document in groff mm format. @@ -67,6 +68,10 @@ func (w *troffOut) s(s string) *troffOut { // write string, escape '\' func (w *troffOut) str(s string) *troffOut { + if strings.HasPrefix(s, ".") { + w.WriteString(`\[char46]`) + s = s[1:] + } w.escape.WriteString(w, s) return w } @@ -128,6 +133,17 @@ func (w *troffOut) elem(elt *element, isFirst bool) *troffOut { w.inline(`\fI`, elt, `\fR`) case STRONG: w.inline(`\fB`, elt, `\fR`) + case STRIKE: + w.s("\\c\n") + if !w.strikeMacroWritten { + w.s(`.de ST +.nr width \w'\\$1' +\Z@\v'-.25m'\l'\\n[width]u'@\\$1\c +.. +`) + w.strikeMacroWritten = true + } + w.inline(".ST \"", elt, `"`).br() case LIST: w.children(elt) case RAW: diff --git a/portid b/portid index 6772f05..385c287 100644 --- a/portid +++ b/portid @@ -1 +1 @@ -a79c71ede83f +ad324b86de96 diff --git a/tests/md1.0.3/Amps and angle encoding.mm b/tests/md1.0.3/Amps and angle encoding.mm index 13913e9..47364a8 100644 --- a/tests/md1.0.3/Amps and angle encoding.mm +++ b/tests/md1.0.3/Amps and angle encoding.mm @@ -11,8 +11,8 @@ This & that. .P Here's a link (http://example.com/?foo=1&bar=2) with an ampersand in the URL. .P -Here's a link with an amersand in the link text: AT&T (http://att.com/). +Here's a link with an amersand in the link text: AT&T (http://att.com/)\[char46] .P -Here's an inline link (/script?foo=1&bar=2). +Here's an inline link (/script?foo=1&bar=2)\[char46] .P -Here's an inline link (/script?foo=1&bar=2). +Here's an inline link (/script?foo=1&bar=2)\[char46] diff --git a/tests/md1.0.3/Auto links.mm b/tests/md1.0.3/Auto links.mm index fcdf6be..f4627c7 100644 --- a/tests/md1.0.3/Auto links.mm +++ b/tests/md1.0.3/Auto links.mm @@ -1,5 +1,5 @@ .P -Link: http://example.com/ (http://example.com/). +Link: http://example.com/ (http://example.com/)\[char46] .P With an ampersand: http://example.com/?foo=1&bar=2 (http://example.com/?foo=1&bar=2) .BL diff --git a/tests/md1.0.3/Backslash escapes.mm b/tests/md1.0.3/Backslash escapes.mm index 5429c3c..7835ea3 100644 --- a/tests/md1.0.3/Backslash escapes.mm +++ b/tests/md1.0.3/Backslash escapes.mm @@ -25,7 +25,7 @@ Greater-than: > .P Hash: # .P -Period: . +Period: \[char46] .P Bang: ! .P @@ -113,6 +113,6 @@ _underscores_ .P This is a code span with a literal backslash-backtick sequence: \fC\e`\fR .P -This is a tag with unescaped backticks bar. +This is a tag with unescaped backticks bar\[char46] .P -This is a tag with backslashes bar. +This is a tag with backslashes bar\[char46] diff --git a/tests/md1.0.3/Links, inline style.mm b/tests/md1.0.3/Links, inline style.mm index a0ead8d..54808fc 100644 --- a/tests/md1.0.3/Links, inline style.mm +++ b/tests/md1.0.3/Links, inline style.mm @@ -1,12 +1,12 @@ .P -Just a URL (/url/). +Just a URL (/url/)\[char46] .P -URL and title (/url/). +URL and title (/url/)\[char46] .P -URL and title (/url/). +URL and title (/url/)\[char46] .P -URL and title (/url/). +URL and title (/url/)\[char46] .P -URL and title (/url/). +URL and title (/url/)\[char46] .P -Empty (). +Empty ()\[char46] diff --git a/tests/md1.0.3/Links, reference style.mm b/tests/md1.0.3/Links, reference style.mm index 2cf1a47..ef36e0c 100644 --- a/tests/md1.0.3/Links, reference style.mm +++ b/tests/md1.0.3/Links, reference style.mm @@ -1,17 +1,17 @@ .P -Foo bar (/url/). +Foo bar (/url/)\[char46] .P -Foo bar (/url/). +Foo bar (/url/)\[char46] .P -Foo bar (/url/). +Foo bar (/url/)\[char46] .P -With embedded [brackets] (/url/). +With embedded [brackets] (/url/)\[char46] .P -Indented once (/url). +Indented once (/url)\[char46] .P -Indented twice (/url). +Indented twice (/url)\[char46] .P -Indented thrice (/url). +Indented thrice (/url)\[char46] .P Indented [four][] times. .VERBON 2 @@ -21,27 +21,27 @@ Indented [four][] times. .P this (foo) should work .P -So should this (foo). +So should this (foo)\[char46] .P -And this (foo). +And this (foo)\[char46] .P -And this (foo). +And this (foo)\[char46] .P -And this (foo). +And this (foo)\[char46] .P -But not [that] []. +But not [that] []\[char46] .P -Nor [that][]. +Nor [that][]\[char46] .P -Nor [that]. +Nor [that]\[char46] .P [Something in brackets like this (foo) should work] .P -[Same with this (foo).] +[Same with this (foo)\[char46]] .P In this case, this (/somethingelse/) points to something else. .P -Backslashing should suppress [this] and [this]. +Backslashing should suppress [this] and [this]\[char46] \l'\n(.lu*8u/10u' .P Here's one where the link diff --git a/tests/md1.0.3/Links, shortcut references.mm b/tests/md1.0.3/Links, shortcut references.mm index 9f9a466..2bfe600 100644 --- a/tests/md1.0.3/Links, shortcut references.mm +++ b/tests/md1.0.3/Links, shortcut references.mm @@ -1,8 +1,8 @@ .P -This is the simple case (/simple). +This is the simple case (/simple)\[char46] .P This one has a line -break (/foo). +break (/foo)\[char46] .P This one has a line break (/foo) with a line-ending space. diff --git a/tests/md1.0.3/Literal quotes in titles.mm b/tests/md1.0.3/Literal quotes in titles.mm index 4510639..2182bfc 100644 --- a/tests/md1.0.3/Literal quotes in titles.mm +++ b/tests/md1.0.3/Literal quotes in titles.mm @@ -1,4 +1,4 @@ .P -Foo bar (/url/). +Foo bar (/url/)\[char46] .P -Foo bar (/url/). +Foo bar (/url/)\[char46] diff --git a/tests/md1.0.3/Markdown Documentation - Basics.mm b/tests/md1.0.3/Markdown Documentation - Basics.mm index cadac2d..a802fa2 100644 --- a/tests/md1.0.3/Markdown Documentation - Basics.mm +++ b/tests/md1.0.3/Markdown Documentation - Basics.mm @@ -13,7 +13,7 @@ web application that allows you type your own Markdown-formatted text and translate it to XHTML. .P \fBNote:\fR This document is itself written using Markdown; you -can see the source for it by adding '.text' to the URL (/projects/markdown/basics.text). +can see the source for it by adding '\[char46]text' to the URL (/projects/markdown/basics.text)\[char46] .H 2 "Paragraphs, Headers, Blockquotes" .P A paragraph is simply one or more consecutive lines of text, separated @@ -21,7 +21,7 @@ by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing spaces or tabs is considered blank.) Normal paragraphs should not be intended with spaces or tabs. .P -Markdown offers two styles of headers: \fISetext\fR and \fIatx\fR. +Markdown offers two styles of headers: \fISetext\fR and \fIatx\fR\[char46] Setext-style headers for \fC