Search results

There are no results.

wobsite.markdown.SyntaxHighlight

class pub SyntaxHighlight

A filter that applies syntax highlighting to a Markdown document.

This filter processes fenced code blocks that are tagged with a language, such as the following:

```inko
this_is_inko_code
```

Syntax highlighting is performed using inko-syntax.

Static methods

new

Show source code
Hide source code
fn pub static new -> SyntaxHighlight {
  SyntaxHighlight(Languages.new)
}
fn pub static new -> SyntaxHighlight

Instance methods

run

Show source code
Hide source code
fn pub mut run(document: mut html.Document) {
  let nodes = document.nodes.iter_mut.to_array

  loop {
    match nodes.pop {
      case Some(Element(el)) if el.name == 'pre' and el.nodes.size == 1 -> {
        replace(el)
      }
      case Some(Element(el)) -> nodes.append(el.nodes.iter_mut.to_array)
      case Some(_) -> {}
      case _ -> break
    }
  }
}
fn pub mut run(document: mut Document)

Transforms the HTML document.

How or what exactly this method does is up to the type that implements this trait. Examples include adding IDs to headings, generating a table of contents, or replacing one element with another.

Implemented traits

markdown.html.

Filter

impl Filter for SyntaxHighlight