Small adaptation for counting figures#767
Open
muschellij2 wants to merge 2 commits intorstudio:mainfrom
Open
Conversation
yihui
reviewed
Sep 5, 2019
Collaborator
yihui
left a comment
There was a problem hiding this comment.
In the PR yihui/knitr#1752, you wrote id after class, so I don't see why this PR is necessary if the knitr PR is merged. Could you help me understand it? Thanks!
| labs = regmatches(content, m) | ||
| cntr = new_counters(label_types, chaps) # chapter counters | ||
| figs = grep('^<div class="figure', content) | ||
| figs = grep('^<div .*class="figure', content) |
Collaborator
There was a problem hiding this comment.
Does it make sense to make the regex stricter?
Suggested change
| figs = grep('^<div .*class="figure', content) | |
| figs = grep('^<div [^>]*?class="figure', content) |
Author
|
Yes I believe it makes it stronger. I don’t really understand but it seems
like after I knit the Document it re-ordered the arguments. I’ll check back
when I’m in the office next week
On Thu, Sep 5, 2019 at 7:07 PM Yihui Xie ***@***.***> wrote:
***@***.**** commented on this pull request.
In the PR yihui/knitr#1752 <yihui/knitr#1752>,
you wrote id after class, so I don't see why this PR is necessary if the
*knitr* PR is merged. Could you help me understand it? Thanks!
------------------------------
In R/html.R
<#767 (comment)>:
> @@ -563,7 +563,7 @@ parse_fig_labels = function(content, global = FALSE) {
m = gregexpr(sprintf('\\(#((%s):[-/[:alnum:]]+)\\)', reg_label_types), content)
labs = regmatches(content, m)
cntr = new_counters(label_types, chaps) # chapter counters
- figs = grep('^<div class="figure', content)
+ figs = grep('^<div .*class="figure', content)
Does it make sense to make the regex stricter?
⬇️ Suggested change
- figs = grep('^<div .*class="figure', content)
+ figs = grep('^<div [^>]*?class="figure', content)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#767?email_source=notifications&email_token=AAIGPLQYFYF5D4GLB5UK5ETQIGGM3A5CNFSM4IRVAQM2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCD3HC2Y#pullrequestreview-284586347>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIGPLWXW2L6SITF7AXMH5TQIGGM3ANCNFSM4IRVAQMQ>
.
--
Best,
John
|
Collaborator
|
Okay. If Pandoc reorders |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The PR for
knitrat yihui/knitr#1752, which fixed the figure referencing issue in #766 and is discussed in rstudio/bookdown-demo#42, causes an unintended side effect of puttingidin front of class. As referenced in yihui/knitr#1752,https://github.com/rstudio/bookdown/blob/master/R/html.R#L566 needs to be edited so that it can go
<div id="asdf" class="figure, which this PR addresses.