Fixed Ducking. Refined UI.
This commit is contained in:
@@ -20,6 +20,7 @@ class MarkupParserModule extends BaseModule {
|
||||
'parseInline',
|
||||
'parseMusicOptions',
|
||||
'markdownToHtml',
|
||||
'markdownToPlainText',
|
||||
'smartypants',
|
||||
'escapeHtml',
|
||||
'normalizeParagraph',
|
||||
@@ -65,10 +66,11 @@ class MarkupParserModule extends BaseModule {
|
||||
flushParagraph();
|
||||
const heading = (chapter[1] || chapter[2] || '').trim();
|
||||
if (heading) {
|
||||
const normalizedHeading = this.normalizeParagraph(heading);
|
||||
blocks.push({
|
||||
type: 'heading',
|
||||
text: this.normalizeParagraph(heading),
|
||||
layoutText: this.markdownToHtml(this.normalizeParagraph(heading)),
|
||||
text: this.markdownToPlainText(normalizedHeading),
|
||||
layoutText: this.markdownToHtml(normalizedHeading),
|
||||
role: 'chapter-heading'
|
||||
});
|
||||
}
|
||||
@@ -81,10 +83,11 @@ class MarkupParserModule extends BaseModule {
|
||||
flushParagraph();
|
||||
const heading = (section[1] || section[2] || '').trim();
|
||||
if (heading) {
|
||||
const normalizedHeading = this.normalizeParagraph(heading);
|
||||
blocks.push({
|
||||
type: 'heading',
|
||||
text: this.normalizeParagraph(heading),
|
||||
layoutText: this.markdownToHtml(this.normalizeParagraph(heading)),
|
||||
text: this.markdownToPlainText(normalizedHeading),
|
||||
layoutText: this.markdownToHtml(normalizedHeading),
|
||||
role: 'section-heading'
|
||||
});
|
||||
}
|
||||
@@ -162,7 +165,7 @@ class MarkupParserModule extends BaseModule {
|
||||
parseParagraph(rawText) {
|
||||
const inline = this.parseInline(this.normalizeParagraph(rawText));
|
||||
return {
|
||||
text: inline.text,
|
||||
text: this.markdownToPlainText(inline.text),
|
||||
layoutText: this.markdownToHtml(inline.text),
|
||||
cueMarkers: inline.cueMarkers
|
||||
};
|
||||
@@ -226,6 +229,18 @@ class MarkupParserModule extends BaseModule {
|
||||
.replace(/_([^_\s][^_]*?)_/g, '<em>$1</em>');
|
||||
}
|
||||
|
||||
markdownToPlainText(text) {
|
||||
const plain = String(text || '')
|
||||
.replace(/\*\*\*([^*]+?)\*\*\*/g, '$1')
|
||||
.replace(/___([^_]+?)___/g, '$1')
|
||||
.replace(/\*\*([^*]+?)\*\*/g, '$1')
|
||||
.replace(/__([^_]+?)__/g, '$1')
|
||||
.replace(/\*([^*\s][^*]*?)\*/g, '$1')
|
||||
.replace(/_([^_\s][^_]*?)_/g, '$1');
|
||||
|
||||
return this.smartypants(plain).replace(/\s{2,}/g, ' ').trim();
|
||||
}
|
||||
|
||||
smartypants(text) {
|
||||
return String(text)
|
||||
.replace(/---/g, '\u2014')
|
||||
|
||||
Reference in New Issue
Block a user