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
4b860777
Unverified
Commit
4b860777
authored
Jan 08, 2023
by
boojack
Committed by
GitHub
Jan 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: tag generate in code block (#925)
parent
e29924c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
6 deletions
+7
-6
index.tsx
web/src/labs/marked/index.tsx
+4
-1
CodeBlock.tsx
web/src/labs/marked/parser/CodeBlock.tsx
+1
-3
home.less
web/src/less/home.less
+1
-1
siderbar.less
web/src/less/siderbar.less
+1
-1
No files found.
web/src/labs/marked/index.tsx
View file @
4b860777
...
@@ -99,11 +99,14 @@ export const getMatchedNodes = (markdownStr: string): MatchedNode[] => {
...
@@ -99,11 +99,14 @@ export const getMatchedNodes = (markdownStr: string): MatchedNode[] => {
if
(
parser
.
name
===
"br"
)
{
if
(
parser
.
name
===
"br"
)
{
return
walkthough
(
retainContent
,
blockParsers
,
inlineParsers
);
return
walkthough
(
retainContent
,
blockParsers
,
inlineParsers
);
}
else
{
}
else
{
if
(
retainContent
.
startsWith
(
"
\n
"
)
)
{
if
(
parser
.
name
!==
"code block"
)
{
walkthough
(
matchedStr
,
[],
inlineParsers
);
walkthough
(
matchedStr
,
[],
inlineParsers
);
}
if
(
retainContent
.
startsWith
(
"
\n
"
))
{
return
walkthough
(
retainContent
.
slice
(
1
),
blockParsers
,
inlineParsers
);
return
walkthough
(
retainContent
.
slice
(
1
),
blockParsers
,
inlineParsers
);
}
}
}
}
return
""
;
}
}
let
matchedInlineParser
=
undefined
;
let
matchedInlineParser
=
undefined
;
...
...
web/src/labs/marked/parser/CodeBlock.tsx
View file @
4b860777
import
copy
from
"copy-to-clipboard"
;
import
copy
from
"copy-to-clipboard"
;
import
hljs
from
"highlight.js"
;
import
hljs
from
"highlight.js"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
import
toastHelper
from
"../../../components/Toast"
;
import
toastHelper
from
"../../../components/Toast"
;
export
const
CODE_BLOCK_REG
=
/^```
(\S
*
?)\s([\s\S]
*
?)
```/
;
export
const
CODE_BLOCK_REG
=
/^```
(\S
*
?)\s([\s\S]
*
?)
```/
;
const
renderer
=
(
rawStr
:
string
)
=>
{
const
renderer
=
(
rawStr
:
string
)
=>
{
const
{
t
}
=
useTranslation
();
const
matchResult
=
matcher
(
rawStr
,
CODE_BLOCK_REG
);
const
matchResult
=
matcher
(
rawStr
,
CODE_BLOCK_REG
);
if
(
!
matchResult
)
{
if
(
!
matchResult
)
{
return
<>
{
rawStr
}
</>;
return
<>
{
rawStr
}
</>;
...
@@ -27,7 +25,7 @@ const renderer = (rawStr: string) => {
...
@@ -27,7 +25,7 @@ const renderer = (rawStr: string) => {
const
handleCopyButtonClick
=
()
=>
{
const
handleCopyButtonClick
=
()
=>
{
copy
(
matchResult
[
2
]);
copy
(
matchResult
[
2
]);
toastHelper
.
success
(
t
(
"message.succeed-copy-code"
)
);
toastHelper
.
success
(
"Copy succeed"
);
};
};
return
(
return
(
...
...
web/src/less/home.less
View file @
4b860777
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
}
}
> .page-container {
> .page-container {
@apply relative w-full
min-h-full
mx-auto flex flex-row justify-start sm:justify-center items-start;
@apply relative w-full
h-auto
mx-auto flex flex-row justify-start sm:justify-center items-start;
> .sidebar-wrapper {
> .sidebar-wrapper {
@apply flex-shrink-0 ml-calc;
@apply flex-shrink-0 ml-calc;
...
...
web/src/less/siderbar.less
View file @
4b860777
.sidebar-wrapper {
.sidebar-wrapper {
@apply fixed sm:sticky top-0 z-30 sm:z-0 -translate-x-64 sm:translate-x-0 sm:flex flex-col justify-start items-start w-64 h-
full
py-4 pl-2 bg-white dark:bg-zinc-800 sm:bg-transparent overflow-x-hidden overflow-y-auto transition-transform duration-300 overscroll-contain hide-scrollbar;
@apply fixed sm:sticky top-0 z-30 sm:z-0 -translate-x-64 sm:translate-x-0 sm:flex flex-col justify-start items-start w-64 h-
auto max-h-screen
py-4 pl-2 bg-white dark:bg-zinc-800 sm:bg-transparent overflow-x-hidden overflow-y-auto transition-transform duration-300 overscroll-contain hide-scrollbar;
&.show {
&.show {
@apply translate-x-0 shadow-2xl sm:shadow-none;
@apply translate-x-0 shadow-2xl sm:shadow-none;
...
...
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