Compare commits

..
2 Commits
Author SHA256 Message Date
evilchili 928cb87fa7 fix inline tags being tokenized as blocks 2026-10-21 12:30:24 -07:00
evilchili 0df3677579 Fix getByName() 2026-10-21 11:40:29 -07:00
7 changed files with 14 additions and 10 deletions

No files matched your search

+1 -3
View File
@@ -144,9 +144,7 @@ class TagCollection {
}
}
getByName(name) {
return this.tags.filter(t => {
t.constructor.name == name;
})[0] || undefined;
return this.tags.filter(t => { return t.constructor.name == name; })[0] || undefined;
}
getByElementName(element) {
const el = element.toUpperCase();
+4 -1
View File
@@ -63,7 +63,7 @@ class Tokenizer {
const flushText = () => {
if (textBuffer.length > 0) {
tokens.push({
role: 'block',
role: 'text',
value: textBuffer,
});
textBuffer = '';
@@ -189,6 +189,9 @@ class Tokenizer {
&& (charAfter === undefined || PUNCTUATION.has(charAfter) || charAfter === '\n');
const role = leftFlanking ? 'open' : rightFlanking ? 'close' : 'block';
var token = tag.tokenize(role, sequence, source);
if (role == 'block' && !tag.isBlock) {
continue;
}
if (token) {
return token;
}
+1 -1
View File
@@ -1,4 +1,4 @@
export type TokenRole = 'open' | 'close' | 'block';
export type TokenRole = 'open' | 'close' | 'block' | 'text';
export interface Token {
role: TokenRole;
value: string;
+1 -3
View File
@@ -158,9 +158,7 @@ export class TagCollection implements TagCollectionType {
}
getByName(name: string): TagType | undefined {
return this.tags.filter(t => {
t.constructor.name == name
})[0] || undefined;
return this.tags.filter(t => { return t.constructor.name == name })[0] || undefined;
}
getByElementName(element: string): TagType | undefined {
+5 -1
View File
@@ -78,7 +78,7 @@ export class Tokenizer {
const flushText = () => {
if (textBuffer.length > 0) {
tokens.push({
role: 'block',
role: 'text',
value: textBuffer,
});
textBuffer = '';
@@ -226,6 +226,10 @@ export class Tokenizer {
var token: Token | null = tag.tokenize(role, sequence, source);
if (role == 'block' && !tag.isBlock) {
continue;
}
if (token) {
return token;
}
+1 -1
View File
@@ -1,4 +1,4 @@
export type TokenRole = 'open' | 'close' | 'block';
export type TokenRole = 'open' | 'close' | 'block' | 'text';
export interface Token {
role: TokenRole;
+1
View File
@@ -153,6 +153,7 @@ suite('Markdown to HTML Round-Trips', () => {
assert('Escape sequence \\`', '\\`not code\\`', '<p>\\`not code\\`</p>');
assert('trailing space', '*i* ', '<p><em>i</em> </p>');
assert('no closing delim', '*', '<p>*</p>');
});
});