Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

muschellij2
Copy link

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 putting id 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.

Copy link
Member

@yihui yihui left a 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)
Copy link
Member

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?

Suggested change
figs = grep('^<div .*class="figure', content)
figs = grep('^<div [^>]*?class="figure', content)

@muschellij2
Copy link
Author

muschellij2 commented Sep 5, 2019 via email

@yihui
Copy link
Member

yihui commented Sep 6, 2019

Okay. If Pandoc reorders id and class in the div, then this PR makes perfect sense.

@CLAassistant
Copy link

CLAassistant commented Apr 17, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants