Skip to content

code directive #7

Closed
Enhancement
@Mpdreamz

Description

@Mpdreamz

Code

Kind Link
Reference https://mystmd.org/guide/directives#directive-code
Documentation https://mystmd.org/guide/code

A code-block environment with a language as the argument, and options for highlighting, showing line numbers, and an optional filename.

Implementation

  • Parses directives and aliases
  • Emits HTML
  • Unit tests
  • Validation (emits, warnings and errors).

Specification compliance:

  • Arguments is not parsed and treated as language option
  • Body is not parsed and treated as raw string
  • Options:
    • label, name (string) - Label the code to be cross-referenced or explicitly linked to.
    • enumerated, numbered (boolean) - Turn on/off the numbering for the specific code
    • enumerator, number (string) - Explicitly set the code number
    • class (string)
    • caption (parsed) - A parsed caption for the code block.
    • linenos (boolean)- Show line numbers
    • lineno-start (number) - Start line numbering from a particular value, default is 1. If present, line numbering is activated.
    • number-lines (number)
      Alternative for “lineno-start”, turns on line numbering and can be an integer that is the start of the line numbering.
    • emphasize-lines (string) - Emphasize particular lines (comma-separated numbers), e.g. “3,5”
    • filename (string)
      Show the filename in addition to the rendered code. The include directive will use the filename by default, to turn off this default set the filename to false.
  • Aliases:
    • code-block
    • sourcecode

Metadata

Metadata

Assignees

No one assigned

    Labels

    authoringRelates to our markdown parser

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions