Skip to content

Commit

Permalink
readme: Add description of extras extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Mar 15, 2024
1 parent 998eef2 commit a0918ec
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,61 @@ inline $a^*=x-b^*$ snippet
fmt.Println(buf.String())
}
```

## Extras extension

[![GoDoc](https://godoc.org/github.com/gohugoio/hugo-goldmark-extensions/extras?status.svg)](https://godoc.org/github.com/gohugoio/hugo-goldmark-extensions/extras)

Use this extension to enable [subscript] (`<sub>`), [superscript] (`<sup>`), and [inserted text] (`<ins>`) elements in Markdown.

[subscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub
[superscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
[inserted text ]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins

### Examples

```text
1^st^ → 1<sup>st</sup>
H~2~O → H<sub>2</sub>O
++insert++ → <ins>insert</ins>
```

### Usage

```go
package main

import (
"bytes"
"fmt"

"github.com/gohugoio/hugo-goldmark-extensions/passthrough"
"github.com/yuin/goldmark"
)

func main() {
md := goldmark.New(
goldmark.WithExtensions(
extras.New(
extras.Config{
// TBD
},
)),
)

input := `
Hydrogen is the 1^st^ element in the periodic table.
Water (H~2~O) is a liquid.
Water (H~2~O) is a ++transparent++ liquid.
`

var buf bytes.Buffer
if err := md.Convert([]byte(input), &buf); err != nil {
panic(err)
}

fmt.Println(buf.String())
}
```

0 comments on commit a0918ec

Please sign in to comment.