-
-
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
Correct location of alt-text content #9134
Merged
+121
−30
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
743dd93
Fetch from child element alt-text
kamoe 39c5ab5
refine alt-text
kamoe 138a266
Simplify scope to only fetch alt-text, update tests
kamoe e580cc3
Update tests
kamoe b876f35
Update unit test
kamoe d2d883a
Update unit tests
kamoe 042406d
Fix typo
kamoe 412ca53
update reader samples
kamoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,18 +138,16 @@ trimNl = T.dropAround (== '\n') | |
|
||
-- function that is used by both graphic (in parseBlock) | ||
-- and inline-graphic (in parseInline) | ||
getGraphic :: PandocMonad m | ||
=> Maybe (Inlines, Text) -> Element -> JATS m Inlines | ||
getGraphic mbfigdata e = do | ||
getGraphic :: PandocMonad m => Element -> JATS m Inlines | ||
getGraphic e = do | ||
let atVal a = attrValue a e | ||
(ident, title, capt) = | ||
case mbfigdata of | ||
Just (capt', i) -> (i, "fig:" <> atVal "title", capt') | ||
Nothing -> (atVal "id", atVal "title", | ||
text (atVal "alt-text")) | ||
let altText = case filterElement (named "alt-text") e of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is where we fetch content from a child, rather than an argument |
||
Just alt -> textContent alt | ||
Nothing -> mempty | ||
(ident, title, altText') = (atVal "id", atVal "title", text altText) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. third argument is actually capturing alt-text, not caption, renamed as such |
||
attr = (ident, T.words $ atVal "role", []) | ||
imageUrl = atVal "href" | ||
return $ imageWith attr imageUrl title capt | ||
return $ imageWith attr imageUrl title altText' | ||
|
||
getBlocks :: PandocMonad m => Element -> JATS m Blocks | ||
getBlocks e = mconcat <$> | ||
|
@@ -198,7 +196,7 @@ parseBlock (Elem e) = do | |
"table-wrap-foot" -> parseBlockWithHeader | ||
"trans-abstract" -> parseBlockWithHeader | ||
"verse-group" -> parseBlockWithHeader | ||
"graphic" -> para <$> getGraphic Nothing e | ||
"graphic" -> para <$> getGraphic e | ||
"journal-meta" -> parseMetadata e | ||
"article-meta" -> parseMetadata e | ||
"custom-meta" -> parseMetadata e | ||
|
@@ -622,7 +620,7 @@ parseInline (Elem e) = | |
"code" -> codeWithLang | ||
"monospace" -> codeWithLang | ||
|
||
"inline-graphic" -> getGraphic Nothing e | ||
"inline-graphic" -> getGraphic e | ||
"disp-quote" -> do | ||
qt <- gets jatsQuoteType | ||
let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Noticed this function was only ever called with
Nothing
as first argument, which means it does not need it. Got rid of this argument and all corresponding logic.