Skip to content

Enhancement: support for non-standard RMarkdown directory structures.Β #1859

@jonathan-g

Description

@jonathan-g

I have the same issue as was raised in #146 (and I originally posted this issue as a comment there).

I organize my reveal.js slides for a semester in a directory structure:

semester:
    lecture_lib (common material: css, js, etc.)
        assets (custom css themes, custom js, images, etc. that are shared across the whole project)
        revealjs
        font-awesome
    slides
        class_01
            assets (per-class assets)
                images (images to include)
                videos (video files)
                fig (figures generated by RMarkdown)
        class_02
            assets (per-class assets)
                images (images to include)
                videos (video files)
                fig (figures generated by RMarkdown)
        c;lass_03
            assets (per-class assets)
                images (images to include)
                videos (video files)
                fig (figures generated by RMarkdown)
        ...

This lets me keep a consistent structure for each lecture.

If I use pandoc 2.7.x, RMarkdown works fine with my directory structures, but if I use any later version of Pandoc rendering the .Rmd file fails with an error message about relativeTo() because lib_dir is not a descendant of output_dir.

This is not a bug per-se since by design, RMarkdown does not support this kind of directory structure. But it is something that a number of people have expressed interest in (#146, #472, https://github.com/jayhesselberth/widgetdown/issues/4, workflowr/workflowr#95).

My non-standard (and unsupported) directory structure worked for many years, using a custom reveal.js HTML template for Pandoc to handle a more flexible directory structure but it broke several months ago when Pandoc moved to version 2.9 and rmarkdown introduced html_dependency_header_attrs to fix the duplication of HTML class attributes from <section> to <h[1-9]> tags that Pandoc introduced with version 2.8 or 2.9. I was able to work around this by continuing to work with an older Pandoc version (2.7).

I raise this in part because I think I could address this with a relatively minor PR (I have this working on a fork of rmarkdown at https://github.com/jonathan-g/rmarkdown/tree/minimal-tree-fix, and it changes about 14 lines of code, all of which are in the html_dependencies_as_string() function). I need to test this patch more before submitting it as a PR, but it should allow this non-standard directory structure through the YAML lib_dir parameter without disturbing any use cases except where lib_dir begins with ...


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementtheme: pathspath related improvment / issue

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions