Commit b955fb2d authored by BERTHAUT Florent's avatar BERTHAUT Florent
Browse files

Fixed lists by building html first and converting to odt

parent bf2366ae
No preview for this file type
......@@ -85,19 +85,19 @@ function writeFilteredFicheToStr(guide, f) {
const empty = /\s*/;
//header
guide.str +="<div custom-style='Page Break'>\n";
guide.str += "LEA "+f["Année"]+" "+f["Parcours"]+" S"+String(f["Semestre"]).trim();
guide.str += "\n\n";
guide.str += "</div>\n";
for(let destField of parcFilt.keys()) {
guide.str += "["+destField+" : ]{custom-style='Paragraph Title'} \t";
guide.str +="<p>\n";
guide.str += "<span custom-style='Paragraph Title'>"+destField+": </span> ";
//guide.str += destField+" ";
for(let origField of parcFilt.get(destField)) {
guide.str += f[origField];
guide.str += "\n";
guide.str += f[origField]+" ";
}
guide.str +="\n\n";
guide.str +="</p>\n";
}
guide.str +="\\pagebreak\n\n"
}
function writeFicheToStr(guide, f) {
......@@ -181,39 +181,49 @@ function saveAllToDocs() {
}
//Write the markdown file
fs.writeFileSync(guideFileName+".md", guide.str, {"encoding":"utf-8"});
console.log("Done building guide.md");
//Write the html file
fs.writeFileSync(guideFileName+".html", guide.str, {"encoding":"utf-8"});
console.log("Done building guide.html");
//Transform to odt and html using pandoc
for(let f of ["odt", "html"]) {
console.log("Converting to guide."+f);
//Transform from html to markdown
let commandHTML = "pandoc ";//--lua-filter=src/pagebreak.lua ";
commandHTML+=" -f html "+guideFileName+".html ";
commandHTML+=" -t markdown -o "+guideFileName+".md";
exec(commandHTML,
(error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
let command = "pandoc -t odt+smart --lua-filter=src/pagebreak.lua ";
command+=" --lua-filter src/odt-custom-styles.lua ";
command+="-f markdown "+guideFileName+".md ";
if(f=="odt") {
command+="--reference-doc='input/reference.odt' ";
}
command+=" -o "+guideFileName+"."+f;
//Transfrom markdown to doc/odt
let commandODT = "pandoc -t odt+smart ";
commandODT+=" --lua-filter src/odt-custom-styles.lua ";
commandODT+=" -f markdown "+guideFileName+".md ";
commandODT+=" --reference-doc='input/reference.odt' ";
commandODT+=" -o "+guideFileName+".odt ";
exec(command,
exec(commandODT,
(error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
let commandPDF = "libreoffice --headless --convert-to pdf";
commandPDF +=guideFileName+".odt --outdir output";
//Convert odt to pdf using libreoffice
exec(commandPDF,
(error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
});
});
}
});
//Convert odt to pdf using libreoffice
exec("libreoffice --headless --convert-to pdf "+guideFileName+".odt --outdir output",
(error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
});
}
console.log("Done converting");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment