Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
currentParagraph.addRun(currentText);
currentParagraph.spacing(h3counter === 1 ? h3marginspacing1st : h3marginspacing);
} else if (name === 'question') {
currentParagraph = new docx.Paragraph();
currentParagraph.spacing(paragraphspacing);
boldActive = true;
italicsActive = true;
} else if (name === 'ul') {
unorderedListActive = true;
} else if (name === 'ol') {
orderedListActive = true;
} else if (name === 'p' || name === 'li') {
currentParagraph = new docx.Paragraph();
// spacing
currentParagraph.spacing(paragraphspacing);
// alignment
if (!attribs.style || attribs.style.indexOf('text-align: left') > -1) {
currentParagraph.left();
} else if (attribs.style.indexOf('text-align: center') > -1) {
currentParagraph.center();
} else if (attribs.style.indexOf('text-align: right') > -1) {
currentParagraph.right();
} else if (attribs.style.indexOf('text-align: justify') > -1) {
currentParagraph.justified();
}
// indent
onopentag: function (name, attribs) {
if (name === 'exporttitle') {
currentParagraph = new docx.Paragraph();
currentParagraph.center();
currentParagraph.spacing(exportitlespacing);
boldActive = true;
} else if (name === 'exportsubtitle') {
currentParagraph = new docx.Paragraph();
currentParagraph.center();
boldActive = true;
} else if (name === 'h1') {
h1counter += 1;
currentParagraph = new docx.Paragraph();
currentParagraph.pageBreak();
boldActive = true;
let currentText = new docx.TextRun(h1counter + ' ');
currentText.size(fontSize);
currentText.font(font);
currentText.bold();
currentParagraph.addRun(currentText);
currentParagraph.spacing(h1marginspacing);
} else if (name === 'h2') {
h2counter += 1;
currentParagraph = new docx.Paragraph();
italicsActive = true;
let currentText = new docx.TextRun(h1counter + '.' + h2counter + ' ');
currentText.size(fontSize);
currentText.font(font);
} else if (name === 'h1') {
h1counter += 1;
currentParagraph = new docx.Paragraph();
currentParagraph.pageBreak();
boldActive = true;
let currentText = new docx.TextRun(h1counter + ' ');
currentText.size(fontSize);
currentText.font(font);
currentText.bold();
currentParagraph.addRun(currentText);
currentParagraph.spacing(h1marginspacing);
} else if (name === 'h2') {
h2counter += 1;
currentParagraph = new docx.Paragraph();
italicsActive = true;
let currentText = new docx.TextRun(h1counter + '.' + h2counter + ' ');
currentText.size(fontSize);
currentText.font(font);
currentText.italic();
currentParagraph.addRun(currentText);
currentParagraph.spacing(h2counter ===1 ? h2marginspacing1st : h2marginspacing);
} else if (name === 'h3') {
h3counter += 1;
currentParagraph = new docx.Paragraph();
let currentText = new docx.TextRun(h1counter + '.' + h2counter + '.' + h3counter + ' ');
currentText.size(fontSize);
currentText.font(font);
currentParagraph.addRun(currentText);
currentParagraph.spacing(h3counter === 1 ? h3marginspacing1st : h3marginspacing);
onopentag: function (name, attribs) {
if (name === 'exporttitle') {
currentParagraph = new docx.Paragraph();
currentParagraph.center();
currentParagraph.spacing(exportitlespacing);
boldActive = true;
} else if (name === 'exportsubtitle') {
currentParagraph = new docx.Paragraph();
currentParagraph.center();
boldActive = true;
} else if (name === 'h1') {
h1counter += 1;
currentParagraph = new docx.Paragraph();
currentParagraph.pageBreak();
boldActive = true;
let currentText = new docx.TextRun(h1counter + ' ');
currentText.size(fontSize);
currentText.font(font);
currentText.bold();
currentParagraph.addRun(currentText);
currentParagraph.spacing(h1marginspacing);
} else if (name === 'h2') {
onopentag: function (name, attribs) {
if (name === 'exporttitle') {
currentParagraph = new docx.Paragraph();
currentParagraph.center();
currentParagraph.spacing(exportitlespacing);
boldActive = true;
} else if (name === 'exportsubtitle') {
currentParagraph = new docx.Paragraph();
currentParagraph.center();
boldActive = true;
} else if (name === 'h1') {
h1counter += 1;
currentParagraph = new docx.Paragraph();
currentParagraph.pageBreak();
boldActive = true;
let currentText = new docx.TextRun(h1counter + ' ');
currentText.size(fontSize);