Skip to content

Enable code copy for code snippets in panel tabsets #264

@cmjc

Description

@cmjc

Description

The website configuration in quarto.yml sets code copy to true:

code-copy: true

This works for a simple code block using yaml after the 3 backticks. E.g. https://docs.autonity.org/oracle/run-oracle/#atn-and-ntn-data-simulator-plugin.

This does not work for panel tab sets - e.g. https://docs.autonity.org/reference/api/aut/#usage

Quarto docs refs:

To get the copy button, docs say to add to the code block opening 3 backticks for a code block {r eval=FALSE} to the code block for the snippet. Example:

```{r eval=FALSE}
  go build -o ./build/bin/plugins/crypto_uniswap ./plugins/crypto_uniswap/crypto_uniswap.go

({r, copy=TRUE, eval=FALSE} works too )

This clearly isn't required for a simple code block but may be a solution for the panel-tabset. However, to use it the .qmd file extension must be used and not the current (legacy) .md extension. Without that change, the quarto build will error and fail if {r eval=FALSE} or {r, copy=TRUE, eval=FALSE} is used on a .md page.

Rationale

Allow code snippets in interface and guide pages to be copied to clipboard by the reader.

Implementation

To fix this and enable code snippets to be copied from code blocks and panel tabsets in website pages, the correct solution from the quarto docs seems:

  • page file extension needs changing from .md to .qmd.
  • leading back ticks to the code block should have {r eval=FALSE} after them

This should be tried to verify if it addresses the copy button issue.

Else, the use of yaml after the opening backticks could be researched to understand if this is a viable solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageNeeds prioritisation and/or scheduling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions