fix: bold and emphasis regex (#323)

* fix: bold and emphasis regex

* chore: udpate
This commit is contained in:
boojack 2022-10-20 21:57:40 +08:00 committed by GitHub
parent 7c9c5c316b
commit 0b2a9d8511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -123,6 +123,14 @@ console.log("hello world!")
markdown: `Important: ***Minecraft/123***`,
want: `<p>Important: <strong><em>Minecraft/123</em></strong></p>`,
},
{
markdown: `Important: **Minecraft*123***`,
want: `<p>Important: <strong>Minecraft<em>123</em></strong></p>`,
},
{
markdown: `Important: **Minecraft*123*456**`,
want: `<p>Important: <strong>Minecraft<em>123</em>456</strong></p>`,
},
{
markdown: `Important: ***[baidu](https://baidu.com)***`,
want: `<p>Important: <strong><em><a class='link' target='_blank' rel='noreferrer' href='https://baidu.com'>baidu</a></em></strong></p>`,

View File

@ -2,7 +2,7 @@ import { marked } from "..";
import Emphasis from "./Emphasis";
import Link from "./Link";
export const BOLD_REG = /\*\*([\S ]+)\*\*/;
export const BOLD_REG = /\*\*([\S *]+)\*\*/;
const renderer = (rawStr: string): string => {
const matchResult = rawStr.match(BOLD_REG);

View File

@ -2,7 +2,7 @@ import { marked } from "..";
import Bold from "./Bold";
import Link from "./Link";
export const EMPHASIS_REG = /\*([\S ]+)\*/;
export const EMPHASIS_REG = /\*([\S ]+?)\*/;
const renderer = (rawStr: string): string => {
const matchResult = rawStr.match(EMPHASIS_REG);