Skip to content

Unexpected syntax highlighting in Rmd chunks #4821

Closed

Description

@atusy

System details

RStudio Edition : Server (rocker/verse:latest and devel)
RStudio Version : 1.2.1335
OS Version      : Manjaro Linux
R Version       : 3.5.3 (rocker/verse:latest)
                  3.7.0 (rocker/verse:devel)

Steps to reproduce the problem

  1. Create new Rmd file
  2. Create asis chunk (or css)
  3. Write some R code

Describe the problem in detail

Although asis and css chunks are intended to be text and CSS scripts, respectively,
they are highlighted as if they are R code.
If I create some original knitr engines, they will also be highlighted as if they are R code.

image

Describe the behavior you expected

Chunks with asis or original engines should not be highlighted
(asis can be highlighted as if markdown script)

Chunks with css engine should be highlighted by the syntax of CSS.

There may be some more chunks with unexpected syntax highlights.
I haven't checked all.

Activity

  1. added this to the v1.3 milestone on May 22, 2019
  2. removed this from the v1.3 milestone on Dec 2, 2019
  3. stale commented on Feb 6, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  4. added
    stale
    on Feb 6, 2021
  5. atusy commented on Feb 7, 2021

    @atusy
    Author

    I wish this issue be solved.

  6. stale commented on Feb 21, 2021

    @stale

    This issue has been automatically closed due to inactivity.

  7. joelnitta commented on Jul 14, 2021

    @joelnitta

    This is especially problematic with CSS where # is valid code (id selector) and not a comment. +1 for re-opening and resolving this issue. Thanks!
    css_example

  8. removed
    stale
    on Jul 14, 2021
  9. ronblum commented on Jul 22, 2021

    @ronblum
    Contributor

    Confirmed that CSS chunks appear to be using CSS highlighting, and ASIS chunks don't use any. Verified in:

    • RStudio Desktop 1.5.232 on MacOS 12 beta
    • RStudio Server 1.5.233 on Ubuntu 20.04.2 via Safari on MacOS 12 beta

    Note: Used the following code, transcribed from the screenshots above.

    ```{asis}
    aaa
    #bbb
    library(ggplot)
    ```
    
    ```{css}
    h1.test {
    	font-size: 10px;
    }
    library(ggplot)
    ```
    
    ```{css, style, echo = FALSE}
    #title code {
      color: inherit;
      font-size: inherit;
      background-color: transparent;
    }
    ```
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions