conig / revise

R package for writing revise and resubmits
Other
3 stars 2 forks source link

Rendering brackets method to md or html removes bracketed section #18

Open cjvanlissa opened 1 year ago

cjvanlissa commented 1 year ago

Performing more tests, I find that text in brackets, e.g. [section]{#tag} is inconsistently rendered. In md_document and html_document, it is removed entirely. In pdf_document, the behavior depends on pandoc version: 2.18 renders as intended (no square brackets, yes text); 2.19.2 renders square brackets in text.

conig commented 1 year ago

We might be trying to get the anchor tags to do a job they weren't designed for. Therefore might not be a bug.

Looking at the pandoc manual:

https://pandoc.org/MANUAL.html#divs-and-spans

Extension: bracketed_spans A bracketed sequence of inlines, as one would use to begin a link, will be treated as a Span with attributes if it is followed immediately by attributes: [This is some text]{.class key="val"}

Perhaps we could instead use the fenced div syntax for multi-line sequences, and reserve []{#} for inline stuff.

We could even get an rstudio addin to automatically detect whether users are tagging single or multi-line content and insert the appropriate syntax for them.

Example:

---
format: "html"
---

::: {#multiline}
## Heading 1

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pulvinar felis scelerisque auctor mattis. Interdum et malesuada fames ac ante ipsum primis in faucibus.
:::

## Heading 2

Quisque eget libero ut odio placerat convallis [aliquam convallis urna.]{#inline}

These syntax options are documented in the pandoc manual, and come out consistently cleanly:

image

The div block also looks awesome in the rstudio visual editor

image