Skip to content

Commit

Permalink
fix(parser): remove support for underscores so URLs can use
Browse files Browse the repository at this point in the history
  • Loading branch information
neotyk committed May 16, 2021
1 parent a81e12e commit dd5affb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 40 deletions.
24 changes: 9 additions & 15 deletions src/cljc/athens/parser/impl.cljc
Expand Up @@ -76,19 +76,13 @@ code-span = <#'(?<!\\w)`'>
#'(?s)([^`]|(?<=\\s)`(?=\\s))+'
<#'`(?!\\w)'>
strong-emphasis = (<#'(?<!\\w)\\*\\*(?!\\s)'>
recur
<#'(?<!\\s)\\*\\*(?!\\w)'>)
| (<#'(?<!\\w)__(?!\\s)'>
recur
<#'(?<!\\s)__(?!\\w)'>)
emphasis = (<#'(?<!\\w)\\*(?!\\s)'>
recur
<#'(?<!\\s)\\*(?!\\w)'>)
| (<#'(?<!\\w)_(?!\\s)'>
recur
<#'(?<!\\s)_(?!\\w)'>)
strong-emphasis = <#'(?<!\\w)\\*\\*(?!\\s)'>
recur
<#'(?<!\\s)\\*\\*(?!\\w)'>
emphasis = <#'(?<!\\w)\\*(?!\\s)'>
recur
<#'(?<!\\s)\\*(?!\\w)'>
highlight = <#'(?<!\\w)\\^\\^(?!\\s)'>
recur
Expand Down Expand Up @@ -144,10 +138,10 @@ latex = <#'(?<!\\w)\\$\\$(?!\\s)'>
(* every delimiter used as inline span boundary has to be added below *)
(* anything but special chars *)
text-run = #'(?:[^\\*_`\\^~\\[!<\\(\\#\\$\\{\\r\\n]|(?<=\\S)[`!\\#\\$\\{])+'
text-run = #'(?:[^\\*`\\^~\\[!<\\(\\#\\$\\{\\r\\n]|(?<=\\S)[`!\\#\\$\\{])+'
(* any special char *)
<special-char> = #'(?<!\\w)[\\*_`^~\\[!<\\(\\#\\$\\{]'
<special-char> = #'(?<!\\w)[\\*`^~\\[!<\\(\\#\\$\\{]'
<backtick> = #'(?<!`)`(?!`)'
Expand Down
16 changes: 1 addition & 15 deletions test/athens/cljs_parser_test.cljs
Expand Up @@ -224,16 +224,6 @@
[:strong-emphasis
[:text-run "strong"]]]

"_also emphasis_"
[:paragraph
[:emphasis
[:text-run "also emphasis"]]]

"__very strong__"
[:paragraph
[:strong-emphasis
[:text-run "very strong"]]]

;; mix and match different emphasis
"**bold and *italic***"
[:paragraph
Expand All @@ -248,11 +238,7 @@
[:text-run "normal "]
[:emphasis [:text-run "italic"]]
[:text-run " "]
[:strong-emphasis [:text-run "bold"]]]

"_so wrong*"
[:paragraph
[:text-run "_so wrong*"]]))
[:strong-emphasis [:text-run "bold"]]]))

(t/testing "highlights (local Athens extension `^^...^^`)"
(util/parses-to sut/inline-parser->ast
Expand Down
10 changes: 0 additions & 10 deletions test/athens/parser/impl_test.clj
Expand Up @@ -229,16 +229,6 @@
[:strong-emphasis
[:text-run "strong"]]]

"_also emphasis_"
[:paragraph
[:emphasis
[:text-run "also emphasis"]]]

"__very strong__"
[:paragraph
[:strong-emphasis
[:text-run "very strong"]]]

;; mix and match different emphasis
"**bold and *italic***"
[:paragraph
Expand Down

0 comments on commit dd5affb

Please sign in to comment.