bookdown
bookdown copied to clipboard
Small adaptation for counting figures
The PR for knitr
at https://github.com/yihui/knitr/pull/1752, which fixed the figure referencing issue in https://github.com/rstudio/bookdown/issues/766 and is discussed in https://github.com/rstudio/bookdown-demo/issues/42, causes an unintended side effect of putting id
in front of class. As referenced in https://github.com/yihui/knitr/pull/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.
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 [email protected] wrote:
@yihui commented on this pull request.
In the PR yihui/knitr#1752 https://github.com/yihui/knitr/pull/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 https://github.com/rstudio/bookdown/pull/767#discussion_r321519942:
@@ -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 https://github.com/rstudio/bookdown/pull/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 id
and class
in the div, then this PR makes perfect sense.