Ms. writer: links: use footnote only for absolute URIs.

This commit is contained in:
John MacFarlane 2017-03-25 10:35:05 +01:00
parent 980cc50aff
commit 2e20129903
2 changed files with 27 additions and 98 deletions
src/Text/Pandoc/Writers
test

View file

@ -71,6 +71,7 @@ import Control.Monad.State
import Data.Char ( isLower, isUpper, toUpper ) import Data.Char ( isLower, isUpper, toUpper )
import Text.TeXMath (writeEqn) import Text.TeXMath (writeEqn)
import System.FilePath (takeExtension) import System.FilePath (takeExtension)
import Network.URI (isURI)
data WriterState = WriterState { stHasInlineMath :: Bool data WriterState = WriterState { stHasInlineMath :: Bool
, stFirstPara :: Bool , stFirstPara :: Bool
@ -477,7 +478,8 @@ inlineToMs opts (Link _ txt (src, _)) = do
[Str s] [Str s]
| escapeURI s == srcSuffix -> | escapeURI s == srcSuffix ->
return $ text (escapeString srcSuffix) return $ text (escapeString srcSuffix)
_ | inNote -> do _ | not (isURI src) -> inlineListToMs opts txt
| inNote -> do
-- avoid a note in a note! -- avoid a note in a note!
contents <- inlineListToMs opts txt contents <- inlineListToMs opts txt
return $ contents <> space <> char '(' <> return $ contents <> space <> char '(' <>

View file

@ -58,10 +58,7 @@ John Gruber's markdown test suite.
.SH 1 .SH 1
Headers Headers
.SH 2 .SH 2
Level 2 with an embedded link\** Level 2 with an embedded link
.FS
/url
.FE
.SH 3 .SH 3
Level 3 with \f[I]emphasis\f[] Level 3 with \f[I]emphasis\f[]
.SH 4 .SH 4
@ -574,10 +571,7 @@ This is \f[I]emphasized\f[], and so \f[I]is this\f[].
.PP .PP
This is \f[B]strong\f[], and so \f[B]is this\f[]. This is \f[B]strong\f[], and so \f[B]is this\f[].
.PP .PP
An \f[I]emphasized link\**\f[]. An \f[I]emphasized link\f[].
.FS
/url
.FE
.PP .PP
\f[B]\f[BI]This is strong and em.\f[B]\f[] \f[B]\f[BI]This is strong and em.\f[B]\f[]
.PP .PP
@ -721,92 +715,44 @@ Links
.SH 2 .SH 2
Explicit Explicit
.LP .LP
Just a URL\**. Just a URL.
.FS
/url/
.FE
.PP .PP
URL and title\**. URL and title.
.FS
/url/
.FE
.PP .PP
URL and title\**. URL and title.
.FS
/url/
.FE
.PP .PP
URL and title\**. URL and title.
.FS
/url/
.FE
.PP .PP
URL and title\** URL and title
.FS
/url/
.FE
.PP .PP
URL and title\** URL and title
.FS
/url/
.FE
.PP .PP
with_underscore\** with_underscore
.FS
/url/with_underscore
.FE
.PP .PP
Email link\** Email link\**
.FS .FS
mailto:nobody\@nowhere.net mailto:nobody\@nowhere.net
.FE .FE
.PP .PP
Empty\**. Empty.
.FS
.FE
.SH 2 .SH 2
Reference Reference
.LP .LP
Foo bar\**. Foo bar.
.FS
/url/
.FE
.PP .PP
Foo bar\**. Foo bar.
.FS
/url/
.FE
.PP .PP
Foo bar\**. Foo bar.
.FS
/url/
.FE
.PP .PP
With embedded [brackets]\**. With embedded [brackets].
.FS
/url/
.FE
.PP .PP
b\** b by itself should be a link.
.FS
/url/
.FE
by itself should be a link.
.PP .PP
Indented once\**. Indented once.
.FS
/url
.FE
.PP .PP
Indented twice\**. Indented twice.
.FS
/url
.FE
.PP .PP
Indented thrice\**. Indented thrice.
.FS
/url
.FE
.PP .PP
This should [not][] be a link. This should [not][] be a link.
.IP .IP
@ -816,15 +762,9 @@ This should [not][] be a link.
\f[] \f[]
.fi .fi
.LP .LP
Foo bar\**. Foo bar.
.FS
/url/
.FE
.PP .PP
Foo biz\**. Foo biz.
.FS
/url/
.FE
.SH 2 .SH 2
With ampersands With ampersands
.LP .LP
@ -838,15 +778,9 @@ Here's a link with an amersand in the link text: AT&T\**.
http://att.com/ http://att.com/
.FE .FE
.PP .PP
Here's an inline link\**. Here's an inline link.
.FS
/script?foo=1&bar=2
.FE
.PP .PP
Here's an inline link in pointy braces\**. Here's an inline link in pointy braces.
.FS
/script?foo=1&bar=2
.FE
.SH 2 .SH 2
Autolinks Autolinks
.LP .LP
@ -877,16 +811,9 @@ Images
.LP .LP
From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902): From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902):
.PP .PP
[IMAGE: lalune\**] [IMAGE: lalune]
.FS
lalune.jpg
.FE
.PP .PP
Here is a movie [IMAGE: movie\**] Here is a movie [IMAGE: movie] icon.
.FS
movie.jpg
.FE
icon.
.HLINE .HLINE
.SH 1 .SH 1
Footnotes Footnotes