@@ -599,19 +599,31 @@ pLineBreak = do
599 pSelfClosing (=="br") (const True)
599 pSelfClosing (=="br") (const True)
600 return B.linebreak
600 return B.linebreak
602+-- Unlike fromAttrib from tagsoup, this distinguishes
603+-- between a missing attribute and an attribute with empty content.
604+maybeFromAttrib :: String -> Tag String -> Maybe String
605+maybeFromAttrib name (TagOpen _ attrs) = lookup name attrs
606+maybeFromAttrib _ _ = Nothing
602pLink :: TagParser Inlines
608pLink :: TagParser Inlines
603pLink = try $ do
609pLink = try $ do
604 tag <- pSatisfy $ tagOpenLit "a" (const True)
610 tag <- pSatisfy $ tagOpenLit "a" (const True)
605− mbBaseHref <- baseHref <$> getState
606− let url' = fromAttrib "href" tag
607− let url = case (parseURIReference url', mbBaseHref) of
608− (Just rel, Just bs) -> show (rel `nonStrictRelativeTo` bs)
610 let title = fromAttrib "title" tag
611 let title = fromAttrib "title" tag
612+ -- take id from id attribute if present, otherwise name
611− let uid = fromAttrib "id" tag
613+ let uid = maybe (fromAttrib "name" tag) id $ maybeFromAttrib "id" tag
612 let cls = words $ fromAttrib "class" tag
614 let cls = words $ fromAttrib "class" tag
613 lab <- trimInlines . mconcat <$> manyTill inline (pCloses "a")
615 lab <- trimInlines . mconcat <$> manyTill inline (pCloses "a")
616+ -- check for href; if href, then a link, otherwise a span
617+ case maybeFromAttrib "href" tag of
619+ return $ B.spanWith (uid, cls, []) lab
621+ mbBaseHref <- baseHref <$> getState
622+ let url = case (parseURIReference url', mbBaseHref) of
623+ (Just rel, Just bs) ->
624+ show (rel `nonStrictRelativeTo` bs)
614− return $ B.linkWith (uid, cls, []) (escapeURI url) title lab
626+ return $ B.linkWith (uid, cls, []) (escapeURI url) title lab
616pImage :: TagParser Inlines
628pImage :: TagParser Inlines
617pImage = do
629pImage = do