Weekly Shaarli

All links of one week in a single page.

Week 37 (September 11, 2023)

No great options to comment out text in R Markdown
thumbnail

When writing in R Markdown format I often would like to comment out one or more lines of text (for example to quickly test variations on sentences or paragraphs) in a way that these comments do not show in the generated HTML file.

The R Markdown Cookbook only mentions HTML comment syntax <!-- your comment --> which does not stop the comment from remaining in the generated HTML file.

Best solutions, as far as I know:

Additional YAML blocks

Add a YAML block with commented out lines (baptiste's suggestion):

Some text in the document.

---
# commented out text
# and such
---

This works fine, it is just slightly verbose to use.
But it is the only option that works without any issues.

Abuse the markdown link labels syntax

This is the most popular answer (by far) on SO:

Some text in the document.

[//]: # (commented out text)

[//]: # (another comment)

According to other answers/comments, this sort of comment line should always have a blank line before it to be proper.
The drawback for Rmd appears as soon as we have more than one such comment line; knitr spits out a very visible warning in the standard output:
[WARNING] Duplicate link reference '[//]' at ... line ....

The only(?) way to avoid those warnings is to differentiate the link labels, but that quickly becomes tedious.

Some text in the document.

[//1]: # (commented out text)

[//2]: # (another comment, now without a knitr warning)

If you know of a less verbose method than adding YAML blocks, or an easier way to circumvent the knitr warnings, I would love to learn about it.

Ny nationell kartläggning av träd i städer och tätorter
thumbnail

Kartläggningen ger en bild av nuläget i 200 tätorter med fler än 5000 invånare. Boverket refererar till den allt oftare uppmärksammade 3-30-300-regeln, det vill säga att man ska kunna se tre träd från sitt fönster, att 30 procent av stadsdelen ska vara täckt av träd och att de boende ska ha max 300 meter till ett grönområde.

Via Arkitekten.se