Update Core.js
This commit is contained in:
parent
434b38e302
commit
0b60398337
1 changed files with 12 additions and 8 deletions
20
Core.js
20
Core.js
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* SimonUp Core Compiler (Core.js) - Version 1.2
|
* SimonUp Core Compiler (Core.js) - Version 1.2.1
|
||||||
* Eine moderne, fluss- und blockorientierte Auszeichnungssprache.
|
* Eine moderne, fluss- und blockorientierte Auszeichnungssprache.
|
||||||
*/
|
*/
|
||||||
class SimonUp {
|
class SimonUp {
|
||||||
|
|
@ -129,7 +129,6 @@ class SimonUp {
|
||||||
const intro = lines.map(function(l) { return self._parseInline(l); }).join('<br>');
|
const intro = lines.map(function(l) { return self._parseInline(l); }).join('<br>');
|
||||||
tocWrapper += `<p class="toc-intro">${intro}</p>\n`;
|
tocWrapper += `<p class="toc-intro">${intro}</p>\n`;
|
||||||
}
|
}
|
||||||
// Ein Text-Token, das garantiert nicht vom Browser unsichtbar gemacht wird:
|
|
||||||
tocWrapper += 'STRENG_GEHEIMER_TOC_PLATZHALTER\n';
|
tocWrapper += 'STRENG_GEHEIMER_TOC_PLATZHALTER\n';
|
||||||
tocWrapper += '</div>';
|
tocWrapper += '</div>';
|
||||||
return tocWrapper;
|
return tocWrapper;
|
||||||
|
|
@ -224,10 +223,16 @@ class SimonUp {
|
||||||
|
|
||||||
html = html.replace(/\/\/(( \s|$))/g, '$1');
|
html = html.replace(/\/\/(( \s|$))/g, '$1');
|
||||||
|
|
||||||
// 1. ZUERST: Standard Text-Inline-Rules parsen
|
// 1. ZUERST: Die kritischen Doppel-Sterne (fett) verarbeiten
|
||||||
|
html = html.replace(/\*\*(.+?)\\\*\*/g, '<strong>$1</strong>');
|
||||||
|
html = html.replace(/\*\*(.+?)(?=\*\*|$)/g, '<strong>$1</strong>');
|
||||||
|
|
||||||
|
// 2. DANACH: Das einzelne Sternchen (medium) separat behandeln, damit es keine Tags beschädigt
|
||||||
|
html = html.replace(/\*(.+?)\\\*/g, '<span style="font-weight: 500;">$1</span>');
|
||||||
|
html = html.replace(/\*(.+?)(?=\*|$)/g, '<span style="font-weight: 500;">$1</span>');
|
||||||
|
|
||||||
|
// 3. Restliche Standard Text-Inline-Rules parsen
|
||||||
const inlineRules = [
|
const inlineRules = [
|
||||||
{ tag: 'strong', symbol: '\\*\\*' },
|
|
||||||
{ tag: 'span style="font-weight: 500;"', symbol: '\\*' },
|
|
||||||
{ tag: 'em', symbol: '%' },
|
{ tag: 'em', symbol: '%' },
|
||||||
{ tag: 'u', symbol: '_' },
|
{ tag: 'u', symbol: '_' },
|
||||||
{ tag: 'del', symbol: '~' },
|
{ tag: 'del', symbol: '~' },
|
||||||
|
|
@ -248,7 +253,7 @@ class SimonUp {
|
||||||
html = html.replace(resetRegex, `<${rule.tag}>$1</${tagSimple}>`);
|
html = html.replace(resetRegex, `<${rule.tag}>$1</${tagSimple}>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. DANACH: Überschriften generieren (schützt generierte id="" Attribute vor den Regeln oben)
|
// 4. Überschriften generieren
|
||||||
let self = this;
|
let self = this;
|
||||||
const processHeading = function(pattern, callback) {
|
const processHeading = function(pattern, callback) {
|
||||||
let match;
|
let match;
|
||||||
|
|
@ -288,7 +293,7 @@ class SimonUp {
|
||||||
return `<h${level} id="${id}">${title}</h${level}>${rest}`;
|
return `<h${level} id="${id}">${title}</h${level}>${rest}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3. RESTLICHE STRUKTUREN (Ausrichtungen, Links, Medien)
|
// 5. RESTLICHE STRUKTUREN (Ausrichtungen, Links, Medien)
|
||||||
const alignMap = { 'l': 'left', 'r': 'right', 'c': 'center', 'j': 'justify' };
|
const alignMap = { 'l': 'left', 'r': 'right', 'c': 'center', 'j': 'justify' };
|
||||||
html = html.replace(/>([lrcj])\s+(.+?)\s*\/>/g, function(m, dir, content) {
|
html = html.replace(/>([lrcj])\s+(.+?)\s*\/>/g, function(m, dir, content) {
|
||||||
return `<div style="text-align: ${alignMap[dir]};">${content}</div>`;
|
return `<div style="text-align: ${alignMap[dir]};">${content}</div>`;
|
||||||
|
|
@ -335,7 +340,6 @@ class SimonUp {
|
||||||
* INTERN: Erzeugt die fertige HTML-Liste des TOC und injiziert sie in den Block
|
* INTERN: Erzeugt die fertige HTML-Liste des TOC und injiziert sie in den Block
|
||||||
*/
|
*/
|
||||||
_injectTOC(html) {
|
_injectTOC(html) {
|
||||||
// Jetzt als absolut lesbarer, unmissverständlicher Text-String!
|
|
||||||
const placeholder = 'STRENG_GEHEIMER_TOC_PLATZHALTER';
|
const placeholder = 'STRENG_GEHEIMER_TOC_PLATZHALTER';
|
||||||
|
|
||||||
if (!html.includes(placeholder)) {
|
if (!html.includes(placeholder)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue