-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
Relative CSS in parent folder are now added with an absolute path #331
Comments
Here is the directory structure: > fs::dir_tree()
.
+-- 01_about
| +-- libs
| | +-- header-attrs
| | | \-- header-attrs.js
| | \-- remark-css
| | +-- default-fonts.css
| | \-- default.css
| +-- presentation.html
| \-- presentation.Rmd
+-- example.Rproj
+-- Makefile
\-- style.css @yihui, do we support in I think it was working before because we did not mess much with the provided css path. However, now that we have added support for SASS in if (!xfun::is_web_path(f)) f <- normalized_relative_to(output_dir, f)
args <- c(args, "--css", pandoc_path_arg(f, backslash = FALSE))
} I think In the example above, this is what is called: # output_dir is ".", the root folder of the Rmd file
# f is the css file path provided
normalized_relative_to(".", "../styles.css")
# > [1] "C:/Users/chris/Documents/DEV_OTHER/ISSUES/xaringan-29/example/styles.css" Filepath handling become quite complicated at some point. I am always referencing to fs package and it seems it gets the correct result in this case # ran in debug mode in place of 'normalized_relative_to'
> fs::path_rel(f, output_dir)
../style.css It seems it handles relative path using also parent folder with We can classify this as a regression. It was introduced in the first place for sass support because An easy fix would be to move the line 109 inside the # Process css files as Pandoc argument if not already been processed by bslib
for (f in css) {
if (grepl("\\.s[ac]ss$", f)) {
if (!xfun::loadable("sass")) {
stop2("Using `.sass` or `.scss` file in `css` argument requires tass package.")
}
f <- sass::sass(
sass::sass_file(f),
# write output file to `lib_dir/sass-{sass:::sass_hash()}{[basena)}`
output = sass_output_template(
basename = xfun::sans_ext(basename(f)),
tmpdir = lib_dir
),
options = sass::sass_options(output_style = "compressed")
)
+ f <- normalized_relative_to(output_dir, f)
}
- # do not normalize web path
- if (!xfun::is_web_path(f)) f <- normalized_relative_to(output_dir, f)
args <- c(args, "--css", pandoc_path_arg(f, backslash = FALSE))
} It seems like the way to restore previous behavior. But, I am still unsure how well we support resources in parent folder than the Rmd or HTML file. I know that there is a However, it seems quite common for presentations to store them all in a unique folder with shared resources, so it seems important to support this correctly. |
Thanks @cderv for the quick response! It would be great to support relative path here. Currently, I just manually replaced the absolute path to relative path once the html file was generated. |
@cderv We should support relative paths that point to parent folders.
That said, the fix you proposed seems to be simple enough and can restore the previous behavior (which is desirable), so I'll apply this fix. Thanks! |
Please try the development version of rmarkdown via remotes::install_github('rstudio/rmarkdown') |
It works well so far, thanks for the help!! |
I already hesitated once in the past to change it, but felt the same: not sure how risky it was because they are slightly different.
Thanks for the committing fix while I was gone!
Thanks a lot for confirming that this fixes it ! |
…n 2.11 Christophe Dervieux (2): Mark result of citeproc conversion as UTF-8 (#2202) Bump version Garrick Aden-Buie (1): Prerender shiny rmd in separate environment (#2203) Yihui Xie (9): start the next version close #1814: upgrade jquery by using the R package jquerylib, which currently ships jquery 3.x by default (#2197) pin the jquery version to 3: rstudio/rmarkdown#2197 (comment) fix yihui/xaringan#331: respect relative paths in parent directories in the `css` argument of `html_document()` use sass::output_template() instead of storing a copy in rmarkdown export convert_ipynb() per suggestion of @acircleda roxygenize and bump version https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html -> https://pandoc.org/MANUAL.html#citations CRAN release v2.11 christophe dervieux (1): Add a specific dirname for sass caching
Merge remote-tracking branch 'rstudio_origin/main' into jg-tree-fix # By Yihui Xie (7) and others # Via Yihui Xie * rstudio_origin/main: import bslib (rstudio#2154) CRAN release v2.11 https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html -> https://pandoc.org/MANUAL.html#citations Add a specific dirname for sass caching roxygenize and bump version export convert_ipynb() per suggestion of @acircleda use sass::output_template() instead of storing a copy in rmarkdown fix yihui/xaringan#331: respect relative paths in parent directories in the `css` argument of `html_document()` Bump version Prerender shiny rmd in separate environment (rstudio#2203) Mark result of citeproc conversion as UTF-8 (rstudio#2202) # Conflicts: # NEWS.md
Merge branch 'jg-tree-fix' into jg-devel # By Yihui Xie (9) and others # Via Jonathan Gilligan (3) and Yihui Xie (1) * jg-tree-fix: import bslib (rstudio#2154) CRAN release v2.11 https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html -> https://pandoc.org/MANUAL.html#citations Add a specific dirname for sass caching roxygenize and bump version export convert_ipynb() per suggestion of @acircleda use sass::output_template() instead of storing a copy in rmarkdown fix yihui/xaringan#331: respect relative paths in parent directories in the `css` argument of `html_document()` Bump version Prerender shiny rmd in separate environment (rstudio#2203) Mark result of citeproc conversion as UTF-8 (rstudio#2202) Fixed conflicts with rstudio main version. Update documentation for html_document. Add self (JG) as a contributor in DESCRIPTION. Resolve conflicts with new updates to RStudio main branch. pin the jquery version to 3: rstudio#2197 (comment) # Conflicts: # DESCRIPTION # NEWS.md
* rstudio_origin/main: Add support for devtools loaded package in `draft()` (rstudio#2224) Fix typo in comment import bslib (rstudio#2154) CRAN release v2.11 https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html -> https://pandoc.org/MANUAL.html#citations Add a specific dirname for sass caching roxygenize and bump version export convert_ipynb() per suggestion of @acircleda use sass::output_template() instead of storing a copy in rmarkdown fix yihui/xaringan#331: respect relative paths in parent directories in the `css` argument of `html_document()` Bump version Prerender shiny rmd in separate environment (rstudio#2203) Mark result of citeproc conversion as UTF-8 (rstudio#2202)
rmarkdown 2.19 ================================================================================ - No longer use `xfun::isFALSE()` internally. rmarkdown 2.18 ================================================================================ - `rmarkdown::render()` argument `output_file` is now used for all output formats, if there is only one name for multiple output formats (thanks, @MaelAstruc, #2421). - Custom output formats can provide a custom function to convert Markdown input to the desired output format now. To do so, define the output format via `output_format(pandoc = pandoc_options(convert_fun = function(...) {}))`. The default converting function is `pandoc_convert()` in this package. See the help page `?pandoc_options` for more details. rmarkdown 2.17 ================================================================================ - `rmarkdown::render_site()` will now also look for `index.rmd` in addition to `index.Rmd` for custom site generator in YAML with `site:` (thanks, @kamalsacranie, #2409). - Icons in tabset dropdown are now correctly shown, including when `self_contained: false` (thanks, @cpsievert, #1697). rmarkdown 2.16 ================================================================================ - Pandoc 2.19 has deprecated the argument `--self-contained`. If you have installed Pandoc 2.19+, **rmarkdown** will use `--embed-resources --standalone` as recommended by Pandoc for output formats that use the option `self_contained = TRUE` (#2382). - `pandoc_version()` returns a version number of the form `X.Y.Z.YYYY.MM.DD` for the nightly build of Pandoc now, where `YYYY.MM.DD` is its build date. Previously it would return `X.Y.Z.9999` to indicate the nightly version. rmarkdown 2.15 ================================================================================ - Fix navbar issue with website when using Boostrap 5 with **bslib** (thanks, @guasi, #2379, @cpsievert, #2384). - The `tufte_handout()` function inside **rmarkdown** is defunct now. Its codebase was moved to the **tufte** package in 2016, and this function was marked as deprecated in 2021. Please use `tufte::tufte_handout()` instead of `rmarkdown::tufte_handout()`. The latter will be removed eventually from this package. - `github_document()` gains `math_method = "default"` and defaults to it. No special processing will be done to inline maths in `$` and block maths in `$$` as now [Github supports it](https://github.blog/changelog/2022-05-19-render-mathematical-expressions-in-markdown/) and will render using Mathjax (thanks, @kylebutts, #2361). rmarkdown 2.14 ================================================================================ - Improved highlighting theme `arrow` regarding accessibility. - Fixed an issue with `site_generator()` detection of a site project (thanks, @bhattmaulik, #2344). - Fixed an issue with Shiny prerendered documents and Pandoc not correctly rendering last Markdown paragraph in HTML (thanks, @gadenbuie, #2336). - Fixed a bug that `site_generator()` fails to detect the root dir of the site and causes infinite recursion (thanks, @fisher-j, #2339). - `html_vignette()` gains `code_folding` argument (thanks, @atusy, #2340). - `html_document()` can opt-out `code_folding = "show"` or `"hide"` for individual code blocks by adding the `fold-none` class to the code blocks (thanks, @atusy, #2348). - When using a development version of Pandoc, a `.9999` suffix is appended to version number so that `pandoc_available()` can correctly compared version with last release. rmarkdown 2.13 ================================================================================ - Fix an issue with older R version and vignette building (#2324). - Fix an issue with older R version and `preserve_yaml = TRUE` in `md_document()` (#2325). - Long title in `ioslides_presentation` failed to work with Pandoc 2.17.x (thanks, @Am386DX-40, #2327). rmarkdown 2.12 ================================================================================ - `html_document()` and `html_document_base()` gains the `math_method` argument to support [all the math rendering engines from Pandoc] (https://pandoc.org/MANUAL.html #math rendering-in-html): "mathjax", "katex", "mathml", "webtex", and "gladtex". For backward compatibility, the `mathjax` argument still works and will take precedence over `math_method`, but we recommend using the new `math_method` argument instead of the `mathjax` argument, and the latter could be deprecated in the future. You can specify a math engine via `math_method` as an engine name, e.g., ```yaml output: html_document: math_method: katex ``` or provide both a name and a URL (for `mathjax`, `katex` and `webtex`): ```yaml output: html_document: math_method: engine: mathjax url: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js ``` For `math_method = "katex"`, KaTeX CDN will be inserted in version 0.15.2 by default (from jsdelivr). A custom URL toward another CDN can be passed as `url`. For `math_method = "webtex"`, it will default to inset SVG using `https://latex.codecogs.com/svg.image?`. Use `https://latex.codecogs.com/png.image?` for PNG. See https://latex.codecogs.com for supported options (dpi, background, ...). Most HTML output format using `html_document()` or `html_document_base()` as based format should benefit from this new feature. See `?rmarkdown::html_document()` for details (thanks, @atusy, #1940). - `github_document()` also gains the `math_method` argument set to `"webtex"` by default so that LaTeX equations can be rendered in the Github Markdown document as images. Previously, LaTeX equations were not rendered. Set `math_method = NULL` to deactivate. - Added support for [**katex**](https://docs.ropensci.org/katex/) R package as a math engine with `math_method = "r-katex"` in HTML documents. This method offers server-side rendering of all the equations, which means no JS processing is needed in the browser as with usual KaTeX or MathJaX methods. (thanks, @jeroen, #2304). - `anchor_sections` can now be easily customized using `style` or `depth` element for `anchor_sections`. For example: ```yaml output: html_document: anchor_sections: style: symbol # use symbol style ("hash", "symbol", "icon") depth: 2 # max depth to apply anchor on (default to max which is 6) ``` Customizing using a CSS rule is still possible. Detailed explanation and examples have been added to the help page `?html_document`. - Improved the highlighting mechanism in formats that supports `highlight` argument: * It is now possible to pass a custom theme file `.theme` in `highlight` argument for customizing the [syntax highlighting style used by Pandoc](https://pandoc.org/MANUAL.html#syntax-highlighting). * In addition to Pandoc's own supported themes, two more themes are bundled in the package: `highlight: arrow` a theme [optimized for accessibility and color contrast](https://www.a11yproject.com/) (thanks to @apreshill), and `highlight: rstudio` to mimic the RStudio editor theme. * For HTML output only, added optional [downlit](https://downlit.r-lib.org/) support in `html_document()` for R syntax highlighting and autolinking. Use `highlight_downlit = TRUE` to activate it (same argument as in **distill**). This features require the **downlit** package. - Templates for `html_document()` and `ioslides_presentation()` gained a new CSS rule to display single line `<summary>` content inline (rstudio/rstudio#10589). - `md_document()` gained a new `standalone` argument, which is `FALSE` by default unless `toc = TRUE`. This allows to output authors, date and other metadata per the Pandoc's template. Due to limitation in how Pandoc is handling metadata blocks in its extensions `yaml_metadata_block`, `preserve_yaml = TRUE` now deactivate any extension to let **rmarkdown** directly handle the keeping of YAML block - this means it does not set `standalone = TRUE` by default. Meanwhile, `github_document()` gained the `preserve_yaml` argument (thanks, @florisvdh, #2297). - Added `available_templates()` to list all the templates from a specific package that can be used with `rmarkdown::draft()`. - Following support in Pandoc 2.15, `powerpoint_presentation()` gained a `incremental` argument as other slide formats. As a reminder, setting `incremental = TRUE` will make lists to display incrementally. See more in [Pandoc's MANUAL](https://pandoc.org/MANUAL.html#incremental-lists). - Added support for Pandoc's `dir` variable in HTML templates. This is the second [Language Variables](https://pandoc.org/MANUAL.html#language-variables) after `lang`. - Added a global option `rmarkdown.html_dependency.header_attr` (`TRUE` by default). It can be set to `FALSE` to opt-out the HTML dependency `html_dependency_header_attrs()` in documents based on `html_document_base()` (thanks, @salim-b rstudio/bookdown#865, @maelle r-lib/downlit#1538). - Rendering using `runtime: shiny_prerendered` or `runtime: shinyrmd` now natively supports custom templates. Previously since 2.8, developers had to add a special comment, `<!-- HEAD_CONTENT -->`, conditionally to `shiny-prerendered` variable. (See also NEWS from 2.8 for the previous behavior). The new behavior inserts required special comment `<!-- HEAD_CONTENT -->` as a last element of `$header-includes$`. If templates rely on the old behavior and require some contents between `$header-includes$` and `<!-- HEAD_CONTENT -->`, consider including them with `$header-includes$` (thanks, @atusy, @gadenbuie #2249). - A shiny prerendered document with only a empty server context does not error anymore. Document will be rendered with a empty server function and `server.R` file will be ignored. To use `server.R`, no server context should be present in the Rmd document (thanks, @jcheng5, #2305). - Fixed a regression with rendering `shiny_prerendered` document (thanks, @aronatkins, @gadenbuie, #2218). - Fixed an issue in `beamer_presentation()` where `header-includes` would be overwritten by `includes = list(in_header =)` (thanks, @samcarter, #2294). Same fix as for `pdf_document()` (#1359). - Fixed broken links to section headers when `number_sections = TRUE` is specified in `md_document` and `github_document` (thanks, @atusy, #2093). - `draft()` now works with `devtools::load_all()` and **testthat** when used in other packages. - Lua Filters: Added two more functions in `shared.lua` for other package to use: * Added `type()` function backward compatible following Pandoc 2.17 changes. * Added `print_debug()` for easier logging during debug. - Add opt-in `tabset` option to the `html_vignette`. In contrast to the similar feature from `html_document`, this feature supports navigation from ToC and URL. Any custom formats can introduce this feature by using an exported function `html_dependency_tabset()` (thanks, @atusy, #2313). rmarkdown 2.11 ================================================================================ - Relative paths in parent directories in the `css` argument of `html_document()` were incorrectly normalized to absolute paths by #2095 in v2.8. Now relative paths in parent directories will no longer be converted to absolute paths (thanks, @daijiang, yihui/xaringan#331). - It is possible to specify the version of jQuery via a global option now, e.g., `options(rmarkdown.jquery.version = 2)` (note that the default major version is `3`). This is mainly for advanced users and developers to test different versions of jQuery. - `pandoc_citeproc_convert()` now handles correctly bib file containing specific UTF-8 characters on non default UTF-8 systems like Windows (thanks, @mitchelloharawild, #2195). - Shiny prerendered documents are now pre-rendered in a child environment to avoid allowing the results of static code chunks to exist in the Shiny app environment (@gadenbuie, #2203). - The previously unexported function `convert_ipynb()` is exported now (thanks, @acircleda).
Here is an example. Note that no matter which way to generate the html (make at the root or use the knit button of RStudio), the line 10 of
01_about/presentation.html
has the absolute path there. Thanks @yihuiexample.zip
Originally posted by @daijiang in #29 (comment)
The text was updated successfully, but these errors were encountered: