wip
This commit is contained in:
parent
a2519a1282
commit
57361f8c55
|
|
@ -441,8 +441,8 @@ export class RibbitEditor extends Ribbit {
|
|||
}
|
||||
|
||||
#parseInline(text: string): DocumentFragment {
|
||||
var t = text;
|
||||
text = disambiguateAsteriskRuns(text);
|
||||
|
||||
const classes: Record<string, string> = {
|
||||
'**': 'md-bold',
|
||||
'*': 'md-italic',
|
||||
|
|
@ -450,10 +450,18 @@ export class RibbitEditor extends Ribbit {
|
|||
'`': 'md-code',
|
||||
};
|
||||
|
||||
// ***bold italic***
|
||||
// ***italic* bold**
|
||||
// **bold *italic***
|
||||
// ***bold** italic* x
|
||||
// *italic **bold*** x
|
||||
|
||||
const INLINE_PATTERN = new RegExp(
|
||||
'\\[(?<linkLabel>[^\\]]+)\\]\\((?<linkHref>[^)]+)\\)' +
|
||||
'|' +
|
||||
'(?<delimiter>\\*{3}|\\*{2}|\\*|~~|`)(?<content>.+)(?<closer>\\k<delimiter>(?!\\*))',
|
||||
'(?<delimiter>\\*{2}|\\*|~~|`)' +
|
||||
'(?<content>[^*].+?)' +
|
||||
'(?<closer>\\k<delimiter>(?!\\*))',
|
||||
'g'
|
||||
);
|
||||
|
||||
|
|
@ -462,7 +470,7 @@ export class RibbitEditor extends Ribbit {
|
|||
let match: RegExpExecArray | null;
|
||||
|
||||
while ((match = INLINE_PATTERN.exec(text)) !== null) {
|
||||
console.log(match, match.index, lastIndex);
|
||||
console.log(`DELIM: ${match.groups!.delimiter} CONTENT: ${match.groups!.content} CLOSER: ${match.groups!.closer}`);
|
||||
if (match.index > lastIndex) {
|
||||
fragment.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
|
||||
}
|
||||
|
|
@ -475,6 +483,7 @@ export class RibbitEditor extends Ribbit {
|
|||
fragment.appendChild(document.createTextNode(text.slice(lastIndex)));
|
||||
}
|
||||
|
||||
console.log(`'${t}' => '${text.replace('\u200C', '|')}`, fragment.children);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
|
@ -821,9 +830,7 @@ export class RibbitEditor extends Ribbit {
|
|||
}
|
||||
|
||||
#blockToMarkdown(block: HTMLElement): string {
|
||||
console.log(block);
|
||||
if (!block.textContent!.trim() && block.querySelector('br')) {
|
||||
console.log(`'${block.textContent}' appears empty, so returning empty string`);
|
||||
return '';
|
||||
}
|
||||
if (block.dataset.macro) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user