diff --git a/Core.js b/Core.js
index 11b43f6..c8653c6 100644
--- a/Core.js
+++ b/Core.js
@@ -94,10 +94,12 @@ class SimonUp {
if (trimmed === '___') {
result.push('
');
} else if (trimmed.startsWith('- ')) {
- result.push('' + this._parseInline(line.replace(/^\s*-\s+/, '')) + '');
+ let insideUl = this._parseInline(line.replace(/^\s*-\s+/, ''));
+ result.push(`${insideUl}`);
} else if (/^\d+\.\s+/.test(trimmed)) {
let cleanLine = line.replace(/^\s*\d+\.\s+/, '');
- result.push('' + this._parseInline(cleanLine) + '');
+ let insideOl = this._parseInline(cleanLine);
+ result.push(`${insideOl}`);
} else {
result.push(this._parseInline(line));
}
@@ -112,6 +114,7 @@ class SimonUp {
*/
_renderBlock(type, meta, lines) {
const content = lines.join('\n');
+ let self = this;
switch (type) {
case 'toc':
@@ -119,44 +122,45 @@ class SimonUp {
if (meta || content.trim()) {
tocWrapper = '\n';
if (meta) {
- tocWrapper += '
' + meta + '
\n';
+ tocWrapper += `
${meta}
\n`;
}
if (content.trim()) {
- let self = this;
const intro = lines.map(function(l) { return self._parseInline(l); }).join('
');
- tocWrapper += '
' + intro + '
\n';
+ tocWrapper += `
${intro}
\n`;
}
tocWrapper += '\n
';
}
return tocWrapper;
case 'c':
- const langClass = meta ? ' class="language-' + meta + '"' : '';
+ const langClass = meta ? ` class="language-${meta}"` : '';
const escapedCode = content.replace(/&/g, '&').replace(//g, '>');
- return '' + escapedCode + '
';
+ return `${escapedCode}
`;
case 'q':
- let selfQ = this;
- return '' + lines.map(function(l) { return selfQ._parseInline(l); }).join('
') + '
';
+ const qContent = lines.map(function(l) { return self._parseInline(l); }).join('
');
+ return `${qContent}
`;
case 'b':
- let selfB = this;
- return '' + lines.map(function(l) { return selfB._parseInline(l); }).join('
') + '
';
+ const bContent = lines.map(function(l) { return self._parseInline(l); }).join('
');
+ return `${bContent}
`;
case 'f':
- let selfF = this;
- return '\n' + (meta || 'Details') + '
\n' + lines.map(function(l) { return selfF._parseInline(l); }).join('
') + '
\n ';
+ const fSummary = meta || 'Details';
+ const fContent = lines.map(function(l) { return self._parseInline(l); }).join('
');
+ return `\n${fSummary}
\n${fContent}
\n `;
case 'i':
- let selfI = this;
- return '\n' + lines.map(function(l) { return selfI._parseInline(l); }).join('
') + '\n
';
+ const iColor = meta || '#ff6347';
+ const iContent = lines.map(function(l) { return self._parseInline(l); }).join('
');
+ return `\n${iContent}\n
`;
case 't':
return this._renderTable(meta, lines);
default:
- let selfDef = this;
- return '' + lines.map(function(l) { return selfDef._parseInline(l); }).join('
') + '
';
+ const defContent = lines.map(function(l) { return self._parseInline(l); }).join('
');
+ return `${defContent}
`;
}
}
@@ -192,9 +196,10 @@ class SimonUp {
if (line.endsWith('|') && currentCells.length > 0) {
let rowContent = currentCells.map(function(c) {
- return '' + self._parseInline(c.trim()).replace(/\n/g, ' ') + ' | ';
+ let parsedCell = self._parseInline(c.trim()).replace(/\n/g, '
');
+ return `${parsedCell} | `;
}).join('\n');
- tableHtml += '\n' + rowContent + '\n
\n';
+ tableHtml += `\n${rowContent}\n
\n`;
currentCells = [];
}
}
@@ -212,7 +217,7 @@ class SimonUp {
const escapes = [];
html = html.replace(/\\(.)/g, function(match, char) {
escapes.push(char);
- return '';
+ return ``;
});
html = html.replace(/\/\/(\s|$)/g, '$1');
@@ -240,20 +245,20 @@ class SimonUp {
processHeading(/^([1-6])x#\s*(.*)/g, function(level, title, rest) {
const numStr = self._getAutoNumber(level);
- const fullTitle = numStr + ' ' + title;
+ const fullTitle = `${numStr} ${title}`;
const id = self._slugify(fullTitle);
self.headings.push({ level: level, text: fullTitle, id: id });
- return '' + fullTitle + '' + rest;
+ return `${fullTitle}${rest}`;
});
processHeading(/^([1-6])-#\s*(.*)/g, function(level, title, rest) {
- return '' + title + '' + rest;
+ return `${title}${rest}`;
});
processHeading(/^([1-6])#\s*(.*)/g, function(level, title, rest) {
const id = self._slugify(title);
self.headings.push({ level: level, text: title, id: id });
- return '' + title + '' + rest;
+ return `${title}${rest}`;
});
const inlineRules = [
@@ -270,18 +275,20 @@ class SimonUp {
for (let k = 0; k < inlineRules.length; k++) {
let rule = inlineRules[k];
+ let tagSimple = rule.tag.split(' ')[0];
+
let regex = new RegExp(rule.symbol + '(.+?)\\x2F' + rule.symbol, 'g');
- html = html.replace(regex, '<' + rule.tag + '>$1' + rule.tag.split(' ')[0] + '>');
+ html = html.replace(regex, `<${rule.tag}>$1${tagSimple}>`);
let resetRegex = new RegExp(rule.symbol + '(.+?)(?=)', 'g');
- html = html.replace(resetRegex, '<' + rule.tag + '>$1' + rule.tag.split(' ')[0] + '>');
+ html = html.replace(resetRegex, `<${rule.tag}>$1${tagSimple}>`);
}
html = html.replace(//g, '');
const alignMap = { 'l': 'left', 'r': 'right', 'c': 'center', 'j': 'justify' };
html = html.replace(/>([lrcj])\s+(.+?)\s*\/>/g, function(m, dir, content) {
- return '' + content + '
';
+ return `${content}
`;
});
html = html.replace(/!\[([^\]]+)\s+w:(\d+)\]\(([^)]+)\)/g, '
');
@@ -325,8 +332,12 @@ class SimonUp {
* INTERN: Erzeugt die fertige HTML-Liste des TOC und injiziert sie in den Block
*/
_injectTOC(html) {
- if (!html.includes('')) return html;
- if (this.headings.length === 0) return html.replace('', '');
+ if (!html.includes('')) {
+ return html;
+ }
+ if (this.headings.length === 0) {
+ return html.replace('', '');
+ }
let tocListHtml = '\n
\n';
let currentLevel = 1;
@@ -334,16 +345,19 @@ class SimonUp {
for (let i = 0; i < this.headings.length; i++) {
let heading = this.headings[i];
if (heading.level > currentLevel) {
- tocListHtml += '\n'.repeat(heading.level - currentLevel);
+ let diffUp = heading.level - currentLevel;
+ tocListHtml += '\n'.repeat(diffUp);
} else if (heading.level < currentLevel) {
- tocListHtml += '
\n'.repeat(currentLevel - heading.level);
+ let diffDown = currentLevel - heading.level;
+ tocListHtml += '
\n'.repeat(diffDown);
}
currentLevel = heading.level;
- tocListHtml += '- ' + heading.text + '
\n';
+ tocListHtml += `- ${heading.text}
\n`;
}
if (currentLevel > 1) {
- tocListHtml += '
\n'.repeat(currentLevel - 1);
+ let diffFinal = currentLevel - 1;
+ tocListHtml += '\n'.repeat(diffFinal);
}
tocListHtml += '\n
';
@@ -361,8 +375,8 @@ class SimonUp {
const flushList = function() {
if (listBuffer.length > 0) {
- let items = listBuffer.map(function(item) { return ' ' + item + ''; }).join('\n');
- processed.push('<' + currentListType + '>\n' + items + '\n' + currentListType + '>');
+ let items = listBuffer.map(function(item) { return ` ${item}`; }).join('\n');
+ processed.push(`<${currentListType}>\n${items}\n${currentListType}>`);
listBuffer = [];
currentListType = null;
}
@@ -370,7 +384,8 @@ class SimonUp {
const flushParagraph = function() {
if (paragraphBuffer.length > 0) {
- processed.push('' + paragraphBuffer.join('
') + '
');
+ let pContent = paragraphBuffer.join('
');
+ processed.push(`${pContent}
`);
paragraphBuffer = [];
}
};