Skip to content

Commit fff63a7

Browse files
committed
Allow math expressions to be preceeded but not suceeded by alphanumerical characters
Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
1 parent e375bf3 commit fff63a7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/markup/markdown/math/inline_parser.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ func (parser *inlineParser) Trigger() []byte {
4141
return parser.start[0:1]
4242
}
4343

44+
func isAlphanumeric(b byte) bool {
45+
// Github only cares about 0-9A-Za-z
46+
return (b >= '0' && b <= '9') || (b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z')
47+
}
48+
4449
// Parse parses the current line and returns a result of parsing.
4550
func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node {
4651
line, _ := block.PeekLine()
@@ -69,6 +74,9 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.
6974
if len(line) <= pos {
7075
break
7176
}
77+
if isAlphanumeric(line[pos]) {
78+
return nil
79+
}
7280
if line[ender-1] != '\\' {
7381
break
7482
}

0 commit comments

Comments
 (0)