fix inline tags being tokenized as blocks
This commit is contained in:
1 parent
0df3677579
commit
928cb87fa7
6 files changed
+13
-5
No files matched your search
Vendored
+1
-1
@@ -144,7 +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();
|
||||
|
||||
Vendored
+4
-1
@@ -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;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
export type TokenRole = 'open' | 'close' | 'block';
|
||||
export type TokenRole = 'open' | 'close' | 'block' | 'text';
|
||||
export interface Token {
|
||||
role: TokenRole;
|
||||
value: string;
|
||||
|
||||
+5
-1
@@ -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
@@ -1,4 +1,4 @@
|
||||
export type TokenRole = 'open' | 'close' | 'block';
|
||||
export type TokenRole = 'open' | 'close' | 'block' | 'text';
|
||||
|
||||
export interface Token {
|
||||
role: TokenRole;
|
||||
|
||||
@@ -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>');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user