Skip to content

Commit 4fab25a

Browse files
committed
feat: parse strong and em label
1 parent 00931b8 commit 4fab25a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/config/theme.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ const defaultTheme: Theme = {
157157
// 'word-break': `break-all`,
158158
},
159159

160+
em: {
161+
'font-style': `italic`,
162+
'font-size': `inherit`,
163+
},
164+
160165
link: {
161166
color: `#576b95`,
162167
},
@@ -297,6 +302,9 @@ const graceTheme = toMerged(defaultTheme, {
297302
codespan: {
298303
},
299304

305+
em: {
306+
},
307+
300308
link: {
301309
},
302310

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PropertiesHyphen } from 'csstype'
22

33
type Block = `h1` | `h2` | `h3` | `h4` | `p` | `blockquote` | `blockquote_p` | `code_pre` | `code` | `image` | `ol` | `ul` | `footnotes` | `figure` | `hr`
4-
type Inline = `listitem` | `codespan` | `link` | `wx_link` | `strong` | `table` | `thead` | `td` | `footnote` | `figcaption`
4+
type Inline = `listitem` | `codespan` | `link` | `wx_link` | `strong` | `table` | `thead` | `td` | `footnote` | `figcaption` | `em`
55

66
interface CustomCSSProperties {
77
[`--md-primary-color`]?: string

src/utils/renderer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,12 @@ export function initRenderer(opts: IOpts) {
222222
return styledContent(`link`, text, `span`)
223223
},
224224

225-
strong({ text }: Tokens.Strong): string {
226-
return styledContent(`strong`, text)
225+
strong( {tokens}: Tokens.Strong): string {
226+
return styledContent(`strong`, this.parser.parseInline(tokens))
227227
},
228228

229-
em({ text }: Tokens.Em): string {
230-
return `<span style="font-style: italic;">${text}</span>`
229+
em({ tokens }: Tokens.Em): string {
230+
return styledContent(`em`, this.parser.parseInline(tokens), `span`)
231231
},
232232

233233
table({ header, rows }: Tokens.Table): string {

0 commit comments

Comments
 (0)