Improved handling of code in man writer.
+ Inline code is now in monoscpace, not bold. + Code blocks now use .nf (no fill) and .IP (indented paragraph). + Resolves Issue #247.
This commit is contained in:
parent
1436437683
commit
8757da76b0
2 changed files with 81 additions and 55 deletions
|
@ -151,8 +151,12 @@ blockToMan opts (Header level inlines) = do
|
||||||
_ -> ".SS "
|
_ -> ".SS "
|
||||||
return $ text heading <> contents
|
return $ text heading <> contents
|
||||||
blockToMan _ (CodeBlock _ str) = return $
|
blockToMan _ (CodeBlock _ str) = return $
|
||||||
text ".PP" $$ text "\\f[CR]" $$
|
text ".IP" $$
|
||||||
text ((unlines . map (" " ++) . lines) (escapeCode str)) <> text "\\f[]"
|
text ".nf" $$
|
||||||
|
text "\\f[C]" $$
|
||||||
|
text (escapeCode str) $$
|
||||||
|
text "\\f[]" $$
|
||||||
|
text ".fi"
|
||||||
blockToMan opts (BlockQuote blocks) = do
|
blockToMan opts (BlockQuote blocks) = do
|
||||||
contents <- blockListToMan opts blocks
|
contents <- blockListToMan opts blocks
|
||||||
return $ text ".RS" $$ contents $$ text ".RE"
|
return $ text ".RS" $$ contents $$ text ".RE"
|
||||||
|
@ -300,7 +304,7 @@ inlineToMan _ EnDash = return $ text "\\[en]"
|
||||||
inlineToMan _ Apostrophe = return $ char '\''
|
inlineToMan _ Apostrophe = return $ char '\''
|
||||||
inlineToMan _ Ellipses = return $ text "\\&..."
|
inlineToMan _ Ellipses = return $ text "\\&..."
|
||||||
inlineToMan _ (Code str) =
|
inlineToMan _ (Code str) =
|
||||||
return $ text $ "\\f[B]" ++ escapeCode str ++ "\\f[]"
|
return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]"
|
||||||
inlineToMan _ (Str str) = return $ text $ escapeString str
|
inlineToMan _ (Str str) = return $ text $ escapeString str
|
||||||
inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str
|
inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str
|
||||||
inlineToMan opts (Math DisplayMath str) = do
|
inlineToMan opts (Math DisplayMath str) = do
|
||||||
|
|
120
tests/writer.man
120
tests/writer.man
|
@ -50,12 +50,14 @@ It is pretty short.
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.PP
|
||||||
Code in a block quote:
|
Code in a block quote:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
sub\ status\ {
|
\f[C]
|
||||||
\ \ \ \ print\ "working";
|
sub\ status\ {
|
||||||
}
|
\ \ \ \ print\ "working";
|
||||||
|
}
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
A list:
|
A list:
|
||||||
.IP "1." 3
|
.IP "1." 3
|
||||||
|
@ -82,24 +84,28 @@ And a following paragraph.
|
||||||
.SH Code Blocks
|
.SH Code Blocks
|
||||||
.PP
|
.PP
|
||||||
Code:
|
Code:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
----\ (should\ be\ four\ hyphens)
|
\f[C]
|
||||||
|
----\ (should\ be\ four\ hyphens)
|
||||||
|
|
||||||
sub\ status\ {
|
sub\ status\ {
|
||||||
\ \ \ \ print\ "working";
|
\ \ \ \ print\ "working";
|
||||||
}
|
}
|
||||||
|
|
||||||
this\ code\ block\ is\ indented\ by\ one\ tab
|
this\ code\ block\ is\ indented\ by\ one\ tab
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
And:
|
And:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
\ \ \ \ this\ code\ block\ is\ indented\ by\ two\ tabs
|
\f[C]
|
||||||
|
\ \ \ \ this\ code\ block\ is\ indented\ by\ two\ tabs
|
||||||
|
|
||||||
These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{
|
These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
* * * * *
|
* * * * *
|
||||||
.SH Lists
|
.SH Lists
|
||||||
|
@ -372,10 +378,12 @@ contains seeds, crisp, pleasant to taste
|
||||||
.B \f[I]orange\f[]
|
.B \f[I]orange\f[]
|
||||||
orange fruit
|
orange fruit
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
{\ orange\ code\ block\ }
|
\f[C]
|
||||||
|
{\ orange\ code\ block\ }
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.PP
|
||||||
orange block quote
|
orange block quote
|
||||||
|
@ -453,18 +461,22 @@ Here's a simple block:
|
||||||
foo
|
foo
|
||||||
.PP
|
.PP
|
||||||
This should be a code block, though:
|
This should be a code block, though:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
<div>
|
\f[C]
|
||||||
\ \ \ \ foo
|
<div>
|
||||||
</div>
|
\ \ \ \ foo
|
||||||
|
</div>
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
As should this:
|
As should this:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
<div>foo</div>
|
\f[C]
|
||||||
|
<div>foo</div>
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
Now, nested:
|
Now, nested:
|
||||||
foo
|
foo
|
||||||
|
@ -474,18 +486,22 @@ This should just be an HTML comment:
|
||||||
Multiline:
|
Multiline:
|
||||||
.PP
|
.PP
|
||||||
Code block:
|
Code block:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
<!--\ Comment\ -->
|
\f[C]
|
||||||
|
<!--\ Comment\ -->
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
Just plain comment, with trailing spaces on the line:
|
Just plain comment, with trailing spaces on the line:
|
||||||
.PP
|
.PP
|
||||||
Code:
|
Code:
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
<hr\ />
|
\f[C]
|
||||||
|
<hr\ />
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
Hr's:
|
Hr's:
|
||||||
.PP
|
.PP
|
||||||
|
@ -506,8 +522,8 @@ So is \f[B]\f[I]this\f[]\f[] word.
|
||||||
.PP
|
.PP
|
||||||
So is \f[B]\f[I]this\f[]\f[] word.
|
So is \f[B]\f[I]this\f[]\f[] word.
|
||||||
.PP
|
.PP
|
||||||
This is code: \f[B]>\f[], \f[B]$\f[], \f[B]\\\f[], \f[B]\\$\f[],
|
This is code: \f[C]>\f[], \f[C]$\f[], \f[C]\\\f[], \f[C]\\$\f[],
|
||||||
\f[B]<html>\f[].
|
\f[C]<html>\f[].
|
||||||
.PP
|
.PP
|
||||||
[STRIKEOUT:This is \f[I]strikeout\f[].]
|
[STRIKEOUT:This is \f[I]strikeout\f[].]
|
||||||
.PP
|
.PP
|
||||||
|
@ -531,7 +547,7 @@ So is `pine.'
|
||||||
.PP
|
.PP
|
||||||
`He said, \[lq]I want to go.\[rq]' Were you alive in the 70's?
|
`He said, \[lq]I want to go.\[rq]' Were you alive in the 70's?
|
||||||
.PP
|
.PP
|
||||||
Here is some quoted `\f[B]code\f[]' and a
|
Here is some quoted `\f[C]code\f[]' and a
|
||||||
\[lq]quoted link (http://example.com/?foo=1&bar=2)\[rq].
|
\[lq]quoted link (http://example.com/?foo=1&bar=2)\[rq].
|
||||||
.PP
|
.PP
|
||||||
Some dashes: one\[em]two \[em] three\[em]four \[em] five.
|
Some dashes: one\[em]two \[em] three\[em]four \[em] five.
|
||||||
|
@ -563,7 +579,7 @@ Here's one that has a line break in it: α + ω × \f[I]x\f[]^2^.
|
||||||
.PP
|
.PP
|
||||||
These shouldn't be math:
|
These shouldn't be math:
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
To get the famous equation, write \f[B]$e\ =\ mc^2$\f[].
|
To get the famous equation, write \f[C]$e\ =\ mc^2$\f[].
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
$22,000 is a \f[I]lot\f[] of money.
|
$22,000 is a \f[I]lot\f[] of money.
|
||||||
So is $34,000.
|
So is $34,000.
|
||||||
|
@ -571,7 +587,7 @@ So is $34,000.
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
Shoes ($20) and socks ($5).
|
Shoes ($20) and socks ($5).
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
Escaped \f[B]$\f[]: $73 \f[I]this should be emphasized\f[] 23$.
|
Escaped \f[C]$\f[]: $73 \f[I]this should be emphasized\f[] 23$.
|
||||||
.PP
|
.PP
|
||||||
Here's a LaTeX table:
|
Here's a LaTeX table:
|
||||||
.PP
|
.PP
|
||||||
|
@ -673,10 +689,12 @@ Indented twice (/url).
|
||||||
Indented thrice (/url).
|
Indented thrice (/url).
|
||||||
.PP
|
.PP
|
||||||
This should [not][] be a link.
|
This should [not][] be a link.
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
[not]:\ /url
|
\f[C]
|
||||||
|
[not]:\ /url
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
Foo bar (/url/).
|
Foo bar (/url/).
|
||||||
.PP
|
.PP
|
||||||
|
@ -708,11 +726,13 @@ An e-mail address: <nobody@nowhere.net>
|
||||||
Blockquoted: <http://example.com/>
|
Blockquoted: <http://example.com/>
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
Auto-links should not occur here: \f[B]<http://example.com/>\f[]
|
Auto-links should not occur here: \f[C]<http://example.com/>\f[]
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
or\ here:\ <http://example.com/>
|
\f[C]
|
||||||
|
or\ here:\ <http://example.com/>
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
* * * * *
|
* * * * *
|
||||||
.SH Images
|
.SH Images
|
||||||
|
@ -753,10 +773,12 @@ This one contains multiple blocks.
|
||||||
.PP
|
.PP
|
||||||
Subsequent blocks are indented to show that they belong to the
|
Subsequent blocks are indented to show that they belong to the
|
||||||
footnote (as with list items).
|
footnote (as with list items).
|
||||||
.PP
|
.IP
|
||||||
\f[CR]
|
.nf
|
||||||
\ \ {\ <code>\ }
|
\f[C]
|
||||||
|
\ \ {\ <code>\ }
|
||||||
\f[]
|
\f[]
|
||||||
|
.fi
|
||||||
.PP
|
.PP
|
||||||
If you want, you can indent every line, but you can also be lazy
|
If you want, you can indent every line, but you can also be lazy
|
||||||
and just indent the first line of each block.
|
and just indent the first line of each block.
|
||||||
|
@ -764,7 +786,7 @@ and just indent the first line of each block.
|
||||||
.SS [3]
|
.SS [3]
|
||||||
.PP
|
.PP
|
||||||
This is \f[I]easier\f[] to type.
|
This is \f[I]easier\f[] to type.
|
||||||
Inline notes may contain links (http://google.com) and \f[B]]\f[]
|
Inline notes may contain links (http://google.com) and \f[C]]\f[]
|
||||||
verbatim characters, as well as [bracketed text].
|
verbatim characters, as well as [bracketed text].
|
||||||
|
|
||||||
.SS [4]
|
.SS [4]
|
||||||
|
|
Loading…
Add table
Reference in a new issue