@markdoc/markdoc
Advanced tools
Comparing version 0.3.4 to 0.3.5
{ | ||
"name": "@markdoc/markdoc", | ||
"author": "Ryan Paul", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "A text markup language for documentation", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -379,6 +379,6 @@ import { diff } from 'jest-diff'; | ||
const expected = ` | ||
| Syntax | Description | | ||
| ----------- | ----------- | | ||
| Header | Title | | ||
| Paragraph | Text | | ||
| Syntax | Description | | ||
| --------- | ----------- | | ||
| Header | Title | | ||
| Paragraph | Text | | ||
@@ -385,0 +385,0 @@ {% table %} |
@@ -385,16 +385,24 @@ import Ast from './ast'; | ||
} else { | ||
yield NL; | ||
const widths: number[] = []; | ||
for (const row of table) { | ||
for (let i = 0; i < row.length; i++) { | ||
widths[i] = widths[i] | ||
? Math.max(widths[i], row[i].length) | ||
: row[i].length; | ||
} | ||
} | ||
const [head, ...rows] = table as string[][]; | ||
const ml = table | ||
.map((arr) => arr.map((s: string) => s.length).reduce(max)) | ||
.reduce(max); | ||
yield* formatTableRow(head.map((h) => h + SPACE.repeat(ml - h.length))); | ||
yield NL; | ||
yield* formatTableRow(head.map(() => '-'.repeat(ml))); | ||
yield* formatTableRow( | ||
head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)) | ||
); | ||
yield NL; | ||
yield* formatTableRow(head.map((cell, i) => '-'.repeat(widths[i]))); | ||
yield NL; | ||
for (const row of rows) { | ||
yield* formatTableRow( | ||
row.map((r) => r + SPACE.repeat(ml - r.length)) | ||
row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)) | ||
); | ||
@@ -401,0 +409,0 @@ yield NL; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1895133
25850