Skip to content

Syntax for metadata on code blocks #633

Closed
@Julow

Description

@Julow

It should be possible to attach metadata to code blocks. There is two main use-cases:

  • Running Mdx on OCaml and mld files. It needs per-block configuration.
  • Code highlighting. The HTML backend adds color highlighting but assumes that all blocks contain OCaml code.

Odoc won't try to interpret or to render them, they would be present in the parse tree but discared afterwards.

During a previous meeting, we proposed the following syntax:

{@language metadata [
]}

The metadata part is an arbitrary string and is optional.
We'd need quoting, I propose wrapping it with double quotes ("") and allowing OCaml's escaping (eg. \" and everything String.escape produces).

The language part is not optional.

For example:

{@sh [
rm -rf /
]}
{@ocaml env=f1 version>=4.06 [
# let x = 1 ;;
val x : 1
]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions