sfdx-hardis
Version:
Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards
47 lines • 1.55 kB
JavaScript
import c from "chalk";
import { uxLog } from "./index.js";
import { mdToPdf } from 'md-to-pdf';
export async function generatePdfFileFromMarkdown(markdownFile) {
try {
const outputPdfFile = markdownFile.replace('.md', '.pdf');
await mdToPdf({ path: markdownFile }, {
dest: outputPdfFile,
css: `img {
max-width: 50%;
max-height: 20%;
display: block;
margin: 0 auto;
}`,
stylesheet_encoding: 'utf-8'
});
uxLog(this, c.green(`PDF file generated from ${markdownFile} documentation: ${c.bold(outputPdfFile)}`));
return outputPdfFile;
}
catch (e) {
uxLog(this, c.yellow(`Error generating PDF file from ${markdownFile} documentation with CLI: ${e.message}`) + "\n" + c.grey(e.stack));
return false;
}
}
// Add a new line before each start of list of items starting by "-"
// If the previous line is already empty, do nothing
// Example before:
// Some line
// - item 1
// - item 2
// Example after:
// Some line
//
// - item 1
// - item 2
export function formatMarkdownForMkDocs(markdown) {
const lines = markdown.split("\n");
const formattedLines = lines.map((line, index) => {
if (line.trim().startsWith("-") && (index === 0 || lines[index - 1].trim() !== "")) {
return "\n" + line;
}
return line;
});
const formattedMarkdown = formattedLines.join("\n");
return formattedMarkdown;
}
//# sourceMappingURL=markdownUtils.js.map