Skip to content

About

A goldmark extension adding ^text^ superscript syntax, rendered as <sup>text</sup>

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

goldmark-superscript

A goldmark extension that adds superscript syntax: ^text^ renders as <sup>text</sup>.

E=mc^2^   →   E=mc<sup>2</sup>

It is implemented the same way as goldmark's built-in extension.Strikethrough (a single-character inline delimiter with CommonMark flanking rules), so it behaves predictably alongside the rest of goldmark.

Install

go get github.com/matthew6s/goldmark-superscript

Usage

import (
	"github.com/yuin/goldmark"
	superscript "github.com/matthew6s/goldmark-superscript"
)

md := goldmark.New(
	goldmark.WithExtensions(superscript.Superscript),
)

Behavior

  • A pair of single carets on the same line forms a superscript span: x^2^ → x<sup>2</sup>.
  • The text between the carets is parsed as normal inline Markdown, so it may contain emphasis, code spans, links, etc.: ^**b**^ → <sup><strong>b</strong></sup>.
  • Following CommonMark flanking rules, a caret directly adjacent to whitespace does not open or close a span (^ 2^ stays literal).
  • A run of two or more consecutive carets (^^) is never a delimiter.
  • An unmatched caret is rendered literally.
  • When the extension is not registered, ^ has no special meaning.

License

MIT — see LICENSE.

About

A goldmark extension adding ^text^ superscript syntax, rendered as <sup>text</sup>

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages