mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-30 17:59:17 +08:00
Man writer: Fix some spacing issues around links.
See #9120. We need to use `\c` before a `.UR` or `.MT`, to avoid an extra space, and also after. To ensure that a space at the beginning of the following line doesn't get swallowed up, we escape it with `\`.
This commit is contained in:
@@ -311,8 +311,8 @@ inlineToMan _ il@(RawInline f str)
|
||||
return empty
|
||||
inlineToMan _ LineBreak = return $
|
||||
cr <> literal ".PD 0" $$ literal ".P" $$ literal ".PD" <> cr
|
||||
inlineToMan _ SoftBreak = return space
|
||||
inlineToMan _ Space = return space
|
||||
inlineToMan _ SoftBreak = return $ afterBreak "\\" <> space
|
||||
inlineToMan _ Space = return $ afterBreak "\\" <> space
|
||||
inlineToMan opts (Link _ txt (src, _))
|
||||
| not (isURI src) = inlineListToMan opts txt -- skip relative links
|
||||
| otherwise = do
|
||||
@@ -323,7 +323,7 @@ inlineToMan opts (Link _ txt (src, _))
|
||||
let (start, end) = if "mailto:" `T.isPrefixOf` src
|
||||
then (".MT", ".ME")
|
||||
else (".UR", ".UE")
|
||||
return $ cr
|
||||
return $ "\\c" <> cr -- \c avoids extra space
|
||||
$$ (start <+> literal srcSuffix)
|
||||
$$ linktext
|
||||
$$ (end <+> "\\c" <> cr) -- \c avoids space after
|
||||
|
||||
@@ -50,7 +50,7 @@ import Safe (lastMay)
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import Control.Monad (zipWithM)
|
||||
import Data.Aeson (ToJSON (..), encode)
|
||||
import Data.Char (chr, ord, isSpace, isLetter)
|
||||
import Data.Char (chr, ord, isSpace, isLetter, isUpper)
|
||||
import Data.List (groupBy, intersperse, transpose, foldl')
|
||||
import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
|
||||
import Data.Text.Conversions (FromText(..))
|
||||
@@ -552,10 +552,10 @@ splitSentences :: Doc Text -> Doc Text
|
||||
splitSentences = go . toList
|
||||
where
|
||||
go [] = mempty
|
||||
go (Text len t : BreakingSpace : xs) =
|
||||
if isSentenceEnding t
|
||||
then Text len t <> NewLine <> go xs
|
||||
else Text len t <> BreakingSpace <> go xs
|
||||
go (Text len t : AfterBreak _ : BreakingSpace : xs)
|
||||
| isSentenceEnding t = Text len t <> NewLine <> go xs
|
||||
go (Text len t : BreakingSpace : xs)
|
||||
| isSentenceEnding t = Text len t <> NewLine <> go xs
|
||||
go (x:xs) = x <> go xs
|
||||
|
||||
toList (Concat (Concat a b) c) = toList (Concat a (Concat b c))
|
||||
|
||||
@@ -8,10 +8,12 @@ SEE ALSO
|
||||
^D
|
||||
.SH SEE ALSO
|
||||
.IP \[bu] 2
|
||||
\c
|
||||
.UR https://en.wikipedia.org/wiki/Milk
|
||||
Milk
|
||||
.UE \c
|
||||
.IP \[bu] 2
|
||||
\c
|
||||
.UR https://en.wikipedia.org/wiki/Extended_Backus–Naur_form
|
||||
EBNF
|
||||
.UE \c
|
||||
|
||||
+19
-15
@@ -483,9 +483,9 @@ So is `pine.'
|
||||
.PP
|
||||
`He said, \[lq]I want to go.\[rq]' Were you alive in the 70\[cq]s?
|
||||
.PP
|
||||
Here is some quoted `\f[CR]code\f[R]' and a \[lq]quoted
|
||||
link
|
||||
Here is some quoted `\f[CR]code\f[R]' and a \[lq]\c
|
||||
.UR http://example.com/?foo=1&bar=2
|
||||
quoted link
|
||||
.UE \c
|
||||
\[rq].
|
||||
.PP
|
||||
@@ -604,7 +604,10 @@ URL and title
|
||||
.PP
|
||||
with_underscore
|
||||
.PP
|
||||
Email link (mailto:nobody@nowhere.net)
|
||||
\c
|
||||
.MT nobody@nowhere.net
|
||||
Email link
|
||||
.ME \c
|
||||
.PP
|
||||
Empty.
|
||||
.SS Reference
|
||||
@@ -630,39 +633,40 @@ Foo bar.
|
||||
.PP
|
||||
Foo biz.
|
||||
.SS With ampersands
|
||||
Here\[cq]s a link with an ampersand in the
|
||||
URL
|
||||
Here\[cq]s a \c
|
||||
.UR http://example.com/?foo=1&bar=2
|
||||
link with an ampersand in the URL
|
||||
.UE \c
|
||||
.
|
||||
\&.
|
||||
.PP
|
||||
Here\[cq]s a link with an amersand in the link text:
|
||||
Here\[cq]s a link with an amersand in the link text: \c
|
||||
.UR http://att.com/
|
||||
AT&T
|
||||
.UE \c
|
||||
.
|
||||
\&.
|
||||
.PP
|
||||
Here\[cq]s an inline link.
|
||||
.PP
|
||||
Here\[cq]s an inline link in pointy braces.
|
||||
.SS Autolinks
|
||||
With an ampersand:
|
||||
With an ampersand: \c
|
||||
.UR http://example.com/?foo=1&bar=2
|
||||
.UE
|
||||
.UE \c
|
||||
.IP \[bu] 2
|
||||
In a list?
|
||||
.IP \[bu] 2
|
||||
\c
|
||||
.UR http://example.com/
|
||||
.UE \c
|
||||
.IP \[bu] 2
|
||||
It should.
|
||||
.PP
|
||||
An e-mail address:
|
||||
An e-mail address: \c
|
||||
.MT nobody@nowhere.net
|
||||
.ME \c
|
||||
.RS
|
||||
.PP
|
||||
Blockquoted:
|
||||
Blockquoted: \c
|
||||
.UR http://example.com/
|
||||
.UE \c
|
||||
.RE
|
||||
@@ -717,11 +721,11 @@ the first line of each block.
|
||||
.SS [3]
|
||||
.PP
|
||||
This is \f[I]easier\f[R] to type.
|
||||
Inline notes may contain links
|
||||
Inline notes may contain \c
|
||||
.UR http://google.com
|
||||
links
|
||||
.UE \c
|
||||
and \f[CR]]\f[R] verbatim
|
||||
characters, as well as [bracketed text].
|
||||
\ and \f[CR]]\f[R] verbatim characters, as well as [bracketed text].
|
||||
.SS [4]
|
||||
.PP
|
||||
In quote.
|
||||
|
||||
Reference in New Issue
Block a user