git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: extract spaces inside links instead of trimming them

Fixes #4845

commit937b92cd304a6a404f750c7f9a894adfb3638d01 authorAlexander Krotov <ilabdsf@gmail.com> dateWed 22 Aug 2018, 12:16 (8 years ago) parent3b5949e
2 files changed+9−3
src/Text/Pandoc/Readers/HTML.hs+3−3 test/command/4845.md+6
src/Text/Pandoc/Readers/HTML.hs+3−3
@@ -745,18 +745,18 @@ pLink = try $ do
745745 let uid = fromMaybe (T.unpack $ fromAttrib "name" tag) $
746746 maybeFromAttrib "id" tag
747747 let cls = words $ T.unpack $ fromAttrib "class" tag
748− lab <- trimInlines . mconcat <$> manyTill inline (pCloses "a")
748+ lab <- mconcat <$> manyTill inline (pCloses "a")
749749 -- check for href; if href, then a link, otherwise a span
750750 case maybeFromAttrib "href" tag of
751751 Nothing ->
752− return $ B.spanWith (uid, cls, []) lab
752+ return $ extractSpaces (B.spanWith (uid, cls, [])) lab
753753 Just url' -> do
754754 mbBaseHref <- baseHref <$> getState
755755 let url = case (parseURIReference url', mbBaseHref) of
756756 (Just rel, Just bs) ->
757757 show (rel `nonStrictRelativeTo` bs)
758758 _ -> url'
759− return $ B.linkWith (uid, cls, []) (escapeURI url) title lab
759+ return $ extractSpaces (B.linkWith (uid, cls, []) (escapeURI url) title) lab
760760
761761pImage :: PandocMonad m => TagParser m Inlines
762762pImage = do
test/command/4845.mdnew file+6
@@ -0,0 +1,6 @@
1+```
2+% pandoc -f html -t native
3+x<a href="/foo"> leading trailing space </a>x
4+^D
5+[Plain [Str "x",Space,Link ("",[],[]) [Str "leading",Space,Str "trailing",Space,Str "space"] ("/foo",""),Space,Str "x"]]
6+```