Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tables #1577

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fix precision rounding issues in LineWrapper
- Add support for dynamic sizing
- Add support for rotatable text
- Add table generation

### [v0.16.0] - 2024-12-29

Expand Down
17 changes: 17 additions & 0 deletions docs/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ class Node {
({ y } = doc);
doc.x = doc.y = 0;

// Update the page width for those which rely on the width of the document
var docPageWidth = doc.page.width;
var docPageHeight = doc.page.height;
var docPageMargins = doc.page.margins;
doc.page.width = doc.page.width - x - doc.page.margins.right;
doc.page.margins = { top: 0, left: 0, right: 0, bottom: 0 };

// run the example code with the document
vm.runInNewContext(this.code, {
doc,
Expand All @@ -218,6 +225,9 @@ class Node {
doc.restore();
doc.x = x;
doc.y = y + this.height;
doc.page.width = docPageWidth;
doc.page.height = docPageHeight;
doc.page.margins = docPageMargins;
break;
case 'hr':
doc.addPage();
Expand All @@ -226,6 +236,12 @@ class Node {
// loop through subnodes and render them
for (let index = 0; index < this.content.length; index++) {
const fragment = this.content[index];

if (this.type === 'numberlist') {
let node = new Node(['inlinecode', `${index + 1}. `]);
fragment.content.splice(0, 0, node);
}

if (fragment.type === 'text') {
// add a new page for each heading, unless it follows another heading
if (
Expand Down Expand Up @@ -328,5 +344,6 @@ render(doc, 'forms.md');
render(doc, 'destinations.md');
render(doc, 'attachments.md');
render(doc, 'accessibility.md');
render(doc, 'table.md');
render(doc, 'you_made_it.md');
doc.end();
1 change: 1 addition & 0 deletions docs/generate_website.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const files = [
'destinations.md',
'attachments.md',
'accessibility.md',
'table.md',
'you_made_it.md'
];

Expand Down
Loading
Loading