-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Small adaptation for counting figures #767
base: main
Are you sure you want to change the base?
Conversation
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.
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!
@@ -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) |
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.
Does it make sense to make the regex stricter?
figs = grep('^<div .*class="figure', content) | |
figs = grep('^<div [^>]*?class="figure', content) |
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
|
Okay. If Pandoc reorders |
The PR for
knitr
at 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 puttingid
in 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.