Ruby kramdown

From wikinotes

A markdown parser written in ruby.

Documentation

official docs https://kramdown.gettalong.org/syntax.html
github https://github.com/gettalong/kramdown

Editors

online kramdown editor http://kramdown.electricbook.works/

Syntax

In addition to the base markdown syntax

Headers

Set the id of a header

# Header 1 (#my-first-header)

Links

Footnotes

This species of foo is noted for it's propensity to...[^wikipedia].

[^wikipedia]: See wikipedia

End of Block

Use ^ to indicate the end of block elements.
Useful to separate lists, code-blocks, etc.

    def foo(bar):
        print("baz")
^
    def snap(crackle):
        print("pop")

Code

Fenced code-blocks

~~~
def foo(bar):
    print("baz")
~~~

Fenced code-block syntax-highlighting

~~~ python
def foo(bar):
    print("baz")
~~~

Tables

Tables without headers

| red   | #FF0000 |
| green | #00FF00 |
| blue  | #0000FF |

Tables with headers

| faction  | username |
| -------- | -------- |
| imperial | vaderd   |
| rebel    | lukes    |

Cell Alignment is indicated with : characters in the header marker.

| right aligned  |  centered  | left aligned  | default aligned |
| -------------: | :--------: | :------------ | --------------- |
| foo            |    bar     | baz           | bif             |

It can also be abbreviated:

| right aligned | centered | left aligned | default aligned |
| -: | :-: | :- | - |
| foo | bar | baz | bif |

Kramdown also supports multiple table bodies, and table footer rows. </syntaxhighlight>

Math

Kramdown can also render latex code blocks.

$$
x^2 \times 5
$$

HTML attributes

You can set attributes on html elements.

  • id/class use a syntax like css selectors. (ex: {:.set-my-id})
  • other key/value attributes can be assigned with an equal sign (ex: {:title="my title"}
# header with id and title
{: .header-with-id-and-title}
{:title="Header with ID"}


{:.ruby}
    def foo(bar = "baz")
      p bar
    end