@cenk1cenk2/md-printer 2.2.97 → 2.3.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/bin/dev.js +1 -1
- package/dist/commands/{run.js → index.js} +59 -26
- package/dist/commands/index.js.map +1 -0
- package/dist/constants/file.constants.js +0 -4
- package/dist/constants/file.constants.js.map +1 -1
- package/dist/constants/template.constants.js +2 -0
- package/dist/constants/template.constants.js.map +1 -1
- package/dist/interfaces/commands/index.js +0 -1
- package/dist/interfaces/commands/index.js.map +1 -1
- package/dist/interfaces/index.js +0 -1
- package/dist/interfaces/index.js.map +1 -1
- package/oclif.manifest.json +5 -11
- package/package.json +31 -27
- package/templates/label-25x38-cable/settings.json +10 -0
- package/templates/{privat-rechnung/tailwind.config.js → label-25x38-cable/tailwind.config.cjs} +4 -4
- package/templates/label-25x38-cable/tailwind.css +13 -0
- package/templates/label-25x38-cable/template.html.j2 +36 -0
- package/templates/privat-rechnung/tailwind.config.cjs +74 -0
- package/dist/commands/run.js.map +0 -1
- package/templates/privat-rechnung/main.css +0 -1456
package/bin/dev.js
CHANGED
|
@@ -16,7 +16,7 @@ async function main() {
|
|
|
16
16
|
tsNode.register({ project })
|
|
17
17
|
tsConfigPaths.register({
|
|
18
18
|
baseUrl: dirname(project),
|
|
19
|
-
paths: await import(project, {
|
|
19
|
+
paths: await import(project, { with: { type: 'json' } }).then((json) => {
|
|
20
20
|
return json.default.compilerOptions.paths
|
|
21
21
|
})
|
|
22
22
|
})
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { Args, Flags } from "@oclif/core";
|
|
4
3
|
import { watch } from "chokidar";
|
|
5
4
|
import { default as graymatter } from "gray-matter";
|
|
6
5
|
import { mdToPdf } from "md-to-pdf";
|
|
7
6
|
import Nunjucks from "nunjucks";
|
|
8
7
|
import { basename, dirname, extname, join } from "path";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import postcss from "postcss";
|
|
9
|
+
import showdown from "showdown";
|
|
10
|
+
import tailwind from "tailwindcss";
|
|
11
|
+
import { Args, Flags, Command, ConfigService, FileSystemService, ParserService, JsonParser, YamlParser } from "@cenk1cenk2/oclif-common";
|
|
12
|
+
import { OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from "../constants/index.js";
|
|
11
13
|
class MDPrinter extends Command {
|
|
12
14
|
static {
|
|
13
15
|
__name(this, "MDPrinter");
|
|
@@ -34,7 +36,7 @@ class MDPrinter extends Command {
|
|
|
34
36
|
};
|
|
35
37
|
static args = {
|
|
36
38
|
file: Args.string({
|
|
37
|
-
description: "
|
|
39
|
+
description: "File to be processed.",
|
|
38
40
|
required: true
|
|
39
41
|
}),
|
|
40
42
|
output: Args.string({
|
|
@@ -53,6 +55,10 @@ class MDPrinter extends Command {
|
|
|
53
55
|
async shouldRunBefore() {
|
|
54
56
|
this.cs = this.app.get(ConfigService);
|
|
55
57
|
this.fs = this.app.get(FileSystemService);
|
|
58
|
+
await this.app.get(ParserService).register(JsonParser, YamlParser);
|
|
59
|
+
this.nunjucks.addFilter("markdown_to_html", (markdown) => {
|
|
60
|
+
return new showdown.Converter().makeHtml(markdown);
|
|
61
|
+
});
|
|
56
62
|
this.tasks.options = {
|
|
57
63
|
silentRendererCondition: true
|
|
58
64
|
};
|
|
@@ -62,21 +68,32 @@ class MDPrinter extends Command {
|
|
|
62
68
|
{
|
|
63
69
|
task: /* @__PURE__ */ __name(async (ctx) => {
|
|
64
70
|
const file = join(process.cwd(), this.args.file);
|
|
65
|
-
if (!INPUT_FILE_ACCEPTED_TYPES.includes(extname(file))) {
|
|
66
|
-
throw new Error(`Input file should be ending with the extension: ${INPUT_FILE_ACCEPTED_TYPES.join(", ")} -> current: ${extname(file)}`);
|
|
67
|
-
}
|
|
68
71
|
if (!this.fs.exists(file)) {
|
|
69
72
|
throw new Error(`File does not exists: ${file}`);
|
|
70
73
|
}
|
|
71
74
|
this.logger.debug("Loading file: %s", file);
|
|
72
75
|
ctx.file = file;
|
|
73
|
-
ctx.
|
|
74
|
-
|
|
76
|
+
switch (extname(ctx.file)) {
|
|
77
|
+
case ".md": {
|
|
78
|
+
const data = graymatter.read(ctx.file);
|
|
79
|
+
ctx.content = await this.fs.read(file);
|
|
80
|
+
ctx.content = data.content;
|
|
81
|
+
ctx.metadata = data.data;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case ".yml": {
|
|
85
|
+
ctx.content = await this.fs.read(file);
|
|
86
|
+
ctx.metadata = await this.app.get(ParserService).parse(ctx.file, ctx.content);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
default:
|
|
90
|
+
throw new Error("File type is not accepted.");
|
|
91
|
+
}
|
|
75
92
|
}, "task")
|
|
76
93
|
},
|
|
77
94
|
{
|
|
78
95
|
task: /* @__PURE__ */ __name(async (ctx) => {
|
|
79
|
-
const template = ctx.
|
|
96
|
+
const template = ctx.metadata?.template ?? this.flags.template;
|
|
80
97
|
this.logger.debug("Loading template: %s", template);
|
|
81
98
|
ctx.templates = new RegExp(/\.\.?\//).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template);
|
|
82
99
|
await Promise.all(RequiredTemplateFiles.map(async (file) => {
|
|
@@ -88,6 +105,8 @@ class MDPrinter extends Command {
|
|
|
88
105
|
const paths = {
|
|
89
106
|
[TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),
|
|
90
107
|
[TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),
|
|
108
|
+
[TemplateFiles.TAILWIND_CSS]: join(ctx.templates, TemplateFiles.TAILWIND_CSS),
|
|
109
|
+
[TemplateFiles.TAILWIND_CONFIG]: join(ctx.templates, TemplateFiles.TAILWIND_CONFIG),
|
|
91
110
|
[TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),
|
|
92
111
|
[TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),
|
|
93
112
|
[TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)
|
|
@@ -95,19 +114,11 @@ class MDPrinter extends Command {
|
|
|
95
114
|
ctx.options = await this.cs.extend([
|
|
96
115
|
paths[TemplateFiles.SETTINGS],
|
|
97
116
|
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
document_title: ctx.graymatter.data?.document_title ?? this.flags.title ?? this.args.file,
|
|
101
|
-
// https://github.com/simonhaenisch/md-to-pdf/issues/247
|
|
102
|
-
launch_options: {
|
|
103
|
-
headless: "new"
|
|
104
|
-
}
|
|
117
|
+
dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,
|
|
118
|
+
document_title: ctx.metadata?.document_title ?? this.flags.title ?? this.args.file
|
|
105
119
|
}
|
|
106
120
|
]);
|
|
107
|
-
|
|
108
|
-
this.logger.debug("CSS exists for template.");
|
|
109
|
-
ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS]);
|
|
110
|
-
}
|
|
121
|
+
this.logger.debug("Options: %o", ctx.options);
|
|
111
122
|
if (this.fs.exists(paths[TemplateFiles.HEADER])) {
|
|
112
123
|
this.logger.debug("Header exists for template.");
|
|
113
124
|
ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER]);
|
|
@@ -119,8 +130,27 @@ class MDPrinter extends Command {
|
|
|
119
130
|
if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {
|
|
120
131
|
this.logger.debug("Design template exists for template.");
|
|
121
132
|
ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE]);
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
this.logger.debug("Metadata: %o", ctx.metadata);
|
|
134
|
+
}
|
|
135
|
+
if (this.fs.exists(paths[TemplateFiles.CSS])) {
|
|
136
|
+
this.logger.debug("CSS exists for template.");
|
|
137
|
+
ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS]);
|
|
138
|
+
}
|
|
139
|
+
if (this.fs.exists(paths[TemplateFiles.TAILWIND_CSS])) {
|
|
140
|
+
this.logger.debug("Tailwind CSS exists for template, generating configuration from: %s -> %s", paths[TemplateFiles.TAILWIND_CONFIG], paths[TemplateFiles.TAILWIND_CSS]);
|
|
141
|
+
ctx.options.css = await postcss([
|
|
142
|
+
tailwind({
|
|
143
|
+
...await import(paths[TemplateFiles.TAILWIND_CONFIG]).then((m) => m.default),
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
raw: ctx.template,
|
|
147
|
+
extension: "html"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
})
|
|
151
|
+
]).process(await this.fs.read(paths[TemplateFiles.TAILWIND_CSS]), {
|
|
152
|
+
from: void 0
|
|
153
|
+
}).then((result) => result.css);
|
|
124
154
|
}
|
|
125
155
|
}, "task")
|
|
126
156
|
},
|
|
@@ -128,8 +158,8 @@ class MDPrinter extends Command {
|
|
|
128
158
|
task: /* @__PURE__ */ __name(async (ctx) => {
|
|
129
159
|
if (this.flags.dev) {
|
|
130
160
|
ctx.options.devtools = true;
|
|
161
|
+
this.logger.info("Running in dev mode.");
|
|
131
162
|
}
|
|
132
|
-
return this.runMd2Pdf(ctx);
|
|
133
163
|
}, "task")
|
|
134
164
|
}
|
|
135
165
|
]);
|
|
@@ -138,14 +168,17 @@ class MDPrinter extends Command {
|
|
|
138
168
|
if (this.flags.watch) {
|
|
139
169
|
this.logger.info("Running in watch mode.");
|
|
140
170
|
watch([
|
|
171
|
+
TEMPLATE_DIRECTORY,
|
|
141
172
|
this.args.file,
|
|
142
173
|
join(ctx.templates, "**/*")
|
|
143
174
|
]).on("change", async () => {
|
|
144
175
|
await this.run();
|
|
145
176
|
await this.runTasks();
|
|
146
177
|
this.logger.info("Waiting for the next change.");
|
|
178
|
+
return this.runMd2Pdf(ctx);
|
|
147
179
|
});
|
|
148
180
|
}
|
|
181
|
+
return this.runMd2Pdf(ctx);
|
|
149
182
|
}
|
|
150
183
|
async runMd2Pdf(ctx) {
|
|
151
184
|
let pdf;
|
|
@@ -153,7 +186,7 @@ class MDPrinter extends Command {
|
|
|
153
186
|
this.logger.debug("Rendering as template.");
|
|
154
187
|
pdf = await mdToPdf({
|
|
155
188
|
content: this.nunjucks.renderString(ctx.template, {
|
|
156
|
-
...ctx.
|
|
189
|
+
...ctx.metadata ?? {},
|
|
157
190
|
content: ctx.content
|
|
158
191
|
})
|
|
159
192
|
}, ctx.options);
|
|
@@ -180,4 +213,4 @@ class MDPrinter extends Command {
|
|
|
180
213
|
export {
|
|
181
214
|
MDPrinter as default
|
|
182
215
|
};
|
|
183
|
-
//# sourceMappingURL=
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/commands/index.ts"],"sourcesContent":["import { watch } from 'chokidar'\nimport { default as graymatter } from 'gray-matter'\nimport { mdToPdf } from 'md-to-pdf'\nimport type { PdfConfig } from 'md-to-pdf/dist/lib/config.js'\nimport type { PdfOutput } from 'md-to-pdf/dist/lib/generate-output.js'\nimport Nunjucks from 'nunjucks'\nimport { basename, dirname, extname, join } from 'path'\nimport postcss from 'postcss'\nimport showdown from 'showdown'\nimport tailwind from 'tailwindcss'\n\nimport type { ShouldRunAfterHook, ShouldRunBeforeHook } from '@cenk1cenk2/oclif-common'\nimport { Args, Flags, Command, ConfigService, FileSystemService, ParserService, JsonParser, YamlParser } from '@cenk1cenk2/oclif-common'\nimport { OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from '@constants'\nimport type { MdPrinterCtx } from '@interfaces'\n\nexport default class MDPrinter extends Command<typeof MDPrinter, MdPrinterCtx> implements ShouldRunBeforeHook, ShouldRunAfterHook {\n static description = 'Generates a PDF from the given markdown file with the selected HTML template.'\n\n static flags = {\n template: Flags.string({\n char: 't',\n default: 'default',\n description: 'HTML template for the generated PDF file.'\n }),\n title: Flags.string({\n char: 'T',\n description: 'Overwrite document title.'\n }),\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch the changes on the given file.'\n }),\n dev: Flags.boolean({\n char: 'd',\n description: 'Run with Chrome browser instead of publishing the file.'\n })\n }\n\n static args = {\n file: Args.string({\n description: 'File to be processed.',\n required: true\n }),\n output: Args.string({\n description: 'Output file that will be generated. Overwrites the one define in front-matter.',\n required: false\n })\n }\n\n private nunjucks = Nunjucks.configure({\n autoescape: false,\n throwOnUndefined: true,\n trimBlocks: true,\n lstripBlocks: false\n })\n private cs: ConfigService\n private fs: FileSystemService\n\n public async shouldRunBefore(): Promise<void> {\n this.cs = this.app.get(ConfigService)\n this.fs = this.app.get(FileSystemService)\n\n await this.app.get(ParserService).register(JsonParser, YamlParser)\n\n this.nunjucks.addFilter('markdown_to_html', (markdown: string) => {\n return new showdown.Converter().makeHtml(markdown)\n })\n this.tasks.options = { silentRendererCondition: true }\n }\n\n public async run(): Promise<void> {\n this.tasks.add([\n {\n task: async(ctx): Promise<void> => {\n const file = join(process.cwd(), this.args.file)\n\n if (!this.fs.exists(file)) {\n throw new Error(`File does not exists: ${file}`)\n }\n\n this.logger.debug('Loading file: %s', file)\n\n ctx.file = file\n switch (extname(ctx.file)) {\n case '.md': {\n const data = graymatter.read(ctx.file)\n\n ctx.content = await this.fs.read(file)\n ctx.content = data.content\n\n ctx.metadata = data.data\n\n break\n }\n\n case '.yml': {\n ctx.content = await this.fs.read(file)\n\n ctx.metadata = await this.app.get(ParserService).parse(ctx.file, ctx.content)\n\n break\n }\n\n default:\n throw new Error('File type is not accepted.')\n }\n }\n },\n\n {\n task: async(ctx): Promise<void> => {\n const template = ctx.metadata?.template ?? this.flags.template\n\n this.logger.debug('Loading template: %s', template)\n\n ctx.templates = new RegExp(/\\.\\.?\\//).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template)\n\n await Promise.all(\n RequiredTemplateFiles.map(async(file) => {\n const current = join(ctx.templates, file)\n\n if (!this.fs.exists(current)) {\n throw new Error(`Template does not exists: ${current}`)\n }\n })\n )\n\n const paths: Record<TemplateFiles, string> = {\n [TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),\n [TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),\n [TemplateFiles.TAILWIND_CSS]: join(ctx.templates, TemplateFiles.TAILWIND_CSS),\n [TemplateFiles.TAILWIND_CONFIG]: join(ctx.templates, TemplateFiles.TAILWIND_CONFIG),\n [TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),\n [TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),\n [TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)\n }\n\n ctx.options = await this.cs.extend<PdfConfig>([\n paths[TemplateFiles.SETTINGS],\n {\n dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,\n document_title: ctx.metadata?.document_title ?? this.flags.title ?? this.args.file\n // https://github.com/simonhaenisch/md-to-pdf/issues/247\n // launch_options: {\n // headless: true\n // }\n }\n ])\n\n this.logger.debug('Options: %o', ctx.options)\n\n if (this.fs.exists(paths[TemplateFiles.HEADER])) {\n this.logger.debug('Header exists for template.')\n\n ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.FOOTER])) {\n this.logger.debug('Footer exists for template.')\n\n ctx.options.pdf_options.footerTemplate = await this.fs.read(paths[TemplateFiles.FOOTER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {\n this.logger.debug('Design template exists for template.')\n\n ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE])\n\n this.logger.debug('Metadata: %o', ctx.metadata)\n }\n\n if (this.fs.exists(paths[TemplateFiles.CSS])) {\n this.logger.debug('CSS exists for template.')\n ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TAILWIND_CSS])) {\n this.logger.debug('Tailwind CSS exists for template, generating configuration from: %s -> %s', paths[TemplateFiles.TAILWIND_CONFIG], paths[TemplateFiles.TAILWIND_CSS])\n\n ctx.options.css = await postcss([\n tailwind({\n ...(await import(paths[TemplateFiles.TAILWIND_CONFIG]).then((m) => m.default)),\n content: [ { raw: ctx.template, extension: 'html' } ]\n })\n ])\n .process(await this.fs.read(paths[TemplateFiles.TAILWIND_CSS]), { from: undefined })\n .then((result) => result.css)\n }\n }\n },\n\n {\n task: async(ctx): Promise<void> => {\n if (this.flags.dev) {\n ctx.options.devtools = true\n\n this.logger.info('Running in dev mode.')\n }\n }\n }\n ])\n }\n\n public async shouldRunAfter(ctx: MdPrinterCtx): Promise<void> {\n if (this.flags.watch) {\n this.logger.info('Running in watch mode.')\n\n watch([TEMPLATE_DIRECTORY, this.args.file, join(ctx.templates, '**/*')]).on('change', async() => {\n await this.run()\n await this.runTasks()\n\n this.logger.info('Waiting for the next change.')\n\n return this.runMd2Pdf(ctx)\n })\n }\n\n return this.runMd2Pdf(ctx)\n }\n\n private async runMd2Pdf(ctx: MdPrinterCtx): Promise<void> {\n let pdf: PdfOutput\n\n if (ctx.template) {\n this.logger.debug('Rendering as template.')\n pdf = await mdToPdf({ content: this.nunjucks.renderString(ctx.template, { ...(ctx.metadata ?? {}), content: ctx.content }) }, ctx.options)\n } else {\n this.logger.debug('Rendering as plain file.')\n pdf = await mdToPdf({ content: ctx.content }, ctx.options)\n }\n\n const output = pdf.filename\n\n await this.fs.mkdir(dirname(output))\n\n if (!output) {\n throw new Error('Output should either be defined with the variable or front-matter.')\n } else if (!OUTPUT_FILE_ACCEPTED_TYPES.includes(extname(output))) {\n throw new Error(`Output file should be ending with the extension: ${OUTPUT_FILE_ACCEPTED_TYPES.join(', ')} -> current: ${extname(output)}`)\n }\n\n this.logger.debug('Output file will be: %s', output)\n\n if (pdf) {\n this.logger.info('Writing file to output: %s', output)\n\n await this.fs.write(output, pdf.content)\n }\n }\n}\n"],"mappings":";;AAAA,SAASA,aAAa;AACtB,SAASC,WAAWC,kBAAkB;AACtC,SAASC,eAAe;AAGxB,OAAOC,cAAc;AACrB,SAASC,UAAUC,SAASC,SAASC,YAAY;AACjD,OAAOC,aAAa;AACpB,OAAOC,cAAc;AACrB,OAAOC,cAAc;AAGrB,SAASC,MAAMC,OAAOC,SAASC,eAAeC,mBAAmBC,eAAeC,YAAYC,kBAAkB;AAC9G,SAASC,4BAA4BC,uBAAuBC,oBAAoBC,qBAAqB;AAGrG,MAAA,kBAAuCT,QAAAA;EAhBvC,OAgBuCA;;;EACrC,OAAOU,cAAc;EAErB,OAAOC,QAAQ;IACbC,UAAUb,MAAMc,OAAO;MACrBC,MAAM;MACN3B,SAAS;MACTuB,aAAa;IACf,CAAA;IACAK,OAAOhB,MAAMc,OAAO;MAClBC,MAAM;MACNJ,aAAa;IACf,CAAA;IACAxB,OAAOa,MAAMiB,QAAQ;MACnBF,MAAM;MACNJ,aAAa;IACf,CAAA;IACAO,KAAKlB,MAAMiB,QAAQ;MACjBF,MAAM;MACNJ,aAAa;IACf,CAAA;EACF;EAEA,OAAOQ,OAAO;IACZC,MAAMrB,KAAKe,OAAO;MAChBH,aAAa;MACbU,UAAU;IACZ,CAAA;IACAC,QAAQvB,KAAKe,OAAO;MAClBH,aAAa;MACbU,UAAU;IACZ,CAAA;EACF;EAEQE,WAAWhC,SAASiC,UAAU;IACpCC,YAAY;IACZC,kBAAkB;IAClBC,YAAY;IACZC,cAAc;EAChB,CAAA;EACQC;EACAC;EAER,MAAaC,kBAAiC;AAC5C,SAAKF,KAAK,KAAKG,IAAIC,IAAI/B,aAAAA;AACvB,SAAK4B,KAAK,KAAKE,IAAIC,IAAI9B,iBAAAA;AAEvB,UAAM,KAAK6B,IAAIC,IAAI7B,aAAAA,EAAe8B,SAAS7B,YA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AAEgE,SAAST,IAAIS;MAAQ,GAAGT,IAAIL,OAAO;IAC3D;AAEA,UAAMlB,SAASwE,IAAIE;AAEnB,UAAM,KAAKlE,GAAGmE,MAAMxG,QAAQ6B,MAAAA,CAAAA;AAE5B,QAAI,CAACA,QAAQ;AACX,YAAM,IAAI2B,MAAM,oEAAA;IAClB,WAAW,CAAC1C,2BAA2B2F,SAASxG,QAAQ4B,MAAAA,CAAAA,GAAU;AAChE,YAAM,IAAI2B,MAAM,oDAAoD1C,2BAA2BZ,KAAK,IAAA,CAAA,gBAAqBD,QAAQ4B,MAAAA,CAAAA,EAAS;IAC5I;AAEA,SAAK4B,OAAOC,MAAM,2BAA2B7B,MAAAA;AAE7C,QAAIwE,KAAK;AACP,WAAK5C,OAAOuC,KAAK,8BAA8BnE,MAAAA;AAE/C,YAAM,KAAKQ,GAAGqE,MAAM7E,QAAQwE,IAAIxC,OAAO;IACzC;EACF;AACF;","names":["watch","default","graymatter","mdToPdf","Nunjucks","basename","dirname","extname","join","postcss","showdown","tailwind","Args","Flags","Command","ConfigService","FileSystemService","ParserService","JsonParser","YamlParser","OUTPUT_FILE_ACCEPTED_TYPES","RequiredTemplateFiles","TEMPLATE_DIRECTORY","TemplateFiles","description","flags","template","string","char","title","boolean","dev","args","file","required","output","nunjucks","configure","autoescape","throwOnUndefined","trimBlocks","lstripBlocks","cs","fs","shouldRunBefore","app","get","register","addFilter","markdown","Converter","makeHtml","tasks","options","silentRendererCondition","run","add","task","ctx","process","cwd","exists","Error","logger","debug","data","read","content","metadata","parse","templates","RegExp","test","config","root","Promise","all","map","current","paths","SETTINGS","CSS","TAILWIND_CSS","TAILWIND_CONFIG","HEADER","FOOTER","TEMPLATE","extend","dest","document_title","pdf_options","headerTemplate","footerTemplate","css","then","m","raw","extension","from","undefined","result","devtools","info","shouldRunAfter","on","runTasks","runMd2Pdf","pdf","renderString","filename","mkdir","includes","write"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants/file.constants.ts"],"sourcesContent":["export const
|
|
1
|
+
{"version":3,"sources":["../../src/constants/file.constants.ts"],"sourcesContent":["export const OUTPUT_FILE_ACCEPTED_TYPES = ['.pdf']\n"],"mappings":"AAAO,MAAMA,6BAA6B;EAAC;;","names":["OUTPUT_FILE_ACCEPTED_TYPES"]}
|
|
@@ -2,6 +2,8 @@ var TemplateFiles = /* @__PURE__ */ function(TemplateFiles2) {
|
|
|
2
2
|
TemplateFiles2["FOOTER"] = "footer.html";
|
|
3
3
|
TemplateFiles2["HEADER"] = "header.html";
|
|
4
4
|
TemplateFiles2["TEMPLATE"] = "template.html.j2";
|
|
5
|
+
TemplateFiles2["TAILWIND_CSS"] = "tailwind.css";
|
|
6
|
+
TemplateFiles2["TAILWIND_CONFIG"] = "tailwind.config.cjs";
|
|
5
7
|
TemplateFiles2["CSS"] = "main.css";
|
|
6
8
|
TemplateFiles2["SETTINGS"] = "settings.json";
|
|
7
9
|
return TemplateFiles2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants/template.constants.ts"],"sourcesContent":["export enum TemplateFiles {\n FOOTER = 'footer.html',\n HEADER = 'header.html',\n TEMPLATE = 'template.html.j2',\n CSS = 'main.css',\n SETTINGS = 'settings.json'\n}\n\nexport const RequiredTemplateFiles = [
|
|
1
|
+
{"version":3,"sources":["../../src/constants/template.constants.ts"],"sourcesContent":["export enum TemplateFiles {\n FOOTER = 'footer.html',\n HEADER = 'header.html',\n TEMPLATE = 'template.html.j2',\n TAILWIND_CSS = 'tailwind.css',\n TAILWIND_CONFIG = 'tailwind.config.cjs',\n CSS = 'main.css',\n SETTINGS = 'settings.json'\n}\n\nexport const RequiredTemplateFiles = [TemplateFiles.SETTINGS]\n\nexport const TEMPLATE_DIRECTORY = 'templates'\n"],"mappings":"AAAO,IAAKA,gBAAAA,yBAAAA,gBAAAA;;;;;;;;SAAAA;;AAUL,MAAMC,wBAAwB;;;AAE9B,MAAMC,qBAAqB;","names":["TemplateFiles","RequiredTemplateFiles","TEMPLATE_DIRECTORY"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/oclif.manifest.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"
|
|
3
|
+
"Symbol(SINGLE_COMMAND_CLI)": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {
|
|
6
6
|
"file": {
|
|
7
|
-
"description": "
|
|
7
|
+
"description": "File to be processed.",
|
|
8
8
|
"name": "file",
|
|
9
9
|
"required": true
|
|
10
10
|
},
|
|
@@ -89,19 +89,13 @@
|
|
|
89
89
|
},
|
|
90
90
|
"hasDynamicHelp": false,
|
|
91
91
|
"hiddenAliases": [],
|
|
92
|
-
"id": "
|
|
92
|
+
"id": "Symbol(SINGLE_COMMAND_CLI)",
|
|
93
93
|
"pluginAlias": "@cenk1cenk2/md-printer",
|
|
94
94
|
"pluginName": "@cenk1cenk2/md-printer",
|
|
95
95
|
"pluginType": "core",
|
|
96
96
|
"strict": true,
|
|
97
|
-
"enableJsonFlag": false
|
|
98
|
-
"isESM": true,
|
|
99
|
-
"relativePath": [
|
|
100
|
-
"dist",
|
|
101
|
-
"commands",
|
|
102
|
-
"run.js"
|
|
103
|
-
]
|
|
97
|
+
"enableJsonFlag": false
|
|
104
98
|
}
|
|
105
99
|
},
|
|
106
|
-
"version": "2.2.
|
|
100
|
+
"version": "2.2.98"
|
|
107
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cenk1cenk2/md-printer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "A markdown printer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"build": "tsup-node",
|
|
20
20
|
"dev:start": "tsup-node --watch",
|
|
21
21
|
"clean": "rimraf oclif.manifset.json",
|
|
22
|
-
"format": "prettier --write src/ --
|
|
23
|
-
"lint": "eslint
|
|
22
|
+
"format": "prettier --write src/ --log-level warn && eslint --fix src/",
|
|
23
|
+
"lint": "eslint src/",
|
|
24
24
|
"manifest": "oclif manifest",
|
|
25
25
|
"docs:toc": "oclif readme"
|
|
26
26
|
},
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"lint-staged": {
|
|
32
32
|
"*.{ts,js,tsx,jsx}": [
|
|
33
|
-
"prettier --
|
|
33
|
+
"prettier --log-level warn --write",
|
|
34
34
|
"eslint --fix"
|
|
35
35
|
],
|
|
36
36
|
"*.{json,md}": [
|
|
37
|
-
"prettier --
|
|
37
|
+
"prettier --log-level warn --write"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
@@ -47,8 +47,10 @@
|
|
|
47
47
|
"oclif": {
|
|
48
48
|
"bin": "md-printer",
|
|
49
49
|
"dirname": "md-printer",
|
|
50
|
-
"commands":
|
|
51
|
-
|
|
50
|
+
"commands": {
|
|
51
|
+
"strategy": "single",
|
|
52
|
+
"target": "./dist/commands/index.js"
|
|
53
|
+
},
|
|
52
54
|
"plugins": [
|
|
53
55
|
"@oclif/plugin-help"
|
|
54
56
|
],
|
|
@@ -68,43 +70,45 @@
|
|
|
68
70
|
"cenk1cenk2"
|
|
69
71
|
],
|
|
70
72
|
"dependencies": {
|
|
71
|
-
"@cenk1cenk2/oclif-common": "^6.3.
|
|
73
|
+
"@cenk1cenk2/oclif-common": "^6.3.28",
|
|
72
74
|
"@listr2/manager": "^2.0.13",
|
|
73
|
-
"@oclif/core": "^4.0.
|
|
74
|
-
"@oclif/plugin-help": "^6.2.
|
|
75
|
-
"
|
|
75
|
+
"@oclif/core": "^4.0.37",
|
|
76
|
+
"@oclif/plugin-help": "^6.2.19",
|
|
77
|
+
"@tailwindcss/forms": "^0.5.9",
|
|
78
|
+
"@tailwindcss/typography": "^0.5.15",
|
|
79
|
+
"chokidar": "^4.0.1",
|
|
76
80
|
"fs-extra": "^11.2.0",
|
|
77
81
|
"gray-matter": "^4.0.3",
|
|
78
82
|
"listr2": "^8.2.5",
|
|
79
83
|
"md-to-pdf": "^5.2.4",
|
|
80
|
-
"nunjucks": "^3.2.4"
|
|
84
|
+
"nunjucks": "^3.2.4",
|
|
85
|
+
"postcss": "^8.4.49",
|
|
86
|
+
"showdown": "^2.1.0",
|
|
87
|
+
"tailwindcss": "^3.4.16"
|
|
81
88
|
},
|
|
82
89
|
"devDependencies": {
|
|
83
|
-
"@cenk1cenk2/cz-cc": "^1.
|
|
84
|
-
"@cenk1cenk2/eslint-config": "^
|
|
85
|
-
"@swc/core": "^1.
|
|
86
|
-
"@tailwindcss/forms": "^0.5.9",
|
|
87
|
-
"@tailwindcss/typography": "^0.5.15",
|
|
90
|
+
"@cenk1cenk2/cz-cc": "^1.8.0",
|
|
91
|
+
"@cenk1cenk2/eslint-config": "^3.1.14",
|
|
92
|
+
"@swc/core": "^1.10.1",
|
|
88
93
|
"@types/config": "^3.3.5",
|
|
89
94
|
"@types/fs-extra": "^11.0.4",
|
|
90
|
-
"@types/node": "^
|
|
95
|
+
"@types/node": "^22.10.2",
|
|
91
96
|
"@types/nunjucks": "^3.2.6",
|
|
92
|
-
"
|
|
93
|
-
"
|
|
97
|
+
"@types/showdown": "^2.0.6",
|
|
98
|
+
"eslint": "^9.16.0",
|
|
99
|
+
"execa": "^9.5.2",
|
|
94
100
|
"globby": "^14.0.2",
|
|
95
|
-
"lint-staged": "^15.2.
|
|
96
|
-
"oclif": "^4.
|
|
97
|
-
"
|
|
98
|
-
"prettier": "^3.3.3",
|
|
101
|
+
"lint-staged": "^15.2.11",
|
|
102
|
+
"oclif": "^4.16.2",
|
|
103
|
+
"prettier": "^3.4.2",
|
|
99
104
|
"simple-git-hooks": "^2.11.1",
|
|
100
105
|
"source-map-support": "^0.5.21",
|
|
101
|
-
"tailwindcss": "^3.4.14",
|
|
102
106
|
"theme-colors": "^0.1.0",
|
|
103
107
|
"ts-node": "^10.9.2",
|
|
104
108
|
"tsconfig-paths": "^4.2.0",
|
|
105
109
|
"tsconfig-replace-paths": "^0.0.14",
|
|
106
|
-
"tsup": "^8.3.
|
|
107
|
-
"typescript": "^5.
|
|
110
|
+
"tsup": "^8.3.5",
|
|
111
|
+
"typescript": "^5.7.2"
|
|
108
112
|
},
|
|
109
113
|
"config": {
|
|
110
114
|
"commitizen": {
|
package/templates/{privat-rechnung/tailwind.config.js → label-25x38-cable/tailwind.config.cjs}
RENAMED
|
@@ -2,12 +2,12 @@ const colors = require('theme-colors').getColors
|
|
|
2
2
|
|
|
3
3
|
/** @type {import("tailwindcss").Config} */
|
|
4
4
|
module.exports = {
|
|
5
|
-
content: [
|
|
5
|
+
content: ['./template.html.j2'],
|
|
6
6
|
theme: {
|
|
7
7
|
extend: {
|
|
8
8
|
fontFamily: {
|
|
9
|
-
sans: [
|
|
10
|
-
serif: [
|
|
9
|
+
sans: ['Montserrat'],
|
|
10
|
+
serif: ['Montserrat']
|
|
11
11
|
},
|
|
12
12
|
colors: {
|
|
13
13
|
primary: colors('#cd0043')
|
|
@@ -70,5 +70,5 @@ module.exports = {
|
|
|
70
70
|
})
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
plugins: [
|
|
73
|
+
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')]
|
|
74
74
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
vim: ft=html
|
|
3
|
+
-->
|
|
4
|
+
<!DOCTYPE html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="UTF-8">
|
|
9
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
11
|
+
<title>Document</title>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
<div class="h-full w-full leading-tight prose border-2 rounded-md overflow-hidden">
|
|
16
|
+
<div class="flex flex-col h-full w-full items-center">
|
|
17
|
+
<div class="basis-1/2 flex flex-row flex-nowrap">
|
|
18
|
+
<div class="basis-1/4">
|
|
19
|
+
<span></span>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="basis-auto">
|
|
22
|
+
{{ top | markdown_to_html | default("") }}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="basis-1/2 flex flex-row flex-nowrap">
|
|
26
|
+
<div class="basis-1/4">
|
|
27
|
+
<span></span>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="basis-auto">
|
|
30
|
+
{{ bottom | markdown_to_html | default("") }}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</body>
|
|
35
|
+
|
|
36
|
+
</html>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const colors = require('theme-colors').getColors
|
|
2
|
+
|
|
3
|
+
/** @type {import("tailwindcss").Config} */
|
|
4
|
+
module.exports = {
|
|
5
|
+
content: ['./template.html.j2'],
|
|
6
|
+
theme: {
|
|
7
|
+
extend: {
|
|
8
|
+
fontFamily: {
|
|
9
|
+
sans: ['Montserrat'],
|
|
10
|
+
serif: ['Montserrat']
|
|
11
|
+
},
|
|
12
|
+
colors: {
|
|
13
|
+
primary: colors('#cd0043')
|
|
14
|
+
},
|
|
15
|
+
typography: (theme) => ({
|
|
16
|
+
css: {
|
|
17
|
+
a: {
|
|
18
|
+
color: theme('colors.primary.500'),
|
|
19
|
+
textDecoration: 'none'
|
|
20
|
+
},
|
|
21
|
+
h1: {
|
|
22
|
+
fontWeight: 700,
|
|
23
|
+
paddingTop: theme('padding.0.75'),
|
|
24
|
+
paddingBottom: theme('padding.0.75'),
|
|
25
|
+
marginBottom: 0,
|
|
26
|
+
marginTop: 0,
|
|
27
|
+
borderWidth: 0
|
|
28
|
+
},
|
|
29
|
+
h2: {
|
|
30
|
+
paddingTop: theme('padding.0.5'),
|
|
31
|
+
paddingBottom: theme('padding.0.5'),
|
|
32
|
+
marginBottom: 0,
|
|
33
|
+
marginTop: 0,
|
|
34
|
+
borderWidth: 0
|
|
35
|
+
},
|
|
36
|
+
h3: {
|
|
37
|
+
paddingTop: theme('padding.0.25'),
|
|
38
|
+
paddingBottom: theme('padding.0.25'),
|
|
39
|
+
marginBottom: 0,
|
|
40
|
+
marginTop: 0,
|
|
41
|
+
borderWidth: 0
|
|
42
|
+
},
|
|
43
|
+
blockquote: {
|
|
44
|
+
fontWeight: 400,
|
|
45
|
+
color: theme('colors.gray.600'),
|
|
46
|
+
fontStyle: 'normal',
|
|
47
|
+
quotes: '"\\201C""\\201D""\\2018""\\2019"'
|
|
48
|
+
},
|
|
49
|
+
'blockquote p:first-of-type::before': {
|
|
50
|
+
content: ''
|
|
51
|
+
},
|
|
52
|
+
'blockquote p:last-of-type::after': {
|
|
53
|
+
content: ''
|
|
54
|
+
},
|
|
55
|
+
'ul > li': {
|
|
56
|
+
paddingLeft: '1em',
|
|
57
|
+
textAlign: 'left'
|
|
58
|
+
},
|
|
59
|
+
'ol > li': {
|
|
60
|
+
paddingLeft: '1em',
|
|
61
|
+
textAlign: 'left'
|
|
62
|
+
},
|
|
63
|
+
'ol > li::before': {
|
|
64
|
+
top: 'calc(0.875em - 0.1em)'
|
|
65
|
+
},
|
|
66
|
+
'ul > li::before': {
|
|
67
|
+
top: 'calc(0.875em - 0.1em)'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')]
|
|
74
|
+
}
|
package/dist/commands/run.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/run.ts"],"sourcesContent":["import { Args, Flags } from '@oclif/core'\nimport { watch } from 'chokidar'\nimport { default as graymatter } from 'gray-matter'\nimport { mdToPdf } from 'md-to-pdf'\nimport type { PdfConfig } from 'md-to-pdf/dist/lib/config.js'\nimport type { PdfOutput } from 'md-to-pdf/dist/lib/generate-output.js'\nimport Nunjucks from 'nunjucks'\nimport { basename, dirname, extname, join } from 'path'\n\nimport type { ShouldRunAfterHook, ShouldRunBeforeHook } from '@cenk1cenk2/oclif-common'\nimport { Command, ConfigService, FileSystemService } from '@cenk1cenk2/oclif-common'\nimport { INPUT_FILE_ACCEPTED_TYPES, OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from '@constants'\nimport type { MdPrinterCtx } from '@interfaces'\n\nexport default class MDPrinter extends Command<typeof MDPrinter, MdPrinterCtx> implements ShouldRunBeforeHook, ShouldRunAfterHook {\n static description = 'Generates a PDF from the given markdown file with the selected HTML template.'\n\n static flags = {\n template: Flags.string({\n char: 't',\n default: 'default',\n description: 'HTML template for the generated PDF file.'\n }),\n title: Flags.string({\n char: 'T',\n description: 'Overwrite document title.'\n }),\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch the changes on the given file.'\n }),\n dev: Flags.boolean({\n char: 'd',\n description: 'Run with Chrome browser instead of publishing the file.'\n })\n }\n\n static args = {\n file: Args.string({\n description: 'Markdown file to be processed.',\n required: true\n }),\n output: Args.string({\n description: 'Output file that will be generated. Overwrites the one define in front-matter.',\n required: false\n })\n }\n\n private nunjucks = Nunjucks.configure({\n autoescape: false,\n throwOnUndefined: true,\n trimBlocks: true,\n lstripBlocks: false\n })\n private cs: ConfigService\n private fs: FileSystemService\n\n public async shouldRunBefore (): Promise<void> {\n this.cs = this.app.get(ConfigService)\n this.fs = this.app.get(FileSystemService)\n\n this.tasks.options = { silentRendererCondition: true }\n }\n\n public async run (): Promise<void> {\n this.tasks.add([\n {\n task: async (ctx): Promise<void> => {\n const file = join(process.cwd(), this.args.file)\n\n if (!INPUT_FILE_ACCEPTED_TYPES.includes(extname(file))) {\n throw new Error(`Input file should be ending with the extension: ${INPUT_FILE_ACCEPTED_TYPES.join(', ')} -> current: ${extname(file)}`)\n }\n\n if (!this.fs.exists(file)) {\n throw new Error(`File does not exists: ${file}`)\n }\n\n this.logger.debug('Loading file: %s', file)\n\n ctx.file = file\n\n ctx.content = await this.fs.read(file)\n\n ctx.graymatter = graymatter.read(ctx.file)\n }\n },\n\n {\n task: async (ctx): Promise<void> => {\n const template = ctx.graymatter?.data?.template ?? this.flags.template\n\n this.logger.debug('Loading template: %s', template)\n\n ctx.templates = new RegExp(/\\.\\.?\\//).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template)\n\n await Promise.all(\n RequiredTemplateFiles.map(async (file) => {\n const current = join(ctx.templates, file)\n\n if (!this.fs.exists(current)) {\n throw new Error(`Template does not exists: ${current}`)\n }\n })\n )\n\n const paths: Record<TemplateFiles, string> = {\n [TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),\n [TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),\n [TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),\n [TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),\n [TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)\n }\n\n ctx.options = await this.cs.extend<PdfConfig>([\n paths[TemplateFiles.SETTINGS],\n {\n pdf_options: {},\n dest: this.args?.output ?? ctx.graymatter.data?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,\n document_title: ctx.graymatter.data?.document_title ?? this.flags.title ?? this.args.file,\n // https://github.com/simonhaenisch/md-to-pdf/issues/247\n launch_options: {\n headless: 'new'\n }\n }\n ])\n\n if (this.fs.exists(paths[TemplateFiles.CSS])) {\n this.logger.debug('CSS exists for template.')\n ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS])\n }\n\n if (this.fs.exists(paths[TemplateFiles.HEADER])) {\n this.logger.debug('Header exists for template.')\n\n ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.FOOTER])) {\n this.logger.debug('Footer exists for template.')\n\n ctx.options.pdf_options.footerTemplate = await this.fs.read(paths[TemplateFiles.FOOTER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {\n this.logger.debug('Design template exists for template.')\n\n ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE])\n\n ctx.content = ctx.graymatter.content\n\n this.logger.debug('Frontmatter: %o', ctx.graymatter.data)\n }\n }\n },\n\n {\n task: async (ctx): Promise<void> => {\n if (this.flags.dev) {\n ctx.options.devtools = true\n }\n\n return this.runMd2Pdf(ctx)\n }\n }\n ])\n }\n\n public async shouldRunAfter (ctx: MdPrinterCtx): Promise<void> {\n if (this.flags.watch) {\n this.logger.info('Running in watch mode.')\n\n watch([ this.args.file, join(ctx.templates, '**/*') ]).on('change', async () => {\n await this.run()\n await this.runTasks()\n\n this.logger.info('Waiting for the next change.')\n })\n }\n }\n\n private async runMd2Pdf (ctx: MdPrinterCtx): Promise<void> {\n let pdf: PdfOutput\n\n if (ctx.template) {\n this.logger.debug('Rendering as template.')\n pdf = await mdToPdf({ content: this.nunjucks.renderString(ctx.template, { ...ctx.graymatter?.data ?? {}, content: ctx.content }) }, ctx.options)\n } else {\n this.logger.debug('Rendering as plain file.')\n pdf = await mdToPdf({ content: ctx.content }, ctx.options)\n }\n\n const output = pdf.filename\n\n await this.fs.mkdir(dirname(output))\n\n if (!output) {\n throw new Error('Output should either be defined with the variable or front-matter.')\n } else if (!OUTPUT_FILE_ACCEPTED_TYPES.includes(extname(output))) {\n throw new Error(`Output file should be ending with the extension: ${OUTPUT_FILE_ACCEPTED_TYPES.join(', ')} -> current: ${extname(output)}`)\n }\n\n this.logger.debug('Output file will be: %s', output)\n\n if (pdf) {\n this.logger.info('Writing file to output: %s', output)\n\n await this.fs.write(output, pdf.content)\n }\n }\n}\n"],"mappings":";;AAAA,SAASA,MAAMC,aAAa;AAC5B,SAASC,aAAa;AACtB,SAASC,WAAWC,kBAAkB;AACtC,SAASC,eAAe;AAGxB,OAAOC,cAAc;AACrB,SAASC,UAAUC,SAASC,SAASC,YAAY;AAGjD,SAASC,SAASC,eAAeC,yBAAyB;AAC1D,SAASC,2BAA2BC,4BAA4BC,uBAAuBC,oBAAoBC,qBAAqB;AAGhI,MAAA,kBAAuCP,QAAAA;EAdvC,OAcuCA;;;EACrC,OAAOQ,cAAc;EAErB,OAAOC,QAAQ;IACbC,UAAUpB,MAAMqB,OAAO;MACrBC,MAAM;MACNpB,SAAS;MACTgB,aAAa;IACf,CAAA;IACAK,OAAOvB,MAAMqB,OAAO;MAClBC,MAAM;MACNJ,aAAa;IACf,CAAA;IACAjB,OAAOD,MAAMwB,QAAQ;MACnBF,MAAM;MACNJ,aAAa;IACf,CAAA;IACAO,KAAKzB,MAAMwB,QAAQ;MACjBF,MAAM;MACNJ,aAAa;IACf,CAAA;EACF;EAEA,OAAOQ,OAAO;IACZC,MAAM5B,KAAKsB,OAAO;MAChBH,aAAa;MACbU,UAAU;IACZ,CAAA;IACAC,QAAQ9B,KAAKsB,OAAO;MAClBH,aAAa;MACbU,UAAU;IACZ,CAAA;EACF;EAEQE,WAAWzB,SAAS0B,UAAU;IACpCC,YAAY;IACZC,kBAAkB;IAClBC,YAAY;IACZC,cAAc;EAChB,CAAA;EACQC;EACAC;EAER,MAAaC,kBAAkC;AAC7C,SAAKF,KAAK,KAAKG,IAAIC,IAAI7B,aAAAA;AACvB,SAAK0B,KAAK,KAAKE,IAAIC,IAAI5B,iBAAAA;AAEvB,SAAK6B,MAAMC,UAAU;MAAEC,yBAAyB;IAAK;EACvD;E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R,IAAIQ;QAAQ,CAAA;MAAG,GAAGR,IAAIL,OAAO;IACjJ,OAAO;AACL,WAAKW,OAAOC,MAAM,0BAAA;AAClBkC,YAAM,MAAMpF,QAAQ;QAAEmD,SAASR,IAAIQ;MAAQ,GAAGR,IAAIL,OAAO;IAC3D;AAEA,UAAMb,SAAS2D,IAAIE;AAEnB,UAAM,KAAKrD,GAAGsD,MAAMpF,QAAQsB,MAAAA,CAAAA;AAE5B,QAAI,CAACA,QAAQ;AACX,YAAM,IAAIsB,MAAM,oEAAA;IAClB,WAAW,CAACrC,2BAA2BoC,SAAS1C,QAAQqB,MAAAA,CAAAA,GAAU;AAChE,YAAM,IAAIsB,MAAM,oDAAoDrC,2BAA2BL,KAAK,IAAA,CAAA,gBAAqBD,QAAQqB,MAAAA,CAAAA,EAAS;IAC5I;AAEA,SAAKwB,OAAOC,MAAM,2BAA2BzB,MAAAA;AAE7C,QAAI2D,KAAK;AACP,WAAKnC,OAAOgC,KAAK,8BAA8BxD,MAAAA;AAE/C,YAAM,KAAKQ,GAAGuD,MAAM/D,QAAQ2D,IAAIjC,OAAO;IACzC;EACF;AACF;","names":["Args","Flags","watch","default","graymatter","mdToPdf","Nunjucks","basename","dirname","extname","join","Command","ConfigService","FileSystemService","INPUT_FILE_ACCEPTED_TYPES","OUTPUT_FILE_ACCEPTED_TYPES","RequiredTemplateFiles","TEMPLATE_DIRECTORY","TemplateFiles","description","flags","template","string","char","title","boolean","dev","args","file","required","output","nunjucks","configure","autoescape","throwOnUndefined","trimBlocks","lstripBlocks","cs","fs","shouldRunBefore","app","get","tasks","options","silentRendererCondition","run","add","task","ctx","process","cwd","includes","Error","exists","logger","debug","content","read","data","templates","RegExp","test","config","root","Promise","all","map","current","paths","SETTINGS","CSS","HEADER","FOOTER","TEMPLATE","extend","pdf_options","dest","document_title","launch_options","headless","css","headerTemplate","footerTemplate","devtools","runMd2Pdf","shouldRunAfter","info","on","runTasks","pdf","renderString","filename","mkdir","write"]}
|