generated from bep/golibtemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables inclusion of these HTML elements in Markdown: - Inserted Text (++inserted++) - Mark Text (==marked==) - Subscript (H~2~O) - Superscript (1^st^) Closes #12
- Loading branch information
1 parent
998eef2
commit 234f8fa
Showing
11 changed files
with
703 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
1 | ||
//- - - - - - - - -// | ||
++Hi++ Hello, world! | ||
//- - - - - - - - -// | ||
<p><ins>Hi</ins> Hello, world!</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
2 | ||
//- - - - - - - - -// | ||
This ++has a | ||
|
||
new paragraph++. | ||
//- - - - - - - - -// | ||
<p>This ++has a</p> | ||
<p>new paragraph++.</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
3 | ||
//- - - - - - - - -// | ||
x ++++foo++ bar++ | ||
//- - - - - - - - -// | ||
<p>x <ins><ins>foo</ins> bar</ins></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
4 | ||
//- - - - - - - - -// | ||
x ++foo ++bar++++ | ||
//- - - - - - - - -// | ||
<p>x <ins>foo <ins>bar</ins></ins></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
5 | ||
//- - - - - - - - -// | ||
x ++++foo++++ | ||
//- - - - - - - - -// | ||
<p>x <ins><ins>foo</ins></ins></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
6 | ||
//- - - - - - - - -// | ||
**++test**++ | ||
|
||
++**test++** | ||
//- - - - - - - - -// | ||
<p><strong>++test</strong>++</p> | ||
<p><ins>**test</ins>**</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
7 | ||
//- - - - - - - - -// | ||
[++link]()++ | ||
|
||
++[link++]() | ||
//- - - - - - - - -// | ||
<p><a href="">++link</a>++</p> | ||
<p>++<a href="">link++</a></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
1 | ||
//- - - - - - - - -// | ||
==Hello==, world! | ||
//- - - - - - - - -// | ||
<p><mark>Hello</mark>, world!</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
2 | ||
//- - - - - - - - -// | ||
This mark ==has a | ||
|
||
new paragraph==. | ||
//- - - - - - - - -// | ||
<p>This mark ==has a</p> | ||
<p>new paragraph==.</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
3 | ||
//- - - - - - - - -// | ||
x ====foo== bar== | ||
//- - - - - - - - -// | ||
<p>x <mark><mark>foo</mark> bar</mark></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
4 | ||
//- - - - - - - - -// | ||
x ==foo ==bar==== | ||
//- - - - - - - - -// | ||
<p>x <mark>foo <mark>bar</mark></mark></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
5 | ||
//- - - - - - - - -// | ||
x ====foo==== | ||
//- - - - - - - - -// | ||
<p>x <mark><mark>foo</mark></mark></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
6 | ||
//- - - - - - - - -// | ||
**==test**== | ||
|
||
==**test==** | ||
//- - - - - - - - -// | ||
<p><strong>==test</strong>==</p> | ||
<p><mark>**test</mark>**</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
7 | ||
//- - - - - - - - -// | ||
[==link]()== | ||
|
||
==[link==]() | ||
//- - - - - - - - -// | ||
<p><a href="">==link</a>==</p> | ||
<p>==<a href="">link==</a></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
1: Surrounded by tildes | ||
//- - - - - - - - -// | ||
~foo~ | ||
//- - - - - - - - -// | ||
<p><sub>foo</sub></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
2: Formula with tildes in the middle | ||
//- - - - - - - - -// | ||
H~2~O | ||
//- - - - - - - - -// | ||
<p>H<sub>2</sub>O</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
3: Indices | ||
//- - - - - - - - -// | ||
x~i~ + x~j~ | ||
//- - - - - - - - -// | ||
<p>x<sub>i</sub> + x<sub>j</sub></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
4: Escaped tilde | ||
//- - - - - - - - -// | ||
~foo\~ | ||
//- - - - - - - - -// | ||
<p>~foo~</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
5: Non-breaking space entity | ||
//- - - - - - - - -// | ||
~foo bar~ | ||
//- - - - - - - - -// | ||
<p><sub>foo bar</sub></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
6: Non-breaking space UTF-8 | ||
//- - - - - - - - -// | ||
~foo bar~ | ||
//- - - - - - - - -// | ||
<p><sub>foo bar</sub></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
7: Mixed subscript and strikethrough | ||
//- - - - - - - - -// | ||
~~x~foobar~~~ | ||
//- - - - - - - - -// | ||
<p><del>x<sub>foobar</sub></del></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
8: Tildes in the middle and text before | ||
//- - - - - - - - -// | ||
text H~2~O | ||
//- - - - - - - - -// | ||
<p>text H<sub>2</sub>O</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
9: Tildes in the middle and text after | ||
//- - - - - - - - -// | ||
H~2~O text | ||
//- - - - - - - - -// | ||
<p>H<sub>2</sub>O text</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
1: Surrounded by cares | ||
//- - - - - - - - -// | ||
^foo^ | ||
//- - - - - - - - -// | ||
<p><sup>foo</sup></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
2: Ordinal indicator | ||
//- - - - - - - - -// | ||
2^nd^ | ||
//- - - - - - - - -// | ||
<p>2<sup>nd</sup></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
3: Powers | ||
//- - - - - - - - -// | ||
x^2^ + x^5^ | ||
//- - - - - - - - -// | ||
<p>x<sup>2</sup> + x<sup>5</sup></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
4: Escaped care | ||
//- - - - - - - - -// | ||
^foo\^ | ||
//- - - - - - - - -// | ||
<p>^foo^</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
5: : Cares surround text with a non-breaking space entity | ||
//- - - - - - - - -// | ||
^foo bar^ | ||
//- - - - - - - - -// | ||
<p><sup>foo bar</sup></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
6: Cares surround text Surround with a non-breaking space (UTF-8) | ||
//- - - - - - - - -// | ||
^foo bar^ | ||
//- - - - - - - - -// | ||
<p><sup>foo bar</sup></p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
7: Cares in the middle and text before | ||
//- - - - - - - - -// | ||
text C^foo^C | ||
//- - - - - - - - -// | ||
<p>text C<sup>foo</sup>C</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
8: Cares in the middle and text after | ||
//- - - - - - - - -// | ||
C^foo^C text | ||
//- - - - - - - - -// | ||
<p>C<sup>foo</sup>C text</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
9: Wrong markers in LaTeX style notation should be left untouched | ||
//- - - - - - - - -// | ||
x^2 + x^3 | ||
//- - - - - - - - -// | ||
<p>x^2 + x^3</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// | ||
|
||
10: Footnote markers should be left untouched | ||
//- - - - - - - - -// | ||
text[^1] text[^2] | ||
//- - - - - - - - -// | ||
<p>text[^1] text[^2]</p> | ||
//= = = = = = = = = = = = = = = = = = = = = = = =// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package ast | ||
|
||
import ( | ||
gast "github.com/yuin/goldmark/ast" | ||
) | ||
|
||
type InlineTagType int | ||
|
||
const ( | ||
Superscript InlineTagType = iota + 1 | ||
Subscript | ||
Insert | ||
Mark | ||
) | ||
|
||
type InlineTag struct { | ||
TagType InlineTagType | ||
Char byte | ||
Number int | ||
Html string | ||
WhitespaceAllowed bool | ||
ParsePriority int | ||
RenderPriority int | ||
} | ||
|
||
var SuperscriptTag = InlineTag{ | ||
TagType: Superscript, | ||
Char: '^', | ||
Number: 1, | ||
Html: "sup", | ||
WhitespaceAllowed: false, | ||
ParsePriority: 600, | ||
RenderPriority: 600, | ||
} | ||
|
||
var SubscriptTag = InlineTag{ | ||
TagType: Subscript, | ||
Char: '~', | ||
Number: 1, | ||
Html: "sub", | ||
WhitespaceAllowed: false, | ||
ParsePriority: 602, | ||
RenderPriority: 602, | ||
} | ||
|
||
var InsertTag = InlineTag{ | ||
TagType: Insert, | ||
Char: '+', | ||
Number: 2, | ||
Html: "ins", | ||
WhitespaceAllowed: true, | ||
ParsePriority: 501, | ||
RenderPriority: 501, | ||
} | ||
|
||
var MarkTag = InlineTag{ | ||
TagType: Mark, | ||
Char: '=', | ||
Number: 2, | ||
Html: "mark", | ||
WhitespaceAllowed: true, | ||
ParsePriority: 550, | ||
RenderPriority: 550, | ||
} | ||
|
||
type InlineTagNode struct { | ||
gast.BaseInline | ||
|
||
InlineTag | ||
} | ||
|
||
func NewInlineTag(tag InlineTag) *InlineTagNode { | ||
return &InlineTagNode{ | ||
BaseInline: gast.BaseInline{}, | ||
|
||
InlineTag: tag, | ||
} | ||
} | ||
|
||
var KindSuperscript = gast.NewNodeKind("Superscript") | ||
var KindSubscript = gast.NewNodeKind("Subscript") | ||
var KindInsert = gast.NewNodeKind("Insert") | ||
var KindMark = gast.NewNodeKind("Mark") | ||
|
||
func NewInlineTagNodeKind(tag InlineTagType) gast.NodeKind { | ||
var kind gast.NodeKind | ||
switch tag { | ||
case Superscript: | ||
kind = KindSuperscript | ||
case Subscript: | ||
kind = KindSubscript | ||
case Insert: | ||
kind = KindInsert | ||
case Mark: | ||
kind = KindMark | ||
} | ||
return kind | ||
} | ||
|
||
func (n *InlineTagNode) Kind() gast.NodeKind { | ||
return NewInlineTagNodeKind(n.TagType) | ||
} | ||
|
||
func (n *InlineTagNode) Dump(source []byte, level int) { | ||
gast.DumpHelper(n, source, level, nil, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/gohugoio/hugo-goldmark-extensions/extras | ||
|
||
go 1.20 | ||
|
||
require github.com/yuin/goldmark v1.7.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github.com/yuin/goldmark v1.7.0 h1:EfOIvIMZIzHdB/R/zVrikYLPPwJlfMcNczJFMs1m6sA= | ||
github.com/yuin/goldmark v1.7.0/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= | ||
github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= | ||
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= |
Oops, something went wrong.