rehype-highlight-code-lines 1.0.10 → 1.1.0

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
@@ -100,26 +100,26 @@ async function main() {
100
100
  }
101
101
  ```
102
102
 
103
- Now, running `node example.js` you will see that each line of code is wrapped in a `div`, which has appropriate class names (`code-line`, `numbered-code-line`, `highlighted-code-line`) and line numbering attribute `data-line-number`.
103
+ Now, running `node example.js` you will see that each line of code is wrapped in a `span`, which has appropriate class names (`code-line`, `numbered-code-line`, `highlighted-code-line`) and line numbering attribute `data-line-number`.
104
104
 
105
105
  ```html
106
106
  <pre>
107
107
  <code class="hljs language-javascript">
108
- <div class="code-line numbered-code-line" data-line-number="1">
108
+ <span class="code-line numbered-code-line" data-line-number="1">
109
109
  <span class="hljs-keyword">let</span> a1;
110
- </div>
111
- <div
110
+ </span>
111
+ <span
112
112
  class="code-line numbered-code-line highlighted-code-line" data-line-number="2">
113
113
  <span class="hljs-keyword">let</span> a2;
114
- </div>
115
- <div class="code-line numbered-code-line" data-line-number="3">
114
+ </span>
115
+ <span class="code-line numbered-code-line" data-line-number="3">
116
116
  <span class="hljs-keyword">let</span> a3;
117
- </div>
117
+ </span>
118
118
  </code>
119
119
  </pre>
120
120
  ```
121
121
 
122
- Without `rehype-highlight-code-lines`, the lines of code wouldn't be in a `div`.
122
+ Without `rehype-highlight-code-lines`, the lines of code wouldn't be in a `span`.
123
123
 
124
124
  ```html
125
125
  <pre>
@@ -133,6 +133,92 @@ Without `rehype-highlight-code-lines`, the lines of code wouldn't be in a `div`.
133
133
 
134
134
  ***Note:** `hljs` prefix comes from `rehype-highlight`*.
135
135
 
136
+ ## Usage in HTML attributes
137
+
138
+ **`rehype-highlight-code-lines`** runs on `<code>` elements with directives like `showLineNumbers` and range number in curly braces like `{2-4, 8}`. That directives can be passed as a word in markdown (` ```ts showLineNumbers {2-4, 8} `) or as a class and attribute in HTML (`<code class="language-ts show-line-numbers" data-highlight-lines="2-4, 8">`).
139
+
140
+ The inverse occurs when the option `showLineNumbers` is true. All `<code>` are processed and numbered. Then (` ```ts noLineNumbers `), or as a class (`<code class="language-ts no-line-numbers">`) can be used to prevent processing.
141
+
142
+ **The class directives can be with dash or without, or camel cased.**
143
+
144
+ See some example usage as HTML class and attributes *(only opening `<code>` tags are provided, the rest is omitted.)*:
145
+ ```html
146
+ <code class="language-typescript show-line-numbers">
147
+ <code class="language-typescript showlinenumbers">
148
+ <code class="language-typescript showLineNumbers">
149
+
150
+ <code class="language-typescript show-line-numbers" data-highlight-lines="2-4">
151
+ <code class="language-typescript show-line-numbers" data-start-numbering="11">
152
+ <code class="language-typescript show-line-numbers" data-start-numbering="11" data-highlight-lines="2-4">
153
+
154
+ <code class="language-typescript no-line-numbers">
155
+ <code class="language-typescript nolinenumbers">
156
+ <code class="language-typescript noLineNumbers">
157
+ <code class="language-typescript no-line-numbers" data-highlight-lines="2-4">
158
+
159
+ <code class="no-line-numbers">
160
+ <code class="show-line-numbers">
161
+ <code class="show-line-numbers" data-highlight-lines="2-4">
162
+ <code data-highlight-lines="2-4">
163
+ <code data-start-numbering="11">
164
+ ```
165
+
166
+ Say we have the following HTML fragment in a `example.md`:
167
+
168
+ ```markdown
169
+ <pre><code class="language-javascript show-line-numbers" data-highlight-lines="2">
170
+ let a1;
171
+ let a2;
172
+ let a3;
173
+ </code></pre>
174
+ ```
175
+
176
+ I assume you use `rehype-highlight` for code highlighting. Our module, `example.js`, looks as follows:
177
+
178
+ ```javascript
179
+ import { read } from "to-vfile";
180
+ import remarkParse from "remark-parse";
181
+ import remarkRehype from "remark-rehype";
182
+ import rehypeRaw from "rehype-raw";
183
+ import rehypeHighlight from "rehype-highlight";
184
+ import rehypeHighlightLines from "rehype-highlight-code-lines";
185
+ import rehypeStringify from "rehype-stringify";
186
+
187
+ main();
188
+
189
+ async function main() {
190
+ const file = await unified()
191
+ .use(remarkParse)
192
+ .use(remarkRehype, { allowDangerousHtml: true })
193
+ .use(rehypeRaw)
194
+ .use(rehypeHighlight)
195
+ .use(rehypeHighlightLines)
196
+ .use(rehypeStringify)
197
+ .process(await read("example.md"));
198
+
199
+ console.log(String(file));
200
+ }
201
+ ```
202
+
203
+ Now, running `node example.js` you will see that each line of code is wrapped in a `span`, which has appropriate class names (`code-line`, `numbered-code-line`, `highlighted-code-line`) and line numbering attribute `data-line-number`.
204
+
205
+ ```html
206
+ <pre>
207
+ <code class="hljs language-javascript">
208
+ <span class="code-line numbered-code-line" data-line-number="1">
209
+ <span class="hljs-keyword">let</span> a1;
210
+ </span>
211
+ <span
212
+ class="code-line numbered-code-line highlighted-code-line" data-line-number="2">
213
+ <span class="hljs-keyword">let</span> a2;
214
+ </span>
215
+ <span class="code-line numbered-code-line" data-line-number="3">
216
+ <span class="hljs-keyword">let</span> a3;
217
+ </span>
218
+ </code>
219
+ </pre>
220
+ ```
221
+
136
222
  ## Options
137
223
 
138
224
  All options are **optional** and have **default values**.
@@ -141,7 +227,6 @@ All options are **optional** and have **default values**.
141
227
  type HighlightLinesOptions = {
142
228
  showLineNumbers?: boolean; // default is "false"
143
229
  lineContainerTagName?: "span" | "div"; // deprecated, always span
144
- trimBlankLines?: boolean; // default is "false"
145
230
  };
146
231
 
147
232
  use(rehypeHighlightLines, HighlightLinesOptions);
@@ -159,7 +244,9 @@ use(rehypeHighlightLines, {
159
244
  });
160
245
  ```
161
246
 
162
- Now, all code blocks will become numbered. If you want to exclude a specific code block not to be numbered, use `noLineNumbers`.
247
+ Now, all code blocks will become numbered.
248
+
249
+ If you want to exclude a specific code block not to be numbered, use `noLineNumbers`.
163
250
 
164
251
  **\`\`\`[language] noLineNumbers {2}**
165
252
 
@@ -167,7 +254,15 @@ Now, all code blocks will become numbered. If you want to exclude a specific cod
167
254
 
168
255
  **\`\`\`noLineNumbers**
169
256
 
170
- Sometimes you may want to start the line numbering from a specific number. In that cases, use `showLineNumbers=[number]` in code blocks. For example, below, the code block's line numbering will start from number `8`.
257
+ If you want to exclude a specific code block not to be numbered in HTML fragment (in `<pre>`) use `no-line-numbers` class. In that case, the directive could be with dash, or without, or camel cased.
258
+
259
+ **`<code class="language-ts no-line-numbers">`**
260
+
261
+ **`<code class="language-ts nolinenumbers">`**
262
+
263
+ **`<code class="language-ts noLineNumbers">`**
264
+
265
+ Sometimes you may want to start the line numbering from a specific number. In that cases, use `showLineNumbers=[number]` in code blocks. For example, below, the code block's line numbering will start from number `8`.
171
266
 
172
267
  **\`\`\`[language] {2} showLineNumbers=8**
173
268
 
@@ -175,6 +270,10 @@ Sometimes you may want to start the line numbering from a specific number. In th
175
270
 
176
271
  **\`\`\`showLineNumbers=8**
177
272
 
273
+ If you want to start the line numbering from a specific number in HTML fragment (in `<pre>`) use `data-start-numbering` attribute.
274
+
275
+ **`<code class="..." data-start-numbering="8">`**
276
+
178
277
  #### `lineContainerTagName` (Deprecated)
179
278
 
180
279
  **It is marked as `@deprecated` and will be removed in the next versions.**
@@ -189,39 +288,6 @@ use(rehypeHighlightLines, {
189
288
  });
190
289
  ```
191
290
 
192
- #### `trimBlankLines`
193
-
194
- It is a **boolean** option. It is designed to delete one blank/empty line at the beginning and one at the end of the code block, if happened due to html parsing `<pre><code /></pre>`.
195
-
196
- By default, it is `false`.
197
-
198
- Let's assume you want to highlight `pre`, and `code` element in markdown (not code fence).
199
-
200
- ```markdown
201
- Here is markdown content
202
-
203
- <pre><code class="language-javascript">
204
- console.log("rehype-highlight-code-lines");
205
- </code></pre>
206
- ```
207
-
208
- For above markdown, the parsed result (for example via `rehype-parse` and `rehype-stringfy`) is going to contain empty/blank code lines due to nature of `pre` preserving whitespaces. In order to prevent having unintentionally blank lines, use the option `trimBlankLines`.
209
-
210
- ```javascript
211
- use(rehypeHighlightLines, {
212
- trimBlankLines: true,
213
- });
214
- ```
215
-
216
- Actually, the trimming could have been the default behaviour. However, some developers may intentionally include empty lines at the beginning and at the end in code fences for specific reasons and may want to preserve them.
217
- ````markdown
218
- ```javascript
219
-
220
- console.log("rehype-highlight-code-lines");
221
-
222
- ```
223
- ````
224
-
225
291
  ### Examples:
226
292
 
227
293
  ```typescript
@@ -2,7 +2,11 @@ import type { Plugin } from "unified";
2
2
  import type { Root } from "hast";
3
3
  declare module "hast" {
4
4
  interface Data {
5
- meta?: string | undefined;
5
+ meta?: string;
6
+ }
7
+ interface Properties {
8
+ dataStartNumbering?: string;
9
+ dataHighlightLines?: string;
6
10
  }
7
11
  }
8
12
  export type HighlightLinesOptions = {
@@ -12,7 +16,7 @@ export type HighlightLinesOptions = {
12
16
  * will be removed in the next versions
13
17
  */
14
18
  lineContainerTagName?: "div" | "span";
15
- trimBlankLines?: boolean;
19
+ keepOuterBlankLine?: boolean;
16
20
  };
17
21
  export declare function clsx(arr: (string | false | null | undefined | 0)[]): string[];
18
22
  /**
package/dist/esm/index.js CHANGED
@@ -3,7 +3,7 @@ import rangeParser from "parse-numeric-range";
3
3
  const DEFAULT_SETTINGS = {
4
4
  showLineNumbers: false,
5
5
  lineContainerTagName: "span",
6
- trimBlankLines: false,
6
+ keepOuterBlankLine: false,
7
7
  };
8
8
  // a simple util for our use case, like clsx package
9
9
  export function clsx(arr) {
@@ -88,7 +88,7 @@ const plugin = (options) => {
88
88
  * construct the line element
89
89
  *
90
90
  */
91
- const createLine = (children, lineNumber, directiveShowLineNumbers, directiveHighlightLines) => {
91
+ const createLine = (children, lineNumber, directiveLineNumbering, directiveLineHighlighting) => {
92
92
  const firstChild = children[0];
93
93
  const isAddition = hasClassName(firstChild, "addition");
94
94
  const isDeletion = hasClassName(firstChild, "deletion");
@@ -99,14 +99,14 @@ const plugin = (options) => {
99
99
  properties: {
100
100
  className: clsx([
101
101
  "code-line",
102
- directiveShowLineNumbers && "numbered-code-line",
103
- directiveHighlightLines.includes(lineNumber) && "highlighted-code-line",
102
+ (directiveLineNumbering || directiveLineNumbering === 0) && "numbered-code-line",
103
+ directiveLineHighlighting.includes(lineNumber) && "highlighted-code-line",
104
104
  isAddition && "inserted",
105
105
  isDeletion && "deleted",
106
106
  ]),
107
- dataLineNumber: typeof directiveShowLineNumbers === "number"
108
- ? directiveShowLineNumbers - 1 + lineNumber
109
- : directiveShowLineNumbers
107
+ dataLineNumber: typeof directiveLineNumbering === "number"
108
+ ? directiveLineNumbering - 1 + lineNumber
109
+ : directiveLineNumbering
110
110
  ? lineNumber
111
111
  : undefined,
112
112
  },
@@ -165,30 +165,14 @@ const plugin = (options) => {
165
165
  }
166
166
  /**
167
167
  *
168
- * handle trimming blank line for the last text node
169
- *
170
- */
171
- function handleTrimmingBlankLines(code, directiveTrimBlankLines) {
172
- if (!directiveTrimBlankLines)
173
- return;
174
- const lastChild = code.children[code.children.length - 1];
175
- if (lastChild.type === "text") {
176
- if (/(\r?\n|\r)(\1)$/.test(lastChild.value)) {
177
- lastChild.value = lastChild.value.replace(/(\r?\n|\r)(\1)$/, "$1");
178
- }
179
- }
180
- }
181
- /**
182
- *
183
- * extract the lines from HAST of code element
168
+ * finds the code lines from HAST of code element and costructs the lines
184
169
  * mutates the code
185
170
  *
186
171
  */
187
- function gutter(code, { directiveShowLineNumbers, directiveHighlightLines, directiveTrimBlankLines, }) {
188
- hasFlatteningNeed(code) && flattenCodeTree(code); // mutates the code
189
- handleFirstElementContent(code); // mutates the code
190
- handleMultiLineComments(code); // mutates the code
191
- handleTrimmingBlankLines(code, directiveTrimBlankLines);
172
+ function gutter(code, { directiveLineNumbering, directiveLineHighlighting, directiveKeepOuterBlankLine, }) {
173
+ hasFlatteningNeed(code) && flattenCodeTree(code);
174
+ handleFirstElementContent(code);
175
+ handleMultiLineComments(code);
192
176
  const replacement = [];
193
177
  let start = 0;
194
178
  let startTextRemainder = "";
@@ -199,7 +183,7 @@ const plugin = (options) => {
199
183
  continue;
200
184
  let textStart = 0;
201
185
  const matches = Array.from(child.value.matchAll(REGEX_LINE_BREAKS));
202
- matches.forEach((match, iteration) => {
186
+ for (const [iteration, match] of matches.entries()) {
203
187
  // Nodes in this line. (current child (index) is exclusive)
204
188
  const line = code.children.slice(start, index);
205
189
  // Prepend text from a partial matched earlier text.
@@ -209,35 +193,42 @@ const plugin = (options) => {
209
193
  }
210
194
  // Append text from this text.
211
195
  if (match.index > textStart) {
212
- const value = child.value.slice(textStart, match.index);
213
- line.push({ type: "text", value });
196
+ line.push({ type: "text", value: child.value.slice(textStart, match.index) });
214
197
  }
215
198
  const isFirstIteration = index === 0 && iteration === 0;
216
- if (isFirstIteration && directiveTrimBlankLines && line.length === 0) {
199
+ const isLastIteration = index === code.children.length - 1 && iteration === matches.length - 1;
200
+ if (isFirstIteration && !directiveKeepOuterBlankLine && line.length === 0) {
217
201
  replacement.push({ type: "text", value: match[0] }); // eol
218
202
  }
203
+ else if (isLastIteration && !directiveKeepOuterBlankLine && line.length === 0) {
204
+ const lastReplacement = replacement[replacement.length - 1];
205
+ if (!(lastReplacement.type === "text" && lastReplacement.value === match[0]))
206
+ /* v8 ignore next */
207
+ replacement.push({ type: "text", value: match[0] }); // eol
208
+ }
219
209
  else {
220
- lineNumber += 1;
221
- replacement.push(createLine(line, lineNumber, directiveShowLineNumbers, directiveHighlightLines), { type: "text", value: match[0] });
210
+ replacement.push(createLine(line, ++lineNumber, directiveLineNumbering, directiveLineHighlighting), { type: "text", value: match[0] });
222
211
  }
223
212
  start = index + 1;
224
213
  textStart = match.index + match[0].length;
225
- });
214
+ }
226
215
  // If we matched, make sure to not drop the text after the last line ending.
227
216
  if (start === index + 1) {
228
217
  startTextRemainder = child.value.slice(textStart);
229
218
  }
230
219
  }
231
- const line = code.children.slice(start);
220
+ const remainingLine = code.children.slice(start);
232
221
  // Prepend text from a partial matched earlier text.
233
222
  if (startTextRemainder) {
234
- line.unshift({ type: "text", value: startTextRemainder });
235
- startTextRemainder = "";
223
+ remainingLine.unshift({ type: "text", value: startTextRemainder });
236
224
  }
237
- if (line.length > 0) {
238
- directiveTrimBlankLines
239
- ? replacement.push(...line)
240
- : replacement.push(createLine(line, ++lineNumber, directiveShowLineNumbers, directiveHighlightLines));
225
+ if (remainingLine.length > 0) {
226
+ if (remainingLine[0].type === "text" && remainingLine[0].value.trim() === "") {
227
+ replacement.push(...remainingLine);
228
+ }
229
+ else {
230
+ replacement.push(createLine(remainingLine, ++lineNumber, directiveLineNumbering, directiveLineHighlighting));
231
+ }
241
232
  }
242
233
  // Replace children with new array.
243
234
  code.children = replacement;
@@ -273,50 +264,96 @@ const plugin = (options) => {
273
264
  if (parent.type !== "element" || parent.tagName !== "pre") {
274
265
  return;
275
266
  }
276
- const classNames = code.properties.className;
277
- // only for type narrowing
278
- /* v8 ignore next */
279
- if (!isStringArray(classNames) && classNames !== undefined)
267
+ // for type narrowing
268
+ if (!isStringArray(code.properties.className) &&
269
+ code.properties.className !== undefined
270
+ /* v8 ignore next 3 */
271
+ ) {
280
272
  return;
273
+ }
274
+ /** the part of correcting language and meta */
281
275
  let meta = code.data?.meta?.toLowerCase().trim() ?? "";
282
- const language = getLanguage(classNames);
283
- if (language?.startsWith("{") ||
284
- language?.startsWith("showlinenumbers") ||
285
- language?.startsWith("nolinenumbers") ||
286
- language?.startsWith("trimblanklines")) {
276
+ const language = getLanguage(code.properties.className);
277
+ if (language &&
278
+ (language.startsWith("{") ||
279
+ language.startsWith("showlinenumbers") ||
280
+ language.startsWith("nolinenumbers") ||
281
+ language.startsWith("keepouterblankline"))) {
287
282
  // add specifiers to meta
288
283
  meta = (language + " " + meta).trim();
289
284
  // correct the code's meta
290
- code.data && (code.data.meta = meta);
285
+ code.data && (code.data.meta = (language + " " + code.data.meta).trim());
291
286
  // remove all classnames like hljs, lang-{1,3}, language-showLineNumbers, because of false positive
292
287
  code.properties.className = undefined;
293
288
  }
294
- let directiveShowLineNumbers = meta.includes("nolinenumbers")
289
+ const keywords = ["showlinenumbers", "nolinenumbers", "keepouterblankline"];
290
+ const classNames = code.properties.className
291
+ ?.map((cls) => cls.toLowerCase().replaceAll("-", ""))
292
+ .filter((cls) => keywords.includes(cls));
293
+ /** the part of defining the directive for line numbering */
294
+ const directiveNoLineNumbers = meta.includes("nolinenumbers") || Boolean(classNames?.includes("nolinenumbers"));
295
+ const directiveShowLineNumbers = settings.showLineNumbers ||
296
+ meta.includes("showlinenumbers") ||
297
+ Boolean(classNames?.includes("showlinenumbers"));
298
+ let directiveLineNumbering = directiveNoLineNumbers
295
299
  ? false
296
- : settings.showLineNumbers || meta.includes("showlinenumbers");
300
+ : directiveShowLineNumbers;
297
301
  // find the number where the line number starts, if exists
298
- const REGEX1 = /showlinenumbers=(?<start>\d+)/i;
302
+ const REGEX1 = /showlinenumbers=(?<start>\d+)/;
299
303
  const start = REGEX1.exec(meta)?.groups?.start;
300
- if (start && !isNaN(Number(start)))
301
- directiveShowLineNumbers = Number(start);
304
+ if (!directiveNoLineNumbers && !isNaN(Number(start))) {
305
+ directiveLineNumbering = Number(start);
306
+ }
307
+ // get the number where the line number starts, if exists
308
+ const { dataStartNumbering } = code.properties;
309
+ if ("dataStartNumbering" in code.properties) {
310
+ code.properties["dataStartNumbering"] = undefined;
311
+ }
312
+ if (!directiveNoLineNumbers &&
313
+ dataStartNumbering !== "" &&
314
+ !isNaN(Number(dataStartNumbering))) {
315
+ directiveLineNumbering = Number(dataStartNumbering);
316
+ }
317
+ /** the part of defining the directive for line highlighting */
302
318
  // find number range string within curly braces and parse it
303
- const REGEX2 = /{(?<lines>[\d\s,-]+)}/g;
319
+ const directiveLineHighlighting = [];
320
+ const REGEX2 = /{(?<lines>[\d\s,-]+)}/;
304
321
  const strLineNumbers = REGEX2.exec(meta)?.groups?.lines?.replace(/\s/g, "");
305
- const directiveHighlightLines = strLineNumbers ? rangeParser(strLineNumbers) : [];
322
+ if (strLineNumbers) {
323
+ const range = rangeParser(strLineNumbers);
324
+ directiveLineHighlighting.push(...range);
325
+ }
326
+ // get number range string within properties and parse it
327
+ const { dataHighlightLines } = code.properties;
328
+ if ("dataHighlightLines" in code.properties) {
329
+ code.properties["dataHighlightLines"] = undefined;
330
+ }
331
+ if (dataHighlightLines) {
332
+ const range = rangeParser(dataHighlightLines.replace(/\s/g, ""));
333
+ directiveLineHighlighting.push(...range);
334
+ }
335
+ /** the part of defining the directive for line trimming */
306
336
  // find the directive for trimming blank lines
307
- const REGEX3 = /trimblanklines/i;
308
- const directiveTrimBlankLines = settings.trimBlankLines || REGEX3.test(meta);
309
- // if nothing to do for numbering, highlihting or trimming blank lines, just return;
310
- if (directiveShowLineNumbers === false &&
311
- directiveHighlightLines.length === 0 &&
312
- directiveTrimBlankLines === false) {
337
+ const directiveKeepOuterBlankLine = settings.keepOuterBlankLine ||
338
+ /keepouterblankline/.test(meta) ||
339
+ Boolean(classNames?.includes("keepouterblankline"));
340
+ /** the part of cleaning of code properties */
341
+ code.properties.className = code.properties.className?.filter((cls) => !keywords.includes(cls.toLowerCase().replaceAll("-", "")));
342
+ if (isStringArray(code.properties.className) && code.properties.className.length === 0) {
343
+ code.properties.className = undefined;
344
+ }
345
+ // if nothing to do for numbering, highlihting or trimming, just return;
346
+ if (directiveLineNumbering === false &&
347
+ directiveLineHighlighting.length === 0
348
+ // directiveKeepOuterBlankLine === false
349
+ ) {
313
350
  return;
314
351
  }
315
352
  // add container for each line mutating the code element
316
353
  gutter(code, {
317
- directiveShowLineNumbers,
318
- directiveHighlightLines,
319
- directiveTrimBlankLines,
354
+ directiveLineNumbering,
355
+ directiveLineHighlighting,
356
+ directiveKeepOuterBlankLine,
320
357
  });
321
358
  });
322
359
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAsB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,WAAW,MAAM,qBAAqB,CAAC;AA0B9C,MAAM,gBAAgB,GAA0B;IAC9C,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,MAAM;IAC5B,cAAc,EAAE,KAAK;CACtB,CAAC;AAYF,oDAAoD;AACpD,MAAM,UAAU,IAAI,CAAC,GAA8C;IACjE,OAAO,GAAG,CAAC,MAAM,CAAC,CAA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yB,CAAC,MAAM,KAAK,CAAC;YACtC,wCAAwC;cACxC,CAAC;gBACD,OAAO;YACT,CAAC;YAED,wDAAwD;YACxD,MAAM,CAAC,IAAI,EAAE;gBACX,sBAAsB;gBACtB,yBAAyB;gBACzB,2BAA2B;aAC5B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rehype-highlight-code-lines",
3
- "version": "1.0.10",
3
+ "version": "1.1.0",
4
4
  "description": "Rehype plugin to add line numbers to code blocks and allow highlighting of desired code lines",
5
5
  "type": "module",
6
6
  "exports": "./dist/esm/index.js",
@@ -17,6 +17,8 @@
17
17
  "test:file2": "vitest test.html.spec.ts",
18
18
  "test:file3": "vitest test.cases.spec.ts",
19
19
  "test:file4": "vitest from-rehype-highlight/test.rhcl2.spec.ts",
20
+ "test:file5": "vitest test.raw.spec.ts",
21
+ "test:file6": "vitest test.debug.spec.ts",
20
22
  "prepack": "npm run build",
21
23
  "prepublishOnly": "npm run test && npm run format && npm run test-coverage",
22
24
  "test-coverage": "vitest run --coverage"
@@ -56,17 +58,18 @@
56
58
  "devDependencies": {
57
59
  "@eslint/js": "^9.20.0",
58
60
  "@types/dedent": "^0.7.2",
59
- "@types/node": "^22.13.1",
61
+ "@types/node": "^22.13.2",
60
62
  "@vitest/coverage-v8": "^3.0.5",
61
- "@vitest/eslint-plugin": "^1.1.27",
63
+ "@vitest/eslint-plugin": "^1.1.31",
62
64
  "dedent": "^1.5.3",
63
- "eslint": "^9.20.0",
65
+ "eslint": "^9.20.1",
64
66
  "eslint-config-prettier": "^10.0.1",
65
67
  "eslint-plugin-prettier": "^5.2.3",
66
68
  "prettier": "^3.5.0",
67
69
  "rehype": "^13.0.2",
68
70
  "rehype-highlight": "^7.0.2",
69
71
  "rehype-parse": "^9.0.1",
72
+ "rehype-raw": "^7.0.0",
70
73
  "rehype-stringify": "^10.0.1",
71
74
  "remark-gfm": "^4.0.0",
72
75
  "remark-parse": "^11.0.0",
@@ -74,11 +77,11 @@
74
77
  "rimraf": "^5.0.10",
75
78
  "type-coverage": "^2.29.7",
76
79
  "typescript": "^5.7.3",
77
- "typescript-eslint": "^8.23.0",
80
+ "typescript-eslint": "^8.24.0",
81
+ "unified": "^11.0.5",
78
82
  "unist-util-remove-position": "^5.0.0",
79
83
  "vfile": "^6.0.3",
80
- "vitest": "^3.0.5",
81
- "unified": "^11.0.5"
84
+ "vitest": "^3.0.5"
82
85
  },
83
86
  "dependencies": {
84
87
  "@types/hast": "^3.0.4",
package/src/index.ts CHANGED
@@ -9,7 +9,11 @@ type PartiallyRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
9
9
 
10
10
  declare module "hast" {
11
11
  interface Data {
12
- meta?: string | undefined;
12
+ meta?: string;
13
+ }
14
+ interface Properties {
15
+ dataStartNumbering?: string;
16
+ dataHighlightLines?: string;
13
17
  }
14
18
  }
15
19
 
@@ -24,13 +28,13 @@ export type HighlightLinesOptions = {
24
28
  * will be removed in the next versions
25
29
  */
26
30
  lineContainerTagName?: "div" | "span";
27
- trimBlankLines?: boolean;
31
+ keepOuterBlankLine?: boolean;
28
32
  };
29
33
 
30
34
  const DEFAULT_SETTINGS: HighlightLinesOptions = {
31
35
  showLineNumbers: false,
32
36
  lineContainerTagName: "span",
33
- trimBlankLines: false,
37
+ keepOuterBlankLine: false,
34
38
  };
35
39
 
36
40
  type PartiallyRequiredHighlightLinesOptions = Prettify<
@@ -38,9 +42,9 @@ type PartiallyRequiredHighlightLinesOptions = Prettify<
38
42
  >;
39
43
 
40
44
  type GutterOptions = {
41
- directiveShowLineNumbers: boolean | number;
42
- directiveHighlightLines: number[];
43
- directiveTrimBlankLines: boolean;
45
+ directiveLineNumbering: boolean | number;
46
+ directiveLineHighlighting: number[];
47
+ directiveKeepOuterBlankLine: boolean;
44
48
  };
45
49
 
46
50
  // a simple util for our use case, like clsx package
@@ -150,8 +154,8 @@ const plugin: Plugin<[HighlightLinesOptions?], Root> = (options) => {
150
154
  const createLine = (
151
155
  children: ElementContent[],
152
156
  lineNumber: number,
153
- directiveShowLineNumbers: boolean | number,
154
- directiveHighlightLines: number[],
157
+ directiveLineNumbering: boolean | number,
158
+ directiveLineHighlighting: number[],
155
159
  ): Element => {
156
160
  const firstChild = children[0];
157
161
  const isAddition = hasClassName(firstChild, "addition");
@@ -164,15 +168,15 @@ const plugin: Plugin<[HighlightLinesOptions?], Root> = (options) => {
164
168
  properties: {
165
169
  className: clsx([
166
170
  "code-line",
167
- directiveShowLineNumbers && "numbered-code-line",
168
- directiveHighlightLines.includes(lineNumber) && "highlighted-code-line",
171
+ (directiveLineNumbering || directiveLineNumbering === 0) && "numbered-code-line",
172
+ directiveLineHighlighting.includes(lineNumber) && "highlighted-code-line",
169
173
  isAddition && "inserted",
170
174
  isDeletion && "deleted",
171
175
  ]),
172
176
  dataLineNumber:
173
- typeof directiveShowLineNumbers === "number"
174
- ? directiveShowLineNumbers - 1 + lineNumber
175
- : directiveShowLineNumbers
177
+ typeof directiveLineNumbering === "number"
178
+ ? directiveLineNumbering - 1 + lineNumber
179
+ : directiveLineNumbering
176
180
  ? lineNumber
177
181
  : undefined,
178
182
  },
@@ -240,58 +244,36 @@ const plugin: Plugin<[HighlightLinesOptions?], Root> = (options) => {
240
244
 
241
245
  /**
242
246
  *
243
- * handle trimming blank line for the last text node
244
- *
245
- */
246
- function handleTrimmingBlankLines(code: Element, directiveTrimBlankLines: boolean) {
247
- if (!directiveTrimBlankLines) return;
248
-
249
- const lastChild = code.children[code.children.length - 1];
250
-
251
- if (lastChild.type === "text") {
252
- if (/(\r?\n|\r)(\1)$/.test(lastChild.value)) {
253
- lastChild.value = lastChild.value.replace(/(\r?\n|\r)(\1)$/, "$1");
254
- }
255
- }
256
- }
257
-
258
- /**
259
- *
260
- * extract the lines from HAST of code element
247
+ * finds the code lines from HAST of code element and costructs the lines
261
248
  * mutates the code
262
249
  *
263
250
  */
264
251
  function gutter(
265
252
  code: Element,
266
253
  {
267
- directiveShowLineNumbers,
268
- directiveHighlightLines,
269
- directiveTrimBlankLines,
254
+ directiveLineNumbering,
255
+ directiveLineHighlighting,
256
+ directiveKeepOuterBlankLine,
270
257
  }: GutterOptions,
271
258
  ) {
272
- hasFlatteningNeed(code) && flattenCodeTree(code); // mutates the code
273
-
274
- handleFirstElementContent(code); // mutates the code
275
-
276
- handleMultiLineComments(code); // mutates the code
259
+ hasFlatteningNeed(code) && flattenCodeTree(code);
277
260
 
278
- handleTrimmingBlankLines(code, directiveTrimBlankLines);
261
+ handleFirstElementContent(code);
262
+ handleMultiLineComments(code);
279
263
 
280
264
  const replacement: ElementContent[] = [];
281
-
282
265
  let start = 0;
283
266
  let startTextRemainder = "";
284
267
  let lineNumber = 0;
285
268
 
286
269
  for (let index = 0; index < code.children.length; index++) {
287
270
  const child = code.children[index];
288
-
289
271
  if (child.type !== "text") continue;
290
272
 
291
273
  let textStart = 0;
292
-
293
274
  const matches = Array.from(child.value.matchAll(REGEX_LINE_BREAKS));
294
- matches.forEach((match, iteration) => {
275
+
276
+ for (const [iteration, match] of matches.entries()) {
295
277
  // Nodes in this line. (current child (index) is exclusive)
296
278
  const line = code.children.slice(start, index);
297
279
 
@@ -303,25 +285,30 @@ const plugin: Plugin<[HighlightLinesOptions?], Root> = (options) => {
303
285
 
304
286
  // Append text from this text.
305
287
  if (match.index > textStart) {
306
- const value = child.value.slice(textStart, match.index);
307
- line.push({ type: "text", value });
288
+ line.push({ type: "text", value: child.value.slice(textStart, match.index) });
308
289
  }
309
290
 
310
291
  const isFirstIteration = index === 0 && iteration === 0;
292
+ const isLastIteration =
293
+ index === code.children.length - 1 && iteration === matches.length - 1;
311
294
 
312
- if (isFirstIteration && directiveTrimBlankLines && line.length === 0) {
295
+ if (isFirstIteration && !directiveKeepOuterBlankLine && line.length === 0) {
313
296
  replacement.push({ type: "text", value: match[0] }); // eol
297
+ } else if (isLastIteration && !directiveKeepOuterBlankLine && line.length === 0) {
298
+ const lastReplacement = replacement[replacement.length - 1];
299
+ if (!(lastReplacement.type === "text" && lastReplacement.value === match[0]))
300
+ /* v8 ignore next */
301
+ replacement.push({ type: "text", value: match[0] }); // eol
314
302
  } else {
315
- lineNumber += 1;
316
303
  replacement.push(
317
- createLine(line, lineNumber, directiveShowLineNumbers, directiveHighlightLines),
304
+ createLine(line, ++lineNumber, directiveLineNumbering, directiveLineHighlighting),
318
305
  { type: "text", value: match[0] }, // eol
319
306
  );
320
307
  }
321
308
 
322
309
  start = index + 1;
323
310
  textStart = match.index + match[0].length;
324
- });
311
+ }
325
312
 
326
313
  // If we matched, make sure to not drop the text after the last line ending.
327
314
  if (start === index + 1) {
@@ -329,20 +316,26 @@ const plugin: Plugin<[HighlightLinesOptions?], Root> = (options) => {
329
316
  }
330
317
  }
331
318
 
332
- const line = code.children.slice(start);
319
+ const remainingLine = code.children.slice(start);
333
320
 
334
321
  // Prepend text from a partial matched earlier text.
335
322
  if (startTextRemainder) {
336
- line.unshift({ type: "text", value: startTextRemainder });
337
- startTextRemainder = "";
323
+ remainingLine.unshift({ type: "text", value: startTextRemainder });
338
324
  }
339
325
 
340
- if (line.length > 0) {
341
- directiveTrimBlankLines
342
- ? replacement.push(...line)
343
- : replacement.push(
344
- createLine(line, ++lineNumber, directiveShowLineNumbers, directiveHighlightLines),
345
- );
326
+ if (remainingLine.length > 0) {
327
+ if (remainingLine[0].type === "text" && remainingLine[0].value.trim() === "") {
328
+ replacement.push(...remainingLine);
329
+ } else {
330
+ replacement.push(
331
+ createLine(
332
+ remainingLine,
333
+ ++lineNumber,
334
+ directiveLineNumbering,
335
+ directiveLineHighlighting,
336
+ ),
337
+ );
338
+ }
346
339
  }
347
340
 
348
341
  // Replace children with new array.
@@ -387,64 +380,135 @@ const plugin: Plugin<[HighlightLinesOptions?], Root> = (options) => {
387
380
  return;
388
381
  }
389
382
 
390
- const classNames = code.properties.className;
383
+ // for type narrowing
384
+ if (
385
+ !isStringArray(code.properties.className) &&
386
+ code.properties.className !== undefined
387
+ /* v8 ignore next 3 */
388
+ ) {
389
+ return;
390
+ }
391
391
 
392
- // only for type narrowing
393
- /* v8 ignore next */
394
- if (!isStringArray(classNames) && classNames !== undefined) return;
392
+ /** the part of correcting language and meta */
395
393
 
396
394
  let meta = code.data?.meta?.toLowerCase().trim() ?? "";
397
395
 
398
- const language = getLanguage(classNames);
396
+ const language = getLanguage(code.properties.className);
399
397
 
400
398
  if (
401
- language?.startsWith("{") ||
402
- language?.startsWith("showlinenumbers") ||
403
- language?.startsWith("nolinenumbers") ||
404
- language?.startsWith("trimblanklines")
399
+ language &&
400
+ (language.startsWith("{") ||
401
+ language.startsWith("showlinenumbers") ||
402
+ language.startsWith("nolinenumbers") ||
403
+ language.startsWith("keepouterblankline"))
405
404
  ) {
406
405
  // add specifiers to meta
407
406
  meta = (language + " " + meta).trim();
408
407
 
409
408
  // correct the code's meta
410
- code.data && (code.data.meta = meta);
409
+ code.data && (code.data.meta = (language + " " + code.data.meta).trim());
411
410
 
412
411
  // remove all classnames like hljs, lang-{1,3}, language-showLineNumbers, because of false positive
413
412
  code.properties.className = undefined;
414
413
  }
415
414
 
416
- let directiveShowLineNumbers: boolean | number = meta.includes("nolinenumbers")
415
+ const keywords = ["showlinenumbers", "nolinenumbers", "keepouterblankline"];
416
+
417
+ const classNames = code.properties.className
418
+ ?.map((cls) => cls.toLowerCase().replaceAll("-", ""))
419
+ .filter((cls) => keywords.includes(cls));
420
+
421
+ /** the part of defining the directive for line numbering */
422
+
423
+ const directiveNoLineNumbers =
424
+ meta.includes("nolinenumbers") || Boolean(classNames?.includes("nolinenumbers"));
425
+
426
+ const directiveShowLineNumbers =
427
+ settings.showLineNumbers ||
428
+ meta.includes("showlinenumbers") ||
429
+ Boolean(classNames?.includes("showlinenumbers"));
430
+
431
+ let directiveLineNumbering: boolean | number = directiveNoLineNumbers
417
432
  ? false
418
- : settings.showLineNumbers || meta.includes("showlinenumbers");
433
+ : directiveShowLineNumbers;
419
434
 
420
435
  // find the number where the line number starts, if exists
421
- const REGEX1 = /showlinenumbers=(?<start>\d+)/i;
436
+ const REGEX1 = /showlinenumbers=(?<start>\d+)/;
422
437
  const start = REGEX1.exec(meta)?.groups?.start;
423
- if (start && !isNaN(Number(start))) directiveShowLineNumbers = Number(start);
438
+
439
+ if (!directiveNoLineNumbers && !isNaN(Number(start))) {
440
+ directiveLineNumbering = Number(start);
441
+ }
442
+
443
+ // get the number where the line number starts, if exists
444
+ const { dataStartNumbering } = code.properties;
445
+ if ("dataStartNumbering" in code.properties) {
446
+ code.properties["dataStartNumbering"] = undefined;
447
+ }
448
+
449
+ if (
450
+ !directiveNoLineNumbers &&
451
+ dataStartNumbering !== "" &&
452
+ !isNaN(Number(dataStartNumbering))
453
+ ) {
454
+ directiveLineNumbering = Number(dataStartNumbering);
455
+ }
456
+
457
+ /** the part of defining the directive for line highlighting */
424
458
 
425
459
  // find number range string within curly braces and parse it
426
- const REGEX2 = /{(?<lines>[\d\s,-]+)}/g;
460
+ const directiveLineHighlighting: number[] = [];
461
+ const REGEX2 = /{(?<lines>[\d\s,-]+)}/;
427
462
  const strLineNumbers = REGEX2.exec(meta)?.groups?.lines?.replace(/\s/g, "");
428
- const directiveHighlightLines = strLineNumbers ? rangeParser(strLineNumbers) : [];
463
+
464
+ if (strLineNumbers) {
465
+ const range = rangeParser(strLineNumbers);
466
+ directiveLineHighlighting.push(...range);
467
+ }
468
+
469
+ // get number range string within properties and parse it
470
+ const { dataHighlightLines } = code.properties;
471
+ if ("dataHighlightLines" in code.properties) {
472
+ code.properties["dataHighlightLines"] = undefined;
473
+ }
474
+
475
+ if (dataHighlightLines) {
476
+ const range = rangeParser(dataHighlightLines.replace(/\s/g, ""));
477
+ directiveLineHighlighting.push(...range);
478
+ }
479
+
480
+ /** the part of defining the directive for line trimming */
429
481
 
430
482
  // find the directive for trimming blank lines
431
- const REGEX3 = /trimblanklines/i;
432
- const directiveTrimBlankLines = settings.trimBlankLines || REGEX3.test(meta);
483
+ const directiveKeepOuterBlankLine =
484
+ settings.keepOuterBlankLine ||
485
+ /keepouterblankline/.test(meta) ||
486
+ Boolean(classNames?.includes("keepouterblankline"));
487
+
488
+ /** the part of cleaning of code properties */
489
+
490
+ code.properties.className = code.properties.className?.filter(
491
+ (cls) => !keywords.includes(cls.toLowerCase().replaceAll("-", "")),
492
+ );
493
+
494
+ if (isStringArray(code.properties.className) && code.properties.className.length === 0) {
495
+ code.properties.className = undefined;
496
+ }
433
497
 
434
- // if nothing to do for numbering, highlihting or trimming blank lines, just return;
498
+ // if nothing to do for numbering, highlihting or trimming, just return;
435
499
  if (
436
- directiveShowLineNumbers === false &&
437
- directiveHighlightLines.length === 0 &&
438
- directiveTrimBlankLines === false
500
+ directiveLineNumbering === false &&
501
+ directiveLineHighlighting.length === 0
502
+ // directiveKeepOuterBlankLine === false
439
503
  ) {
440
504
  return;
441
505
  }
442
506
 
443
507
  // add container for each line mutating the code element
444
508
  gutter(code, {
445
- directiveShowLineNumbers,
446
- directiveHighlightLines,
447
- directiveTrimBlankLines,
509
+ directiveLineNumbering,
510
+ directiveLineHighlighting,
511
+ directiveKeepOuterBlankLine,
448
512
  });
449
513
  });
450
514
  };