Add glossary hover presentation
This commit is contained in:
@@ -18,6 +18,7 @@ class MarkupParserModule extends BaseModule {
|
||||
'parse',
|
||||
'parseParagraph',
|
||||
'parseInline',
|
||||
'extractGlossaryTags',
|
||||
'parseImageOptions',
|
||||
'parseSfxOptions',
|
||||
'parseMusicOptions',
|
||||
@@ -227,6 +228,21 @@ class MarkupParserModule extends BaseModule {
|
||||
return this.smartypants(plain).replace(/\s{2,}/g, ' ').trim();
|
||||
}
|
||||
|
||||
extractGlossaryTags(tags = []) {
|
||||
if (!Array.isArray(tags)) return [];
|
||||
|
||||
return tags
|
||||
.filter(tag => String(tag?.key || '').toLowerCase() === 'gloss')
|
||||
.map(tag => {
|
||||
const term = String(tag?.value || '').trim();
|
||||
const definition = String(tag?.param || '').trim();
|
||||
if (!term || !definition) return null;
|
||||
return { term, definition };
|
||||
})
|
||||
.filter(Boolean)
|
||||
.sort((a, b) => b.term.length - a.term.length);
|
||||
}
|
||||
|
||||
smartypants(text) {
|
||||
const result = String(text)
|
||||
.replace(/---/g, '\u2014')
|
||||
|
||||
Reference in New Issue
Block a user