Markdown/RST writers: Only autolink absolute URIs.
This fixes a regression and closes #830. $ echo '<a href="x">x</a>' | pandoc -f html -t markdown <x>
This commit is contained in:
parent
d606d74b22
commit
931b22184a
2 changed files with 8 additions and 4 deletions
|
@ -44,6 +44,7 @@ import qualified Data.Set as Set
|
|||
import Text.Pandoc.Writers.HTML (writeHtmlString)
|
||||
import Text.Pandoc.Readers.TeXMath (readTeXMath)
|
||||
import Text.HTML.TagSoup (renderTags, parseTags, isTagText, Tag(..))
|
||||
import Network.URI (isAbsoluteURI)
|
||||
import Data.Default
|
||||
|
||||
type Notes = [[Block]]
|
||||
|
@ -680,7 +681,8 @@ inlineToMarkdown opts (Link txt (src, tit)) = do
|
|||
then empty
|
||||
else text $ " \"" ++ tit ++ "\""
|
||||
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
|
||||
let useAuto = case txt of
|
||||
let useAuto = isAbsoluteURI src &&
|
||||
case txt of
|
||||
[Str s] | escapeURI s == srcSuffix -> True
|
||||
_ -> False
|
||||
let useRefLinks = writerReferenceLinks opts && not useAuto
|
||||
|
|
|
@ -36,6 +36,7 @@ import Text.Pandoc.Options
|
|||
import Text.Pandoc.Shared
|
||||
import Text.Pandoc.Templates (renderTemplate)
|
||||
import Data.List ( isPrefixOf, intersperse, transpose )
|
||||
import Network.URI (isAbsoluteURI)
|
||||
import Text.Pandoc.Pretty
|
||||
import Control.Monad.State
|
||||
import Control.Applicative ( (<$>) )
|
||||
|
@ -364,9 +365,10 @@ inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para)
|
|||
inlineToRST Space = return space
|
||||
-- autolink
|
||||
inlineToRST (Link [Str str] (src, _))
|
||||
| if "mailto:" `isPrefixOf` src
|
||||
then src == escapeURI ("mailto:" ++ str)
|
||||
else src == escapeURI str = do
|
||||
| isAbsoluteURI src &&
|
||||
if "mailto:" `isPrefixOf` src
|
||||
then src == escapeURI ("mailto:" ++ str)
|
||||
else src == escapeURI str = do
|
||||
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
|
||||
return $ text srcSuffix
|
||||
inlineToRST (Link [Image alt (imgsrc,imgtit)] (src, _tit)) = do
|
||||
|
|
Loading…
Add table
Reference in a new issue