generated from bep/golibtemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move ast package one level up * Unexport most types * Simplify config
- Loading branch information
Showing
4 changed files
with
193 additions
and
160 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,108 @@ | ||
package extras | ||
|
||
import ( | ||
"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 { | ||
ast.BaseInline | ||
|
||
inlineTag | ||
} | ||
|
||
func newInlineTag(tag inlineTag) *inlineTagNode { | ||
return &inlineTagNode{ | ||
BaseInline: ast.BaseInline{}, | ||
|
||
inlineTag: tag, | ||
} | ||
} | ||
|
||
var ( | ||
kindSuperscript = ast.NewNodeKind("Superscript") | ||
kindSubscript = ast.NewNodeKind("Subscript") | ||
kindInsert = ast.NewNodeKind("Insert") | ||
kindMark = ast.NewNodeKind("Mark") | ||
) | ||
|
||
func newInlineTagNodeKind(tag inlineTagType) ast.NodeKind { | ||
var kind ast.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() ast.NodeKind { | ||
return newInlineTagNodeKind(n.TagType) | ||
} | ||
|
||
func (n *inlineTagNode) Dump(source []byte, level int) { | ||
ast.DumpHelper(n, source, level, nil, nil) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.