@cenk1cenk2/md-printer 2.18.2 → 2.19.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/dist/commands/index.mjs
CHANGED
|
@@ -143,9 +143,10 @@ var MDPrinter = class extends Command {
|
|
|
143
143
|
["footer.html"]: join(ctx.templates, "footer.html"),
|
|
144
144
|
["template.html.j2"]: join(ctx.templates, "template.html.j2")
|
|
145
145
|
};
|
|
146
|
+
const title = ctx.metadata?.document_title ?? this.flags.title;
|
|
146
147
|
ctx.options = await this.cs.extend([paths["settings.json"], {
|
|
147
148
|
dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.${this.flags["output-filetype"]}`,
|
|
148
|
-
document_title:
|
|
149
|
+
...title ? { document_title: title } : {},
|
|
149
150
|
launch_options: { executablePath: this.flags.browser }
|
|
150
151
|
}]);
|
|
151
152
|
ctx.renderContinuous = this.flags.continuous || ctx.metadata?.continuous === true || ctx.options.continuous === true;
|
|
@@ -175,6 +176,7 @@ var MDPrinter = class extends Command {
|
|
|
175
176
|
ctx.options.css = await postcss([tailwind({ base: ctx.templates })]).process(await this.fs.read(paths["tailwind.css"]), { from: paths["tailwind.css"] }).then((result) => result.css);
|
|
176
177
|
}
|
|
177
178
|
await this.applyTranslations(ctx);
|
|
179
|
+
await this.applyDocumentTitle(ctx);
|
|
178
180
|
} }]);
|
|
179
181
|
}
|
|
180
182
|
async shouldRunAfter(ctx) {
|
|
@@ -197,6 +199,23 @@ var MDPrinter = class extends Command {
|
|
|
197
199
|
await this.runMd2Pdf(ctx);
|
|
198
200
|
if (this.browser) await this.browser.close();
|
|
199
201
|
}
|
|
202
|
+
context(ctx) {
|
|
203
|
+
const context = {
|
|
204
|
+
...ctx.metadata ?? {},
|
|
205
|
+
content: ctx.content
|
|
206
|
+
};
|
|
207
|
+
if (ctx.t) {
|
|
208
|
+
context.t = ctx.t;
|
|
209
|
+
context.language = ctx.language;
|
|
210
|
+
}
|
|
211
|
+
return context;
|
|
212
|
+
}
|
|
213
|
+
async applyDocumentTitle(ctx) {
|
|
214
|
+
const title = ctx.options.document_title ?? this.args.file;
|
|
215
|
+
if (!title) return;
|
|
216
|
+
ctx.options.document_title = this.nunjucks.renderString(title, this.context(ctx));
|
|
217
|
+
this.logger.info("Document title will be: %s", ctx.options.document_title);
|
|
218
|
+
}
|
|
200
219
|
async applyTranslations(ctx) {
|
|
201
220
|
ctx.language = this.flags.language ?? ctx.metadata?.language ?? ctx.options.i18n?.language ?? "en";
|
|
202
221
|
ctx.t = await this.i18n.load(join(ctx.templates, I18N_DIRECTORY), {
|
|
@@ -265,15 +284,7 @@ var MDPrinter = class extends Command {
|
|
|
265
284
|
let output;
|
|
266
285
|
if (ctx.template) {
|
|
267
286
|
this.logger.info("Rendering as template.");
|
|
268
|
-
|
|
269
|
-
...ctx.metadata ?? {},
|
|
270
|
-
content: ctx.content
|
|
271
|
-
};
|
|
272
|
-
if (ctx.t) {
|
|
273
|
-
context.t = ctx.t;
|
|
274
|
-
context.language = ctx.language;
|
|
275
|
-
}
|
|
276
|
-
output = await convertMdToPdf({ content: this.nunjucks.renderString(ctx.template, context) }, options, { browser: this.browser });
|
|
287
|
+
output = await convertMdToPdf({ content: this.nunjucks.renderString(ctx.template, this.context(ctx)) }, options, { browser: this.browser });
|
|
277
288
|
} else {
|
|
278
289
|
this.logger.info("Rendering as plain file.");
|
|
279
290
|
output = await convertMdToPdf({ content: ctx.content }, options, { browser: this.browser });
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cenk1cenk2/md-printer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "A markdown printer.",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -105,15 +105,15 @@
|
|
|
105
105
|
"execa": "^10.0.0",
|
|
106
106
|
"globby": "^16.2.2",
|
|
107
107
|
"lint-staged": "^16.4.0",
|
|
108
|
-
"oclif": "^4.23.
|
|
109
|
-
"prettier": "^3.9.
|
|
108
|
+
"oclif": "^4.23.28",
|
|
109
|
+
"prettier": "^3.9.6",
|
|
110
110
|
"prettier-plugin-jinja-template": "^2.2.0",
|
|
111
111
|
"simple-git-hooks": "^2.13.1",
|
|
112
112
|
"theme-colors": "^0.1.0",
|
|
113
113
|
"tpm": "^1.4.14",
|
|
114
114
|
"ts-node": "^10.9.2",
|
|
115
115
|
"tsconfig-paths": "^4.2.0",
|
|
116
|
-
"tsdown": "^0.22.
|
|
116
|
+
"tsdown": "^0.22.13",
|
|
117
117
|
"typescript": "^6.0.3"
|
|
118
118
|
},
|
|
119
119
|
"config": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"body_class": [],
|
|
3
|
+
"document_title": "{{ date }} - Invoice from {{ company.name }}{% if company.tax_number %} ({{ company.tax_number }}){% endif %} to {{ client.name }}{% if client.tax_number %} ({{ client.tax_number }}){% endif %} - #{{ id }}",
|
|
3
4
|
"highlight_style": "atom-one-dark",
|
|
4
5
|
"i18n": {
|
|
5
6
|
"language": "en",
|
|
@@ -129,6 +129,13 @@ html {
|
|
|
129
129
|
@apply p-4;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/* md-to-pdf ships github-markdown-css, which sets `table { display: block }` for horizontal
|
|
133
|
+
* scrolling. That collapses rows into an anonymous max-content box, so column widths are ignored. */
|
|
134
|
+
table {
|
|
135
|
+
display: table;
|
|
136
|
+
width: 100%;
|
|
137
|
+
}
|
|
138
|
+
|
|
132
139
|
table th {
|
|
133
140
|
@apply bg-gray-700 text-white;
|
|
134
141
|
}
|
|
@@ -136,7 +143,17 @@ table th {
|
|
|
136
143
|
table tr {
|
|
137
144
|
border-top: 0;
|
|
138
145
|
break-inside: avoid;
|
|
139
|
-
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* zebra rows only pay off over many rows, so striping is opt-in; the short key/value
|
|
149
|
+
* tables use hairline row dividers instead and stay quieter beside the items table.
|
|
150
|
+
* The reset is needed because md-to-pdf's markdown.css stripes every table itself. */
|
|
151
|
+
table tr:nth-child(even) {
|
|
152
|
+
background-color: transparent;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
table.striped tr:nth-child(even) {
|
|
156
|
+
@apply bg-gray-50;
|
|
140
157
|
}
|
|
141
158
|
|
|
142
159
|
table th,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<p class="text-vertical">{{ t('sections.from') }}</p>
|
|
21
21
|
</div>
|
|
22
22
|
<div class="col-start-2 col-span-5 flex flex-col justify-start p-4 pt-10 mr-12">
|
|
23
|
-
<h1>
|
|
23
|
+
<h1>{{ company.name }}</h1>
|
|
24
24
|
<h3>{{ company.tax_number }}</h3>
|
|
25
25
|
<address>{{ company.address | trim }}</address>
|
|
26
26
|
<div class="flex flex-col text-sm">
|
|
@@ -50,24 +50,27 @@
|
|
|
50
50
|
{% endif %}
|
|
51
51
|
<address>{{ client.address | trim }}</address>
|
|
52
52
|
</div>
|
|
53
|
-
<div class="col-span-6 flex items-center justify-center text-xs
|
|
54
|
-
<div class="
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
<div class="col-span-6 flex items-center justify-center text-xs py-4 pl-4 pr-16">
|
|
54
|
+
<div class="w-full overflow-hidden rounded-xl border-y-2 shadow-md shadow-gray-300 border-gray-900!">
|
|
55
|
+
<table class="w-full table-auto my-0!">
|
|
56
|
+
<tbody>
|
|
57
|
+
<tr>
|
|
58
|
+
<td class="w-[30%] text-left align-middle font-bold">{{ t('fields.date') }}</td>
|
|
59
|
+
<td class="w-[70%] text-right align-middle font-semibold">{{ date }}</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td class="w-[30%] text-left align-middle font-bold border-t! border-t-gray-100/30!">{{ t('fields.id') }}</td>
|
|
63
|
+
<td class="w-[70%] text-right align-middle font-semibold border-t! border-t-gray-100/30!">{{ id }}</td>
|
|
64
|
+
</tr>
|
|
65
|
+
</tbody>
|
|
66
|
+
</table>
|
|
65
67
|
</div>
|
|
66
68
|
</div>
|
|
67
69
|
</section>
|
|
68
70
|
<section id="items" class="grid grid-cols-12">
|
|
69
71
|
<div class="col-span-12 px-16 py-4">
|
|
70
|
-
<
|
|
72
|
+
<div class="overflow-hidden rounded-xl border-y-2 shadow-md shadow-gray-300 border-gray-900!">
|
|
73
|
+
<table class="striped w-full table-auto my-0!">
|
|
71
74
|
<thead class="border-b-1 border-b-gray-900! border-x-2 border-x-gray-900!">
|
|
72
75
|
<tr>
|
|
73
76
|
<th scope="col" class="w-md text-center">
|
|
@@ -105,7 +108,8 @@
|
|
|
105
108
|
<td class="text-center align-middle">
|
|
106
109
|
{% if calculated_item_tax > 0 %}
|
|
107
110
|
<div class="flex flex-row items-center">
|
|
108
|
-
<span
|
|
111
|
+
<span
|
|
112
|
+
class="w-8 shrink-0 mr-1 py-px rounded-full text-center text-[0.50rem] font-semibold bg-gray-700 text-white">{{ item.tax }}%</span>
|
|
109
113
|
<span>{{ calculated_item_tax | round(2) }}{{ currency }}</span>
|
|
110
114
|
</div>
|
|
111
115
|
{% else %}
|
|
@@ -113,12 +117,13 @@
|
|
|
113
117
|
{% endif %}
|
|
114
118
|
</td>
|
|
115
119
|
{% set calculated_item_total = calculated_item_subtotal + calculated_item_tax %}
|
|
116
|
-
<td class="font-semibold text-
|
|
120
|
+
<td class="font-semibold text-right align-middle">{{ calculated_item_total | round(2) }}{{ currency }}</td>
|
|
117
121
|
</tr>
|
|
118
122
|
{% set calculated_subtotal = calculated_subtotal + calculated_item_subtotal %}
|
|
119
123
|
{% endfor %}
|
|
120
124
|
</tbody>
|
|
121
125
|
</table>
|
|
126
|
+
</div>
|
|
122
127
|
</div>
|
|
123
128
|
</section>
|
|
124
129
|
<section id="payment" class="grid grid-cols-12">
|
|
@@ -126,7 +131,7 @@
|
|
|
126
131
|
<p class="text-vertical">{{ t('sections.payment') }}</p>
|
|
127
132
|
</div>
|
|
128
133
|
<div
|
|
129
|
-
class="col-span-5 flex flex-col p-4 ml-[-1px] pl-5 justify-center
|
|
134
|
+
class="col-span-5 flex flex-col p-4 ml-[-1px] pl-5 justify-center bg-gray-700 rounded-r-4xl text-white">
|
|
130
135
|
<span>{{ payment.bank }}</span>
|
|
131
136
|
<address>{{ payment.address | trim }}</address>
|
|
132
137
|
<span>{{ payment.bic }}</span>
|
|
@@ -135,41 +140,33 @@
|
|
|
135
140
|
<span class="font-semibold">{{ payment.iban }}</span>
|
|
136
141
|
</div>
|
|
137
142
|
<div class="col-span-1"></div>
|
|
138
|
-
<div
|
|
139
|
-
class="
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{{ calculated_tax | round(2) }}{{currency}}
|
|
157
|
-
{% else %}
|
|
158
|
-
<span class="font-semibold">—</span>
|
|
159
|
-
{% endif %}
|
|
160
|
-
</p>
|
|
161
|
-
</div>
|
|
162
|
-
<div class="pt-1 border-t-2 border-primary-500!">
|
|
163
|
-
<div
|
|
164
|
-
class="flex flex-row justify-between font-bold rounded-lg text-primary-500 bg-gray-50 border border-gray-50! inset-shadow-xs inset-shadow-gray-400 py-1 px-2">
|
|
165
|
-
<p>
|
|
166
|
-
{{ t('summary.total') }}
|
|
167
|
-
</p>
|
|
168
|
-
<p>
|
|
143
|
+
<div class="col-span-5 flex flex-col justify-center m-8 mr-16">
|
|
144
|
+
<div class="w-full overflow-hidden rounded-xl border-y-2 shadow-md shadow-gray-300 border-gray-900!">
|
|
145
|
+
<table class="w-full table-auto my-0!">
|
|
146
|
+
<tbody>
|
|
147
|
+
<tr>
|
|
148
|
+
<td class="w-[55%] text-left align-middle font-semibold">{{ t('summary.subtotal') }}</td>
|
|
149
|
+
<td class="w-[45%] text-right align-middle font-semibold">{{ calculated_subtotal | round(2) }}{{ currency }}</td>
|
|
150
|
+
</tr>
|
|
151
|
+
<tr>
|
|
152
|
+
<td class="w-[55%] text-left align-middle font-semibold border-t! border-t-gray-100/30!">{{ t('summary.tax') }}</td>
|
|
153
|
+
<td class="w-[45%] text-right align-middle font-semibold border-t! border-t-gray-100/30!">
|
|
154
|
+
{% if calculated_tax > 0 %}
|
|
155
|
+
{{ calculated_tax | round(2) }}{{ currency }}
|
|
156
|
+
{% else %}
|
|
157
|
+
—
|
|
158
|
+
{% endif %}
|
|
159
|
+
</td>
|
|
160
|
+
</tr>
|
|
169
161
|
{% set calculated_total = calculated_subtotal + calculated_tax %}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
<tr>
|
|
163
|
+
<td class="w-[55%] text-left align-middle font-bold text-primary-500 border-t-2! border-t-primary-500!">{{ t('summary.total') }}</td>
|
|
164
|
+
<td class="w-[45%] text-right align-middle font-bold text-primary-500 border-t-2! border-t-primary-500!">
|
|
165
|
+
{{ calculated_total | round(2) }}{{ currency }}
|
|
166
|
+
</td>
|
|
167
|
+
</tr>
|
|
168
|
+
</tbody>
|
|
169
|
+
</table>
|
|
173
170
|
</div>
|
|
174
171
|
</div>
|
|
175
172
|
</section>
|