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
26aae0e6
Unverified
Commit
26aae0e6
authored
Oct 15, 2022
by
Hyoban
Committed by
GitHub
Oct 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: blank line after table (#298)
parent
95c8d8fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
marked.test.ts
web/src/labs/marked/marked.test.ts
+10
-4
Table.ts
web/src/labs/marked/parser/Table.ts
+2
-2
No files found.
web/src/labs/marked/marked.test.ts
View file @
26aae0e6
...
@@ -6,11 +6,15 @@ describe("test marked parser", () => {
...
@@ -6,11 +6,15 @@ describe("test marked parser", () => {
test
(
"test markdown table"
,
()
=>
{
test
(
"test markdown table"
,
()
=>
{
const
tests
=
[
const
tests
=
[
{
{
markdown
:
`| a | b | c |
markdown
:
`text above the table
| a | b | c |
|---|---|---|
|---|---|---|
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 4 | 5 | 6 |`
,
| 4 | 5 | 6 |
want
:
`<table>
text below the table
`
,
want
:
`<p>text above the table</p>
<table>
<thead>
<thead>
<tr>
<tr>
<th>a</th><th>b</th><th>c</th>
<th>a</th><th>b</th><th>c</th>
...
@@ -19,7 +23,9 @@ describe("test marked parser", () => {
...
@@ -19,7 +23,9 @@ describe("test marked parser", () => {
<tbody>
<tbody>
<tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr>
<tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr>
</tbody>
</tbody>
</table>`
,
</table>
<p>text below the table</p>
`
,
},
},
{
{
markdown
:
`| a | b | c |
markdown
:
`| a | b | c |
...
...
web/src/labs/marked/parser/Table.ts
View file @
26aae0e6
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* | 1 | 2 | 3 |
* | 1 | 2 | 3 |
* | 4 | 5 | 6 |
* | 4 | 5 | 6 |
*/
*/
export
const
TABLE_REG
=
/^
(\|
.*
\|)(?:(?:\n(?:\|
-*
)
+
\|))((?:\n\|
.*
\|)
+
)
/
;
export
const
TABLE_REG
=
/^
(\|
.*
\|)(?:(?:\n(?:\|
-*
)
+
\|))((?:\n\|
.*
\|)
+
)
(\n?)
/
;
const
renderer
=
(
rawStr
:
string
):
string
=>
{
const
renderer
=
(
rawStr
:
string
):
string
=>
{
const
matchResult
=
rawStr
.
match
(
TABLE_REG
);
const
matchResult
=
rawStr
.
match
(
TABLE_REG
);
...
@@ -35,7 +35,7 @@ const renderer = (rawStr: string): string => {
...
@@ -35,7 +35,7 @@ const renderer = (rawStr: string): string => {
<tbody>
<tbody>
${
tableBody
.
map
((
row
)
=>
`<tr>
${
row
.
map
((
str
)
=>
`<td>
${
str
}
</td>`
).
join
(
""
)}
</tr>`
).
join
(
""
)}
${
tableBody
.
map
((
row
)
=>
`<tr>
${
row
.
map
((
str
)
=>
`<td>
${
str
}
</td>`
).
join
(
""
)}
</tr>`
).
join
(
""
)}
</tbody>
</tbody>
</table>`
;
</table>
${
matchResult
[
3
]}
`
;
};
};
export
default
{
export
default
{
...
...
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