-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent loop with overlapping chars (#130)
- Loading branch information
Showing
6 changed files
with
83 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Highlighted chars loop | ||
|
||
Overlapping chars should not cause infinite loop | ||
|
||
```js /carrot/ /car/ | ||
const carrot = 'carrot'; | ||
const car = 'car'; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
<style> | ||
html { | ||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif; | ||
} | ||
body { | ||
margin: 30px auto; | ||
max-width: 800px; | ||
} | ||
pre { | ||
padding: 16px; | ||
} | ||
span > code { | ||
background: black; | ||
padding: 4px; | ||
} | ||
[data-highlighted-line], [data-highlighted-chars] { | ||
background-color: rgba(255, 255, 255, 0.25); | ||
} | ||
code[data-line-numbers] { | ||
counter-reset: line; | ||
} | ||
code[data-line-numbers]>[data-line]::before { | ||
counter-increment: line; | ||
content: counter(line); | ||
display: inline-block; | ||
width: 1rem; | ||
margin-right: 2rem; | ||
text-align: right; | ||
color: gray; | ||
} | ||
|
||
[data-rehype-pretty-code-figure] code[data-theme*=' '], | ||
[data-rehype-pretty-code-figure] code[data-theme*=' '] span { | ||
color: var(--shiki-light) !important; | ||
background-color: var(--shiki-light-bg) !important; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
[data-rehype-pretty-code-figure] code[data-theme*=' '], | ||
[data-rehype-pretty-code-figure] code[data-theme*=' '] span { | ||
color: var(--shiki-dark) !important; | ||
background-color: var(--shiki-dark-bg) !important; | ||
} | ||
} | ||
|
||
.diff.add { | ||
background-color: rgba(0, 255, 100, 0.25); | ||
} | ||
.diff.remove { | ||
background-color: rgba(255, 100, 200, 0.35); | ||
} | ||
</style> | ||
<h1>Highlighted chars loop</h1> | ||
<p>Overlapping chars should not cause infinite loop</p> | ||
<figure data-rehype-pretty-code-figure=""> | ||
<pre | ||
style="background-color: #24292e; color: #e1e4e8" | ||
tabindex="0" | ||
data-language="js" | ||
data-theme="github-dark" | ||
><code data-language="js" data-theme="github-dark" style="display: grid;"><span data-line=""><span style="color:#F97583">const</span><span style="color:#79B8FF"> </span><mark data-highlighted-chars="" class="word"><span style="color:#79B8FF">carrot</span></mark><span style="color:#F97583"> =</span><span style="color:#9ECBFF"> '</span><mark data-highlighted-chars="" class="word"><span style="color:#9ECBFF">carrot</span></mark><span style="color:#9ECBFF">'</span><span style="color:#E1E4E8">;</span></span> | ||
<span data-line=""><span style="color:#F97583">const</span><span style="color:#79B8FF"> </span><mark data-highlighted-chars="" class="word"><span style="color:#79B8FF">car</span></mark><span style="color:#F97583"> =</span><span style="color:#9ECBFF"> '</span><mark data-highlighted-chars="" class="word"><span style="color:#9ECBFF">car</span></mark><span style="color:#9ECBFF">'</span><span style="color:#E1E4E8">;</span></span></code></pre> | ||
</figure> |