-
-
Notifications
You must be signed in to change notification settings - Fork 974
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
Vignette classes for syntax highlighting are mixed up #2399
Comments
I tested the latest version of RStudio, which bundles Pandoc 2.18, and it worked as you expected.
So if you use RStudio, you may update RStudio, otherwise update Pandoc. |
That worked indeed, it was Pandoc's version that mixed things up. |
You are correct. I don't know why Pandoc defines CSS rules differently for |
Indeed, I just hoped this can be solved somehow by rmarkdown, since the final result is an html file irrespective of Pandoc (perhaps post-processing the html file to re-write those classes, at least this is what I would do). |
Just a precision as I explained in #2360 (comment) regarding the styling, I think the rules in the CSS here rmarkdown/inst/rmarkdown/templates/html_vignette/resources/vignette.css Lines 190 to 201 in 45c6802
are no more used, or at least should not be used or just should be updated.
I am not sure in which context the rules of Regarding the parsing of the R Code for HTML highlight, this is done by Pandoc also. Pandoc version update can also update the parser. This is why updating the version of Pandoc may have fix the class issue if it was fixed upstream. If there are still some incorrect highlighting, this is something to report upstream in KDE which is where the highlighting parser comes from.
@dusadrian which part is irrespective of Pandoc ? The CSS rules right ? or another part. thanks |
I tend to agree. I didn't realize we had a stylesheet |
Oh, that explains a lot... @cderv, yes indeed, I was referring to the CSS rules. If nothing else worked, there is at least the option of post-processing the resulting html file(s) to modify, delete, or add rules to obtain the desired result. But I would avoid this, if at all possible. For the moment, I managed to solve this by employing a custom.css style, as suggested by @yihui and advised in the manuals. I simply copied PS: this is a link to the place where I used this in practice, if it helps: |
@dusadrian the official mechanism to use a custom style for highlighting is to provide a custom them in The default one used in Pandoc for our vignette format can be obtained using
See https://pandoc.org/MANUAL.html#option--highlight-style This allows to tweak the default one, if no other option suits you. Benefit of doing that is to have a theme that works with PDF and DOCX too, and any other format supported by Panodc highlighting. The simple method of overwritting Pandoc's included CSS rules for the HTML is the other method. You are doing that and that is perfectly fine if you are using HTML output only for this style ! Hope this clarifies. We'll probably remove the rules in the vignette.css file - I just need to check if some of them are used somehow - from your report I am wondering. If we just remove we could end up with users asking why it has changed 😅 |
Indeed, and I have previously, already tried the Pandoc theme way (banging my head to no avail). Copying your I am now struggling to understand where and how does Pandoc use that class for title: "Motivation for the declared package"
output:
rmarkdown::html_vignette:
highlight: "declared.theme" |
Oh now I think I missed something in your explanation. I just saw that use add a class to the inline code, right ?
Are you doing the same thing in the example above with I am just discovering that applying a class using this syntax will trigger the syntax highlighting even in the inline code with Pandoc. I forgot about that. Usually, no class is applied and inline code are not highlighted specifically. Thanks for reminded me. Anyway,
Not sure to understand here what you mean. Which class are you talking about ? In your example, as discussed in previous message, you see a red color and not the same color as in code chunk even with applying the One way of getting rid of it now is post processing the HTML, or passing a custom At the end, I am not quite sure of the result you are looking for - you can send me your declared.css and declared.theme so that I can reproduce too and see the content. Sorry everything got mix up for me and I am not sure to see if there is another issue you are trying to mention apart for the CSS in As a reminder:
|
Indeed, I am using the You are absolutely right, that red bold color is the result of the Thanks for all the explanation, everything is alright now. I am going to continue using the |
The Vignette syntax highlighting does not seem to follow the general structure of the html classes.
Something like
aa <- c(1, 2)
is rendered in the html version asI believe the function
c()
should in fact have a class "fu" (not keyword "kw"). Similarly, something likerunif(n = 3)
is rendered as:where the argument
n
should have a different class from DataType ("dt"), perhaps "at" if I am not mistaken. Is there a special reason why these classes are mixed up?Below is the output from:
Checklist
When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:
formatted your issue so it is easier for us to read?
included a minimal, self-contained, and reproducible example?
pasted the output from
xfun::session_info('rmarkdown')
in your issue?upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
installed and tested your bug with the development version of the rmarkdown package using
remotes::install_github("rstudio/rmarkdown")
?The text was updated successfully, but these errors were encountered: