-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML Reader: be more forgiving about figcaption #4184
Conversation
88d4331
to
893fef2
Compare
src/Text/Pandoc/Readers/HTML.hs
Outdated
skipMany pBlank | ||
bs <- pInTags "figcaption" block | ||
skipMany pBlank | ||
let getInlines (Plain xs) = xs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we just use blocksToInlines
from Text.Pandoc.Shared
?
src/Text/Pandoc/Readers/HTML.hs
Outdated
return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption | ||
Just [Image attr alt (url, tit)] -> | ||
let caption = fromMaybe alt mbcap | ||
in return $ B.para $ B.imageWith attr url ("fig:" ++ tit) $ B.fromList caption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in the linked issue, I'm not convinced we should do this. The HTML doesn't have a caption, so why should we produce an image with a caption? The tricky thing is that we're overloading alt
; it will still be used for the image's alt text, which just disappears in the current setup. I'm not for the alt attribute disappearing, but I'm also hesitant about creating a caption where there wasn't one before.
Thanks for the feedback, I agree. One thing: |
+++ Mauro Bieg [Dec 22 17 11:23 ]:
Thanks for the feedback, I agree.
One thing: Text.Pandoc.Shared should also export blocksToInlines',
don't you think? The two places where blocksToInlines is already used,
fromList is immediately called on it. Should I make another pull for
that?
Sure.
|
893fef2
to
9b54b94
Compare
btw, I've rebased this and changed according to your comments. |
@@ -588,8 +588,11 @@ pFigure = try $ do | |||
skipMany pBlank | |||
let pImg = (\x -> (Just x, Nothing)) <$> | |||
(pOptInTag "p" pImage <* skipMany pBlank) | |||
pCapt = (\x -> (Nothing, Just x)) <$> | |||
(pInTags "figcaption" inline <* skipMany pBlank) | |||
pCapt = (\x -> (Nothing, Just x)) <$> do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to put a try around this one.
Otherwise it may fail after consuming some blanks, if there's no figcaption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, do you need the skipMany pBlank
? Won't this be handled by pSkip
?
right... thanks! |
fixes #4183