Skip to content

Commit

Permalink
Allow math expressions to be preceeded but not suceeded by alphanumer…
Browse files Browse the repository at this point in the history
…ical characters

Signed-off-by: João Tiago <[email protected]>
  • Loading branch information
jmlt2002 committed Mar 31, 2024
1 parent e375bf3 commit fff63a7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/markup/markdown/math/inline_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (parser *inlineParser) Trigger() []byte {
return parser.start[0:1]
}

func isAlphanumeric(b byte) bool {
// Github only cares about 0-9A-Za-z
return (b >= '0' && b <= '9') || (b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z')
}

// Parse parses the current line and returns a result of parsing.
func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) ast.Node {
line, _ := block.PeekLine()
Expand Down Expand Up @@ -69,6 +74,9 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser.
if len(line) <= pos {
break
}
if isAlphanumeric(line[pos]) {
return nil
}
if line[ender-1] != '\\' {
break
}
Expand Down

0 comments on commit fff63a7

Please sign in to comment.