File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -60,3 +60,24 @@ text[^1] text[^2]
60
60
//- - - - - - - - -//
61
61
<p>text[^1] text[^2]</p>
62
62
//= = = = = = = = = = = = = = = = = = = = = = = =//
63
+
64
+ 10: Superscript is one of +, -, '
65
+ //- - - - - - - - -//
66
+ x^+^ x^-^ x^'^
67
+ //- - - - - - - - -//
68
+ <p>x<sup>+</sup> x<sup>-</sup> x<sup>'</sup></p>
69
+ //= = = = = = = = = = = = = = = = = = = = = = = =//
70
+
71
+ 11: Superscript begins with one of +, -, '
72
+ //- - - - - - - - -//
73
+ x^+2^ x^-2^ x^'2^
74
+ //- - - - - - - - -//
75
+ <p>x<sup>+2</sup> x<sup>-2</sup> x<sup>'2</sup></p>
76
+ //= = = = = = = = = = = = = = = = = = = = = = = =//
77
+
78
+ 12: Superscript ends with one of +, -, '
79
+ //- - - - - - - - -//
80
+ x^2+^ x^2-^ x^2'^
81
+ //- - - - - - - - -//
82
+ <p>x<sup>2+</sup> x<sup>2-</sup> x<sup>2'</sup></p>
83
+ //= = = = = = = = = = = = = = = = = = = = = = = =//
Original file line number Diff line number Diff line change 1
1
package extras
2
2
3
3
import (
4
+ "slices"
5
+
4
6
"github.com/yuin/goldmark"
5
7
"github.com/yuin/goldmark/ast"
6
8
"github.com/yuin/goldmark/parser"
@@ -47,7 +49,17 @@ func (s *inlineTagParser) Trigger() []byte {
47
49
func (s * inlineTagParser ) Parse (_ ast.Node , block text.Reader , pc parser.Context ) ast.Node {
48
50
before := block .PrecendingCharacter ()
49
51
line , segment := block .PeekLine ()
50
- node := parser .ScanDelimiter (line , before , s .Number , newInlineTagDelimiterProcessor (s .inlineTag ))
52
+
53
+ // Issue 30
54
+ lineClone := slices .Clone (line )
55
+ if s .inlineTag .TagKind == kindSuperscript && len (line ) > s .Number {
56
+ switch line [s .Number ] {
57
+ case byte ('+' ), byte ('-' ), byte ('\'' ):
58
+ lineClone [s .Number ] = byte ('z' ) // replace symbols with any letter
59
+ }
60
+ }
61
+
62
+ node := parser .ScanDelimiter (lineClone , before , s .Number , newInlineTagDelimiterProcessor (s .inlineTag ))
51
63
if node == nil || node .OriginalLength > 2 || before == rune (s .Char ) {
52
64
return nil
53
65
}
You can’t perform that action at this time.
0 commit comments