markdown-it-adv-table 0.2.0 → 0.2.2

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.
@@ -13,7 +13,7 @@ export class TableBuilder {
13
13
  return new TableBuilder(new state.md.block.State("", state.md, state.env, []), tableSpec);
14
14
  }
15
15
  get useColgroup() {
16
- return this.tableSpec.attr.cols?.startsWith("\"");
16
+ return this.tableSpec.colspecs.finemode;
17
17
  }
18
18
  get useTHead() {
19
19
  return this.tableSpec.headerRows > 0;
@@ -64,9 +64,6 @@ export class TableBuilder {
64
64
  if (this.useTHead && row === 0) {
65
65
  this.startTHead();
66
66
  }
67
- else if (this.useTBody && row === this.tableSpec.headerRows) {
68
- this.startTBody();
69
- }
70
67
  this.startRow();
71
68
  }
72
69
  const token = this.state.push(`${tx}_open`, tx, 1);
@@ -85,6 +82,7 @@ export class TableBuilder {
85
82
  this.endRow();
86
83
  if (this.useTHead && row == this.tableSpec.headerRows - 1) {
87
84
  this.endTHead();
85
+ this.startTBody();
88
86
  }
89
87
  }
90
88
  }
package/lib/table.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare class TableSpec {
37
37
  export declare class ColSpecs {
38
38
  readonly numCols: number;
39
39
  readonly specs: readonly ColumnAttr[];
40
+ readonly finemode: boolean;
40
41
  constructor(colspec: string);
41
42
  colSpec(col: number): ColumnAttr;
42
43
  colWidth(col: number): ColWidth;
package/lib/table.js CHANGED
@@ -64,26 +64,23 @@ export class TableSpec {
64
64
  static parseInfoString(info) {
65
65
  const lexer = new Lexer(info);
66
66
  const tokens = [];
67
- const wordRe = /^[a-zA-Z][a-zA-Z0-9_\-]+/;
67
+ const anyRe = /^[^\"=\s]*/;
68
68
  const result = {};
69
69
  let cp = 0;
70
70
  while (cp != Lexer.EOF) {
71
71
  lexer.skipWhitespace();
72
72
  cp = lexer.peek();
73
- if (Lexer.isAlphabet(cp)) {
74
- tokens.push(lexer.consumeRe(wordRe));
73
+ if (Lexer.cmp(cp, "=")) {
74
+ tokens.push(lexer.consume());
75
75
  }
76
76
  else if (Lexer.cmp(cp, "\"")) {
77
77
  tokens.push(lexer.consumeLiteral("\""));
78
78
  }
79
- else if (Lexer.cmp(cp, "=")) {
80
- tokens.push(lexer.consume());
81
- }
82
79
  else if (Lexer.isEOF(cp)) {
83
80
  break;
84
81
  }
85
82
  else {
86
- tokens.push(lexer.consume());
83
+ tokens.push(lexer.consumeRe(anyRe));
87
84
  }
88
85
  }
89
86
  ;
@@ -95,7 +92,7 @@ export class TableSpec {
95
92
  const key = consume();
96
93
  consume("=");
97
94
  const value = consume();
98
- result[key] = value;
95
+ result[key] = unwrapLiteral(value, "\"");
99
96
  }
100
97
  else {
101
98
  consume();
@@ -127,11 +124,13 @@ export class TableSpec {
127
124
  export class ColSpecs {
128
125
  numCols;
129
126
  specs;
127
+ finemode = false;
130
128
  constructor(colspec) {
131
129
  if (colspec.startsWith("\"") || colspec.includes(",")) {
132
130
  const specs = unwrapLiteral(colspec, "\"").split(",");
133
131
  this.numCols = Math.max(1, specs.length);
134
132
  this.specs = specs.map(ColSpecs.parseColSpec);
133
+ this.finemode = true;
135
134
  }
136
135
  else if (/^\d+/.test(colspec)) {
137
136
  this.numCols = Math.max(1, parseInt(colspec, 10));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-it-adv-table",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Markdown syntax extension for better table support",
5
5
  "keywords": [
6
6
  "markdown",