Skip to content

Commit

Permalink
Fix markdown for avoid convert any with underline surrounded for avoi…
Browse files Browse the repository at this point in the history
…d change URL.
  • Loading branch information
huacnlee committed May 6, 2022
1 parent 4d93cf0 commit 1fc5bbc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 1 addition & 3 deletions autocorrect/grammar/markdown.pest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
para = { ANY* ~ NEWLINE{2} }
expr = _{ codeblock | img | link | td_tag | mark | heading }
expr = _{ codeblock | img | link | td_tag | heading }
text = { (!(expr | newline) ~ ANY)+ }
newline = ${ "\n" | "\r" }
space = @{ (" ")* }
Expand All @@ -13,8 +13,6 @@ mark_tag = @{
"**"
| "*"
| "~~"
| "__"
| "_"
| "`"
}
heading_tag = @{"######" | "#####" | "####" | "###" | "##" | "#"}
Expand Down
16 changes: 16 additions & 0 deletions autocorrect/src/code/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ mod tests {
#[test]
fn test_format_markdown() {
let example = r###"
---
title: IPAD 和 Ios 接入的不同点
id: h
slug: /appstore/ipad_and_ios
---
# 这是Heading 1大标题
https://google.com/foo/__ios__/**ios**
**加粗**
*倾斜*
~~删除线~~
Expand Down Expand Up @@ -57,8 +65,16 @@ mod tests {
"###;

let expected = r###"
---
title: iPad 和 iOS 接入的不同点
id: h
slug: /appstore/ipad_and_ios
---
# 这是 Heading 1 大标题
https://google.com/foo/__ios__/**ios**
**加粗**
*倾斜*
~~删除线~~
Expand Down
5 changes: 5 additions & 0 deletions autocorrect/src/spellcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ mod tests {
"this is ipad ios website, and the IOS download url" => "this is iPad iOS website, and the iOS download url",
"Ios download" => "iOS download",
"Download iOs" => "Download iOS",
"hello_ios" => "hello_ios",
"ios_hello" => "ios_hello",
"'ios'" => "'ios'",
"openios" => "openios",
"diff_ws_ios\n" => "diff_ws_ios\n",
"diff_ws_ios " => "diff_ws_ios ",
"https://ios.com" => "https://ios.com",
"[email protected]" => "[email protected]",
"开放 IOS 接口" => "开放 iOS 接口",
Expand Down

0 comments on commit 1fc5bbc

Please sign in to comment.