Skip to content

Commit

Permalink
feat: parse strong and em label
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Sep 4, 2024
1 parent 00931b8 commit 4fab25a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/config/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ const defaultTheme: Theme = {
// 'word-break': `break-all`,
},

em: {
'font-style': `italic`,
'font-size': `inherit`,
},

link: {
color: `#576b95`,
},
Expand Down Expand Up @@ -297,6 +302,9 @@ const graceTheme = toMerged(defaultTheme, {
codespan: {
},

em: {
},

link: {
},

Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PropertiesHyphen } from 'csstype'

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

interface CustomCSSProperties {
[`--md-primary-color`]?: string
Expand Down
8 changes: 4 additions & 4 deletions src/utils/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ export function initRenderer(opts: IOpts) {
return styledContent(`link`, text, `span`)
},

strong({ text }: Tokens.Strong): string {
return styledContent(`strong`, text)
strong( {tokens}: Tokens.Strong): string {
return styledContent(`strong`, this.parser.parseInline(tokens))
},

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

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

0 comments on commit 4fab25a

Please sign in to comment.