etiennebacher / altdoc

Alternative to pkgdown to document R packages
https://altdoc.etiennebacher.com
Other
65 stars 9 forks source link

Replace `<code>` tags by backticks in temporary .qmd files #290

Open etiennebacher opened 4 weeks ago

etiennebacher commented 4 weeks ago

This could help fix formatting of quotation marks in code, e.g. pola-rs/r-polars/issues/655

Cf https://github.com/quarto-dev/quarto-cli/issues/10511

etiennebacher commented 4 weeks ago

In .rd2qmd(), we may also want to keep the HTML as-is (for example not replacing heading tags by markdown syntax) and then wrap the whole thing in {=html} so that Quarto parses this as raw HTML.

vincentarelbundock commented 4 weeks ago

Would this work for multiline code blocks or just inline?

etiennebacher commented 4 weeks ago

I think the issue is just for inline code. For code blocks, the quotation marks are normal: https://pola-rs.github.io/r-polars/vignettes/polars.html#series-and-dataframes

vincentarelbundock commented 4 weeks ago

Right. I just wanted to be sure that on the intermediate representation, we never had <code> tags around blocks code. Replacing those by single ticks might break things.

Perhaps that never happens and isn't a concern.

etiennebacher commented 4 weeks ago

Replacing those by single ticks might break things.

Hopefully the snapshot tests would catch that. If they don't, something is wrong with them

etiennebacher commented 4 weeks ago

Wrapping everything in {=html} (except for examples that would be in {r}) works almost perfectly. The problem is equations since they are wrapped in <code class="reqn">. When this is evaluated as raw HTML then it just gives the latex code but doesn't evaluate it. I put some WIP here but it's mostly so that it's not lost since I don't find a good fix for this: https://github.com/etiennebacher/altdoc/pull/291


Replacing <code> by backticks is almost perfect but it means that there would be a mix of HTML and markdown syntax for example if there is code in the "Arguments" table. Some doc tools, e.g docute, don't support that and just show the backticks without formatting.