diff --git a/README.md b/README.md index 2682f8a..f426015 100644 --- a/README.md +++ b/README.md @@ -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] (``), [superscript] (``), and [inserted text] (``) 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^ → 1st +H~2~O → H2O +++insert++ → insert +``` + +### 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()) +} +```