Skip to content

Commit 6814ba8

Browse files
committed
feat(markdown): add custom emphasis styles for strong text
1 parent 143b4f2 commit 6814ba8

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/dev.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ const options: Options = {
4141
try {
4242
// Configure marked renderer to add target="_blank" to links
4343
const renderer = {
44+
strong(token: Tokens.Strong) {
45+
if (token.raw.startsWith('**')) {
46+
return `<strong class="asterisk-emphasis">${token.text}</strong>`
47+
} else if (token.raw.startsWith('__')) {
48+
return `<strong class="underscore-emphasis">${token.text}</strong>`
49+
}
50+
return `<strong>${token.text}</strong>`
51+
},
4452
link(token: Tokens.Link) {
4553
const href = token.href || ''
4654
const title = token.title ? ` title="${token.title}"` : ''
@@ -121,6 +129,7 @@ const options: Options = {
121129
let mind = new MindElixir(options)
122130

123131
const data = MindElixir.new('new topic')
132+
// example.theme = MindElixir.DARK_THEME
124133
mind.init(example)
125134

126135
const m2 = new MindElixir({

src/exampleData/1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ const aboutMindElixir: MindElixirDataWithUseMd = {
448448
useMd: true,
449449
},
450450
{
451-
topic: '**Bold text** and *italic text* and ***bold italic***',
451+
topic: '**Bold text** and __Highlight__ and *italic text*',
452452
id: 'markdown-emphasis',
453453
useMd: true,
454454
},

src/markdown.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@
3737
font-style: italic;
3838
}
3939

40-
.map-container strong,
40+
.map-container strong.asterisk-emphasis,
4141
.map-container em {
4242
color: var(--selected);
4343
}
44+
.map-container strong.underscore-emphasis {
45+
background: rgba(255, 235, 59, 0.25); /* 可改颜色/透明度 */
46+
padding: 0.05em 0.15em;
47+
border-radius: 0.15em;
48+
}
4449

4550
.map-container a {
4651
color: var(--selected);

0 commit comments

Comments
 (0)