pantsdown 1.6.0 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantsdown",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "author": "wallpants",
5
5
  "description": "Markdown to 'GitHub HTML' parser",
6
6
  "license": "MIT",
package/src/lexer.ts CHANGED
@@ -57,7 +57,7 @@ export class Lexer {
57
57
  const tokenLines = rawToken.split("\n");
58
58
  const sourceMap: SourceMap = [this.line, (this.line += tokenLines.length - 1)];
59
59
 
60
- while (tokenLines.slice(-1)[0] === "") {
60
+ while (tokenLines[tokenLines.length - 1] === "") {
61
61
  // token.raw sometimes includes newline chars at the end of the string
62
62
  // which we don't want to include in the sourceMap
63
63
  tokenLines.pop();
package/src/tokenizer.ts CHANGED
@@ -283,19 +283,25 @@ export class Tokenizer {
283
283
  loose: false,
284
284
  text: itemContents,
285
285
  tokens: [],
286
+ sourceMap: this.lexer.getSourceMap(raw),
286
287
  });
287
288
 
288
289
  list.raw += raw;
289
290
  }
290
291
 
291
292
  // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
292
- list.items[list.items.length - 1]!.raw = raw.trimEnd();
293
+ const lastTrimmed = raw.trimEnd();
294
+
295
+ if (list.items[list.items.length - 1]!.sourceMap) {
296
+ this.lexer.line -= raw.length - lastTrimmed.length;
297
+ }
298
+
299
+ list.items[list.items.length - 1]!.raw = lastTrimmed;
293
300
  list.items[list.items.length - 1]!.text = itemContents.trimEnd();
294
301
  list.raw = list.raw.trimEnd();
295
302
 
296
303
  // Item child tokens handled here at end because we needed to have the final item to trim it first
297
304
  for (let i = 0, listItemsLen = list.items.length; i < listItemsLen; i++) {
298
- list.items[i]!.sourceMap = this.lexer.getSourceMap(list.items[i]!.raw);
299
305
  this.lexer.state.top = false;
300
306
  list.items[i]!.tokens = this.lexer.blockTokens(list.items[i]!.text, []);
301
307
 
package/src/types.ts CHANGED
@@ -72,7 +72,7 @@ export interface Tokens extends Record<string, BaseToken> {
72
72
  checked?: boolean | undefined;
73
73
  loose: boolean;
74
74
  tokens: Token[];
75
- sourceMap?: SourceMap;
75
+ sourceMap: SourceMap;
76
76
  };
77
77
  Paragraph: {
78
78
  type: "paragraph";
package/bunfig.toml DELETED
@@ -1,2 +0,0 @@
1
- [test]
2
- preload = "./tests/happydom.ts"