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
b19c3c6d
Unverified
Commit
b19c3c6d
authored
Jan 12, 2023
by
boojack
Committed by
GitHub
Jan 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update renderer in list (#935)
parent
8c146aed
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
19 deletions
+29
-19
DoneList.tsx
web/src/labs/marked/parser/DoneList.tsx
+4
-3
Emphasis.tsx
web/src/labs/marked/parser/Emphasis.tsx
+2
-1
Heading.tsx
web/src/labs/marked/parser/Heading.tsx
+10
-5
OrderedList.tsx
web/src/labs/marked/parser/OrderedList.tsx
+5
-4
TodoList.tsx
web/src/labs/marked/parser/TodoList.tsx
+4
-3
UnorderedList.tsx
web/src/labs/marked/parser/UnorderedList.tsx
+4
-3
No files found.
web/src/labs/marked/parser/DoneList.tsx
View file @
b19c3c6d
...
@@ -2,17 +2,18 @@ import { inlineElementParserList } from ".";
...
@@ -2,17 +2,18 @@ import { inlineElementParserList } from ".";
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
export
const
DONE_LIST_REG
=
/^-
\[[
xX
]\]
([^\n]
+
)
/
;
export
const
DONE_LIST_REG
=
/^
(
*
)
-
\[[
xX
]\]
([^\n]
+
)
/
;
const
renderer
=
(
rawStr
:
string
)
=>
{
const
renderer
=
(
rawStr
:
string
)
=>
{
const
matchResult
=
matcher
(
rawStr
,
DONE_LIST_REG
);
const
matchResult
=
matcher
(
rawStr
,
DONE_LIST_REG
);
if
(
!
matchResult
)
{
if
(
!
matchResult
)
{
return
rawStr
;
return
rawStr
;
}
}
const
space
=
matchResult
[
1
];
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
inlineElementParserList
);
const
parsedContent
=
marked
(
matchResult
[
2
],
[],
inlineElementParserList
);
return
(
return
(
<
p
className=
"li-container"
>
<
p
className=
"li-container"
>
<
span
className=
"whitespace-pre"
>
{
space
}
</
span
>
<
span
className=
"todo-block done"
data
-
value=
"DONE"
>
<
span
className=
"todo-block done"
data
-
value=
"DONE"
>
✓
✓
</
span
>
</
span
>
...
...
web/src/labs/marked/parser/Emphasis.tsx
View file @
b19c3c6d
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
import
Link
from
"./Link"
;
import
Link
from
"./Link"
;
import
PlainLink
from
"./PlainLink"
;
import
PlainText
from
"./PlainText"
;
import
PlainText
from
"./PlainText"
;
export
const
EMPHASIS_REG
=
/
\*(
.+
?)\*
/
;
export
const
EMPHASIS_REG
=
/
\*(
.+
?)\*
/
;
...
@@ -11,7 +12,7 @@ const renderer = (rawStr: string) => {
...
@@ -11,7 +12,7 @@ const renderer = (rawStr: string) => {
return
rawStr
;
return
rawStr
;
}
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
,
PlainText
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
,
Plain
Link
,
Plain
Text
]);
return
<
em
>
{
parsedContent
}
</
em
>;
return
<
em
>
{
parsedContent
}
</
em
>;
};
};
...
...
web/src/labs/marked/parser/Heading.tsx
View file @
b19c3c6d
import
{
marked
}
from
".."
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
import
Link
from
"./Link"
;
import
PlainLink
from
"./PlainLink"
;
import
PlainText
from
"./PlainText"
;
export
const
HEADING_REG
=
/^
(
#+
)
([^\n]
+
)
/
;
export
const
HEADING_REG
=
/^
(
#+
)
([^\n]
+
)
/
;
...
@@ -9,16 +13,17 @@ const renderer = (rawStr: string) => {
...
@@ -9,16 +13,17 @@ const renderer = (rawStr: string) => {
}
}
const
level
=
matchResult
[
1
].
length
;
const
level
=
matchResult
[
1
].
length
;
const
parsedContent
=
marked
(
matchResult
[
2
],
[],
[
Link
,
PlainLink
,
PlainText
]);
if
(
level
===
1
)
{
if
(
level
===
1
)
{
return
<
h1
>
{
matchResult
[
2
]
}
</
h1
>;
return
<
h1
>
{
parsedContent
}
</
h1
>;
}
else
if
(
level
===
2
)
{
}
else
if
(
level
===
2
)
{
return
<
h2
>
{
matchResult
[
2
]
}
</
h2
>;
return
<
h2
>
{
parsedContent
}
</
h2
>;
}
else
if
(
level
===
3
)
{
}
else
if
(
level
===
3
)
{
return
<
h3
>
{
matchResult
[
2
]
}
</
h3
>;
return
<
h3
>
{
parsedContent
}
</
h3
>;
}
else
if
(
level
===
4
)
{
}
else
if
(
level
===
4
)
{
return
<
h4
>
{
matchResult
[
2
]
}
</
h4
>;
return
<
h4
>
{
parsedContent
}
</
h4
>;
}
}
return
<
h5
>
{
matchResult
[
2
]
}
</
h5
>;
return
<
h5
>
{
parsedContent
}
</
h5
>;
};
};
export
default
{
export
default
{
...
...
web/src/labs/marked/parser/OrderedList.tsx
View file @
b19c3c6d
...
@@ -2,18 +2,19 @@ import { inlineElementParserList } from ".";
...
@@ -2,18 +2,19 @@ import { inlineElementParserList } from ".";
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
export
const
ORDERED_LIST_REG
=
/^
(\d
+
)\.
(
.+
)
/
;
export
const
ORDERED_LIST_REG
=
/^
(
*
)(
\d
+
)\.
(
.+
)
/
;
const
renderer
=
(
rawStr
:
string
)
=>
{
const
renderer
=
(
rawStr
:
string
)
=>
{
const
matchResult
=
matcher
(
rawStr
,
ORDERED_LIST_REG
);
const
matchResult
=
matcher
(
rawStr
,
ORDERED_LIST_REG
);
if
(
!
matchResult
)
{
if
(
!
matchResult
)
{
return
rawStr
;
return
rawStr
;
}
}
const
space
=
matchResult
[
1
];
const
parsedContent
=
marked
(
matchResult
[
2
],
[],
inlineElementParserList
);
const
parsedContent
=
marked
(
matchResult
[
3
],
[],
inlineElementParserList
);
return
(
return
(
<
p
className=
"li-container"
>
<
p
className=
"li-container"
>
<
span
className=
"ol-block"
>
{
matchResult
[
1
]
}
.
</
span
>
<
span
className=
"whitespace-pre"
>
{
space
}
</
span
>
<
span
className=
"ol-block"
>
{
matchResult
[
2
]
}
.
</
span
>
<
span
>
{
parsedContent
}
</
span
>
<
span
>
{
parsedContent
}
</
span
>
</
p
>
</
p
>
);
);
...
...
web/src/labs/marked/parser/TodoList.tsx
View file @
b19c3c6d
...
@@ -2,17 +2,18 @@ import { inlineElementParserList } from ".";
...
@@ -2,17 +2,18 @@ import { inlineElementParserList } from ".";
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
export
const
TODO_LIST_REG
=
/^-
\[
\]
([^\n]
+
)
/
;
export
const
TODO_LIST_REG
=
/^
(
*
)
-
\[
\]
([^\n]
+
)
/
;
const
renderer
=
(
rawStr
:
string
)
=>
{
const
renderer
=
(
rawStr
:
string
)
=>
{
const
matchResult
=
matcher
(
rawStr
,
TODO_LIST_REG
);
const
matchResult
=
matcher
(
rawStr
,
TODO_LIST_REG
);
if
(
!
matchResult
)
{
if
(
!
matchResult
)
{
return
rawStr
;
return
rawStr
;
}
}
const
space
=
matchResult
[
1
];
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
inlineElementParserList
);
const
parsedContent
=
marked
(
matchResult
[
2
],
[],
inlineElementParserList
);
return
(
return
(
<
p
className=
"li-container"
>
<
p
className=
"li-container"
>
<
span
className=
"whitespace-pre"
>
{
space
}
</
span
>
<
span
className=
"todo-block todo"
data
-
value=
"TODO"
></
span
>
<
span
className=
"todo-block todo"
data
-
value=
"TODO"
></
span
>
<
span
>
{
parsedContent
}
</
span
>
<
span
>
{
parsedContent
}
</
span
>
</
p
>
</
p
>
...
...
web/src/labs/marked/parser/UnorderedList.tsx
View file @
b19c3c6d
...
@@ -2,17 +2,18 @@ import { inlineElementParserList } from ".";
...
@@ -2,17 +2,18 @@ import { inlineElementParserList } from ".";
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
{
matcher
}
from
"../matcher"
;
import
{
matcher
}
from
"../matcher"
;
export
const
UNORDERED_LIST_REG
=
/^
[
*-
]
([^\n]
+
)
/
;
export
const
UNORDERED_LIST_REG
=
/^
(
*
)
[
*-
]
([^\n]
+
)
/
;
const
renderer
=
(
rawStr
:
string
)
=>
{
const
renderer
=
(
rawStr
:
string
)
=>
{
const
matchResult
=
matcher
(
rawStr
,
UNORDERED_LIST_REG
);
const
matchResult
=
matcher
(
rawStr
,
UNORDERED_LIST_REG
);
if
(
!
matchResult
)
{
if
(
!
matchResult
)
{
return
rawStr
;
return
rawStr
;
}
}
const
space
=
matchResult
[
1
];
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
inlineElementParserList
);
const
parsedContent
=
marked
(
matchResult
[
2
],
[],
inlineElementParserList
);
return
(
return
(
<
p
className=
"li-container"
>
<
p
className=
"li-container"
>
<
span
className=
"whitespace-pre"
>
{
space
}
</
span
>
<
span
className=
"ul-block"
>
•
</
span
>
<
span
className=
"ul-block"
>
•
</
span
>
<
span
>
{
parsedContent
}
</
span
>
<
span
>
{
parsedContent
}
</
span
>
</
p
>
</
p
>
...
...
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