Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
0b34b142
Unverified
Commit
0b34b142
authored
Oct 21, 2022
by
boojack
Committed by
GitHub
Oct 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update marked (#325)
parent
0b2a9d85
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
15 deletions
+27
-15
marked.test.ts
web/src/labs/marked/marked.test.ts
+0
-8
Bold.ts
web/src/labs/marked/parser/Bold.ts
+2
-3
BoldEmphasis.ts
web/src/labs/marked/parser/BoldEmphasis.ts
+20
-0
Emphasis.ts
web/src/labs/marked/parser/Emphasis.ts
+1
-2
Link.ts
web/src/labs/marked/parser/Link.ts
+2
-1
index.ts
web/src/labs/marked/parser/index.ts
+2
-1
No files found.
web/src/labs/marked/marked.test.ts
View file @
0b34b142
...
...
@@ -123,14 +123,6 @@ 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>`
,
...
...
web/src/labs/marked/parser/Bold.ts
View file @
0b34b142
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
);
...
...
@@ -10,7 +9,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Emphasis
,
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
]);
return
`<strong>
${
parsedContent
}
</strong>`
;
};
...
...
web/src/labs/marked/parser/BoldEmphasis.ts
0 → 100644
View file @
0b34b142
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
export
const
BOLD_EMPHASIS_REG
=
/
\*\*\*([\S
]
+
?)\*\*\*
/
;
const
renderer
=
(
rawStr
:
string
):
string
=>
{
const
matchResult
=
rawStr
.
match
(
BOLD_EMPHASIS_REG
);
if
(
!
matchResult
)
{
return
rawStr
;
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
]);
return
`<strong><em>
${
parsedContent
}
</em></strong>`
;
};
export
default
{
name
:
"bold emphasis"
,
regex
:
BOLD_EMPHASIS_REG
,
renderer
,
};
web/src/labs/marked/parser/Emphasis.ts
View file @
0b34b142
import
{
marked
}
from
".."
;
import
Bold
from
"./Bold"
;
import
Link
from
"./Link"
;
export
const
EMPHASIS_REG
=
/
\*([\S
]
+
?)\*
/
;
...
...
@@ -10,7 +9,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Bold
,
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
]);
return
`<em>
${
parsedContent
}
</em>`
;
};
...
...
web/src/labs/marked/parser/Link.ts
View file @
0b34b142
...
...
@@ -3,6 +3,7 @@ import Emphasis from "./Emphasis";
import
Bold
from
"./Bold"
;
import
{
marked
}
from
".."
;
import
InlineCode
from
"./InlineCode"
;
import
BoldEmphasis
from
"./BoldEmphasis"
;
export
const
LINK_REG
=
/
\[(
.*
?)\]\((
.+
?)\)
/
;
...
...
@@ -11,7 +12,7 @@ const renderer = (rawStr: string): string => {
if
(
!
matchResult
)
{
return
rawStr
;
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
InlineCode
,
Emphasis
,
Bold
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
InlineCode
,
BoldEmphasis
,
Emphasis
,
Bold
]);
return
`<a class='link' target='_blank' rel='noreferrer' href='
${
escape
(
matchResult
[
2
])}
'>
${
parsedContent
}
</a>`
;
};
...
...
web/src/labs/marked/parser/index.ts
View file @
0b34b142
...
...
@@ -14,6 +14,7 @@ import PlainLink from "./PlainLink";
import
InlineCode
from
"./InlineCode"
;
import
PlainText
from
"./PlainText"
;
import
Table
from
"./Table"
;
import
BoldEmphasis
from
"./BoldEmphasis"
;
export
{
CODE_BLOCK_REG
}
from
"./CodeBlock"
;
export
{
TODO_LIST_REG
}
from
"./TodoList"
;
...
...
@@ -26,5 +27,5 @@ export { TABLE_REG } from "./Table";
// The order determines the order of execution.
export
const
blockElementParserList
=
[
Table
,
CodeBlock
,
TodoList
,
DoneList
,
OrderedList
,
UnorderedList
,
Paragraph
];
export
const
inlineElementParserList
=
[
Image
,
Mark
,
Bold
,
Emphasis
,
Link
,
InlineCode
,
PlainLink
,
Tag
,
PlainText
];
export
const
inlineElementParserList
=
[
Image
,
Mark
,
Bold
Emphasis
,
Bold
,
Emphasis
,
Link
,
InlineCode
,
PlainLink
,
Tag
,
PlainText
];
export
const
parserList
=
[...
blockElementParserList
,
...
inlineElementParserList
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment