Skip to content

Commit

Permalink
🎨 Protyle Improve the handling of inline-math containing | in the t…
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 25, 2023
1 parent b994942 commit 94bd2a2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion lex/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,19 @@ func AddBackslashBeforePipe(content string) string {
func RepeatBackslashBeforePipe(content string) string {
buf := bytes.Buffer{}
var last byte
backslashCnt := 0
for i := 0; i < len(content); i++ {
b := content[i]
if ItemPipe == b {
if ItemBackslash != last {
buf.WriteByte(ItemBackslash)
backslashCnt = 0
} else {
backslashCnt++
}
if 1 < backslashCnt {
buf.WriteByte(ItemBackslash)
}
buf.WriteByte(ItemBackslash)
}
last = b
buf.WriteByte(b)
Expand Down
4 changes: 2 additions & 2 deletions test/protyle_export_md_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

var protyleExportMdTests = []parseTest{

{"9", "| $foo\\\\|bar$ |\n| -- |", "|$foo\\\\\\|bar$|\n| -|\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
{"8", "| $foo\\|bar$ |\n| -- |", "|$foo\\\\|bar$|\n| -|\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
//{"9", "| $foo\\\\|bar$ |\n| -- |", "|$foo\\\\\\|bar$|\n| -|\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
{"8", "| $foo\\|bar$ |\n| -- |", "|$foo\\|bar$|\n| -|\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
{"7", "[~\\~foo\\~foo\\~~](bar)", "[~\\~foo\\~foo\\~~](bar)\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
{"6", "[^\\^foo\\^foo\\^^](bar)", "[^\\^foo\\^foo\\^^](bar)\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
{"5", "[==\\=foo\\=foo\\===](bar)", "[==\\=foo\\=foo\\===](bar)\n\n{: id=\"20060102150405-1a2b3c4\" updated=\"20060102150405\" type=\"doc\"}\n"},
Expand Down

0 comments on commit 94bd2a2

Please sign in to comment.