Skip to content

Assign default classes for code blocks of source, output, and so on with html_document #2025

@atusy

Description

@atusy

I'm currently working on this issue at https://github.com/atusy/rmarkdown/tree/default-class .

transferred from yihui/knitr#1730 .

What about code blocks generated by chunks have one of the following classes chunk-source, chunk-output, chunk-message, chunk-warning, or chunk-error by default?

This enables easier and precise selections in CSS and JavaScript, which is friendly both for developers and users.

I already implemented it, but am having difficulty in passing tests (atusy/knitr@54db8c4).
So I want to ask if @yihui like my idea and if it is worth working on to pass tests.

Example applications

Cumbersome CSS selections in a PR #1596 can be simplified (https://github.com/atusy/rmarkdown/blob/eb389d721b9f6cddd092234057c98150f70f898f/inst/rmd/h/default.html#L27-L42)

Selection of code blocks to fold by code_folding can be generalized.
Currently, folding is performed on code blocks with certain language classes, which may cause unexpected behavior (#1603).
If folding is performed on code blocks with chunk-source, the unexpected behavior can be suppressed.
In addition, we don't have to update codefolding.js everytime we find additional language to be folded.

There's a request on folding results #1453.
I am currently working on this issue, and seems to be easy.
However, a problem is that choice of folding button, which is currently code and hide.
For folding results, the choice is better to be output and hide.
I want to generate choices conditionally by detecting the code blocks have chunk-source class or chunk-output class.


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 enhancementnextto consider for next release

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions