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

Generalize number sections #1879

Merged
merged 19 commits into from
Sep 9, 2020
Merged

Generalize number sections #1879

merged 19 commits into from
Sep 9, 2020

Conversation

atusy
Copy link
Collaborator

@atusy atusy commented Aug 25, 2020

This PR adds the number_sections argument to formats without it by using a lua filter:

github_document, ioslides_presentation, md_document, odt_document, powerpoint_presentation, rtf_document, slidy_presentation, word_document (pandoc < 2.10.1)

I am also looking forward to generalize bookdown's cross-reference feature.
Currently, bookdown::markdown_document2 and its family globally increments numbers on figures and tables.
With this PR and further implementations, these formats may support section-level increments.

@atusy atusy marked this pull request as ready for review August 26, 2020 14:26
@atusy
Copy link
Collaborator Author

atusy commented Aug 26, 2020

I think I'm ready for the review.
However, Travis CI fails due to 403 from https://travis-ci.rstudio.org .

The command "eval curl -fLo /tmp/R-3.3.3-$(lsb_release -cs).xz https://travis-ci.rstudio.org/R-3.3.3-$(lsb_release -cs).xz " failed. Retrying, 2 of 3.

curl: (22) The requested URL returned error: 403

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.

This is fantastic! Thank you!

@cderv It'll be great if you could also review this PR. Feel free to merge it if it looks good to you.

@yihui yihui requested a review from cderv September 7, 2020 03:40
Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this ! I think we can both agree that we can do a lot of awesome things with Lua filter !

You'll found some feedback and questions.

I think this could be a good addition to be documented in lua filter vignette. What do you think about adding a chapter on this new filter ?

Also, we may need to take the habit add some tests when introducing such features. It would help know when something break. All the more as we depend on pandoc, and testing with more pandoc version is something I would like to introduce.

Adding tests now can save us time later. For now, you could see what I have done in test-lua-filters.R.

We may need to think on how to do those better, and I am planning to make improvment on Rmarkdown using soon-to-come snapshot test from testthat 3, but I need to think how to organize those and it is not released yet.

Anyway, I could work on that if you prefer but I am sure you could help me produce some example content to render.

Thank you !

R/word_document.R Outdated Show resolved Hide resolved
R/slidy_presentation.R Show resolved Hide resolved
inst/rmd/lua/number-sections.lua Outdated Show resolved Hide resolved
inst/rmd/lua/number-sections.lua Outdated Show resolved Hide resolved
inst/rmd/lua/number-sections.lua Outdated Show resolved Hide resolved
@atusy
Copy link
Collaborator Author

atusy commented Sep 8, 2020

@cderv Thank you for the neat review. I agree with adding tests and will work on it.

@atusy
Copy link
Collaborator Author

atusy commented Sep 8, 2020

Added tests via 55dd2f4 (#1879)

@atusy
Copy link
Collaborator Author

atusy commented Sep 8, 2020

Travis CI fails for R 3.3, which seems to be a cache issue.

https://travis-ci.org/github/rstudio/rmarkdown/jobs/725221940#L1101

@cderv
Copy link
Collaborator

cderv commented Sep 8, 2020

It is 📦 systemfonts that does not install correctly on R 3.3. I'll look into that later.

@cderv
Copy link
Collaborator

cderv commented Sep 8, 2020

I think this could be a good addition to be documented in lua filter vignette. What do you think about adding a chapter on this new filter ?

I think that is the last thing to do. It seems interesting to have one place where we can explain (even shortly) what filter are in used.

Would you mind adding something to the vignette ? even something short ?
I see the other filter custom latex divs is missing - I'll add that later.

@atusy
Copy link
Collaborator Author

atusy commented Sep 8, 2020

Oops, I was missing it! Thanks. Will do.

@atusy
Copy link
Collaborator Author

atusy commented Sep 8, 2020

@cderv Done via 06cf99a (#1879)

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.

@cderv I'm fine with ignoring the systemfonts issue in this PR, but we need to let Thomas know and ask him to fix it if possible. It seems he didn't test against R 3.3 (like us before).

@atusy This is really great work. Thanks again!

inst/rmd/lua/number-sections.lua Show resolved Hide resolved
@atusy
Copy link
Collaborator Author

atusy commented Sep 8, 2020

@yihui @cderv Thank you too for your praises and reviews!!

@cderv
Copy link
Collaborator

cderv commented Sep 9, 2020

I'm fine with ignoring the systemfonts issue in this PR, but we need to let Thomas know and ask him to fix it if possible. It seems he didn't test against R 3.3 (like us before).

I have seen with Thomas - he fixed that into systemfont. However, we don't depend directly on systemfont. I believe this is through pkgdown. So the test for 3.3 will fail until we systemfont gets to CRAN. What is strange is that pkgdown did not have issues (https://github.com/r-lib/pkgdown/runs/1081873896?check_suite_focus=true).

Anyway, this is another topic and we could ignore for this PR.

@cderv cderv merged commit 284b685 into rstudio:master Sep 9, 2020
@cderv
Copy link
Collaborator

cderv commented Sep 9, 2020

Thanks a lot for this @atusy !

And it is good to know there are others around here that can help maintain lua filters! ☺️

jonathan-g added a commit to jonathan-g/rmarkdown that referenced this pull request Sep 24, 2020
* rstudio_origin/master:
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this pull request Sep 24, 2020
Merge remote-tracking branch 'rstudio_origin/master' into css-slash-fix

# By Yihui Xie (12) and others
# Via GitHub
* rstudio_origin/master: (22 commits)
  fix rstudio#1905: a chunk with the class "fold-hide" should only hide itself (rstudio#1906)
  bump version after merging rstudio#1899
  lua filter -> Lua filter
  Add an argument `lua_filters` to pandoc_options() to store them in the output format object (rstudio#1899)
  recursve into the parent dir at the end
  also suppor dir input in proj_root()
  list.files() with full.names = TRUE (so the files could be read with corret paths), and pass down the `file`/`pattern` arguments in the recursion
  use our own proj_root() instead of introducing a dependency
  rename package_root() to proj_root()
  generalize the package_root() function to work with more types of projects
  Discover site generators in index.Rmd files in parent directories (rstudio#1898)
  only install pkgdown for website build (rstudio#1900)
  Generalize number sections (rstudio#1879)
  enable figure cropping in pdf_document() only when both pdfcrop and ghostscript are found (yihui/knitr#954), and do not limit this feature to non-Windows platforms
  add the citation entry for the R Markdown Cookbook
  add lua filter vignette to pkgdown website (rstudio#1894)
  close rstudio#1889: evaluate the output argument before changing working directory in pandoc_convert() (rstudio#1890)
  tweak news
  require Pandoc >= 1.14
  xfun 0.16 is on CRAN now
  ...

# Conflicts:
#	NEWS.md
@cderv
Copy link
Collaborator

cderv commented Sep 30, 2020

I'm fine with ignoring the systemfonts issue in this PR, but we need to let Thomas know and ask him to fix it if possible. It seems he didn't test against R 3.3 (like us before).

I have seen with Thomas - he fixed that into systemfont. However, we don't depend directly on systemfont. I believe this is through pkgdown. So the test for 3.3 will fail until we systemfont gets to CRAN. What is strange is that pkgdown did not have issues (https://github.com/r-lib/pkgdown/runs/1081873896?check_suite_focus=true).

Anyway, this is another topic and we could ignore for this PR.

FYI systemfont with the fix has been released https://github.com/r-lib/systemfonts/releases/tag/v0.3.2

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants