Skip to content

Small adaptation for counting figures#767

Open
muschellij2 wants to merge 2 commits into
rstudio:mainfrom
muschellij2:master
Open

Small adaptation for counting figures#767
muschellij2 wants to merge 2 commits into
rstudio:mainfrom
muschellij2:master

Conversation

@muschellij2

Copy link
Copy Markdown

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.

@yihui yihui left a comment

Copy link
Copy Markdown
Collaborator

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!

Comment thread R/html.R
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
Copy Markdown
Collaborator

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

muschellij2 commented Sep 5, 2019 via email

Copy link
Copy Markdown
Author

@yihui

yihui commented Sep 6, 2019

Copy link
Copy Markdown
Collaborator

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

@CLAassistant

CLAassistant commented Apr 17, 2024

Copy link
Copy Markdown

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