sugar-high 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -80,11 +80,24 @@ pre code {
80
80
  Target a line with `.sh__line:nth-child(<n>)` (1-based):
81
81
 
82
82
  ```css
83
+ .sh__line {
84
+ display: block;
85
+ padding: 0 12px;
86
+ margin: 0 -12px;
87
+ min-height: 1rem;
88
+ }
89
+
83
90
  .sh__line:nth-child(5) {
84
- background: #f5f5f5;
91
+ background: #fff8c5;
92
+ }
93
+
94
+ .sh__line--highlighted {
95
+ background: #fff8c5;
85
96
  }
86
97
  ```
87
98
 
99
+ Use `.sh__line--highlighted` when you add highlight classes yourself (for example with `lineClassName`).
100
+
88
101
  ## Remark
89
102
 
90
103
  Use the [remark plugin](https://sugar-high.vercel.app/remark) to highlight fenced code blocks when processing Markdown with [remark](https://remark.js.org/). Details: [`packages/remark-sugar-high`](https://github.com/huozhi/sugar-high/tree/main/packages/remark-sugar-high).
package/lib/index.js CHANGED
@@ -715,9 +715,16 @@ function tokenize(code, options) {
715
715
 
716
716
  let foundClose = false
717
717
 
718
+ // `/` is literal inside regex character classes, e.g. `[/]`.
719
+ let inCharClass = false
720
+
718
721
  // traverse to find closing regex slash
719
722
  for (; !isEol(); i++) {
720
- if (code[i] === '/' && code[i - 1] !== '\\') {
723
+ const ch = code[i]
724
+ const escaped = code[i - 1] === '\\'
725
+ if (!escaped && ch === '[') inCharClass = true
726
+ if (!escaped && ch === ']') inCharClass = false
727
+ if (ch === '/' && !inCharClass && !escaped) {
721
728
  foundClose = true
722
729
  // end of regex, append regex flags
723
730
  while (start !== i && /^[a-z]$/.test(code[i + 1]) && !isEol()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sugar-high",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/huozhi/sugar-high.git",