Skip to content

Small adaptation for counting figures#767

Open
muschellij2 wants to merge 2 commits intorstudio:mainfrom
muschellij2:master
Open

Small adaptation for counting figures#767
muschellij2 wants to merge 2 commits intorstudio: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.

Copy link
Copy Markdown
Collaborator

@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!

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
Copy link
Copy Markdown
Author

muschellij2 commented Sep 5, 2019 via email

@yihui
Copy link
Copy Markdown
Collaborator

yihui commented Sep 6, 2019

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

@CLAassistant
Copy link
Copy Markdown

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