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
319a7cac
Commit
319a7cac
authored
Dec 20, 2025
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix remark tag parse
parent
6b0f90f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
remark-tag.ts
web/src/utils/remark-plugins/remark-tag.ts
+15
-11
No files found.
web/src/utils/remark-plugins/remark-tag.ts
View file @
319a7cac
...
@@ -36,32 +36,36 @@ function isTagChar(char: string): boolean {
...
@@ -36,32 +36,36 @@ function isTagChar(char: string): boolean {
// Parse tags from text and return segments
// Parse tags from text and return segments
function
parseTagsFromText
(
text
:
string
):
Array
<
{
type
:
"text"
|
"tag"
;
value
:
string
}
>
{
function
parseTagsFromText
(
text
:
string
):
Array
<
{
type
:
"text"
|
"tag"
;
value
:
string
}
>
{
const
segments
:
Array
<
{
type
:
"text"
|
"tag"
;
value
:
string
}
>
=
[];
const
segments
:
Array
<
{
type
:
"text"
|
"tag"
;
value
:
string
}
>
=
[];
// Convert to array of code points for proper Unicode handling (emojis, etc.)
const
chars
=
[...
text
];
let
i
=
0
;
let
i
=
0
;
while
(
i
<
text
.
length
)
{
while
(
i
<
chars
.
length
)
{
// Check for tag pattern
// Check for tag pattern
if
(
text
[
i
]
===
"#"
&&
i
+
1
<
text
.
length
&&
isTagChar
(
text
[
i
+
1
]))
{
if
(
chars
[
i
]
===
"#"
&&
i
+
1
<
chars
.
length
&&
isTagChar
(
chars
[
i
+
1
]))
{
// Check if this might be a heading (## at start or after whitespace)
// Check if this might be a heading (## at start or after whitespace)
const
prevChar
=
i
>
0
?
text
[
i
-
1
]
:
""
;
const
prevChar
=
i
>
0
?
chars
[
i
-
1
]
:
""
;
const
nextChar
=
i
+
1
<
text
.
length
?
text
[
i
+
1
]
:
""
;
const
nextChar
=
i
+
1
<
chars
.
length
?
chars
[
i
+
1
]
:
""
;
if
(
prevChar
===
"#"
||
nextChar
===
"#"
||
nextChar
===
" "
)
{
if
(
prevChar
===
"#"
||
nextChar
===
"#"
||
nextChar
===
" "
)
{
// This is a heading, not a tag
// This is a heading, not a tag
segments
.
push
({
type
:
"text"
,
value
:
text
[
i
]
});
segments
.
push
({
type
:
"text"
,
value
:
chars
[
i
]
});
i
++
;
i
++
;
continue
;
continue
;
}
}
// Extract tag content
// Extract tag content
let
j
=
i
+
1
;
let
j
=
i
+
1
;
while
(
j
<
text
.
length
&&
isTagChar
(
text
[
j
]))
{
while
(
j
<
chars
.
length
&&
isTagChar
(
chars
[
j
]))
{
j
++
;
j
++
;
}
}
const
tagContent
=
text
.
slice
(
i
+
1
,
j
);
const
tagContent
=
chars
.
slice
(
i
+
1
,
j
).
join
(
""
);
// Validate tag length (must match backend MAX_TAG_LENGTH)
// Validate tag length by rune count (must match backend MAX_TAG_LENGTH)
if
(
tagContent
.
length
>
0
&&
tagContent
.
length
<=
MAX_TAG_LENGTH
)
{
const
runeCount
=
[...
tagContent
].
length
;
if
(
runeCount
>
0
&&
runeCount
<=
MAX_TAG_LENGTH
)
{
segments
.
push
({
type
:
"tag"
,
value
:
tagContent
});
segments
.
push
({
type
:
"tag"
,
value
:
tagContent
});
i
=
j
;
i
=
j
;
continue
;
continue
;
...
@@ -70,10 +74,10 @@ function parseTagsFromText(text: string): Array<{ type: "text" | "tag"; value: s
...
@@ -70,10 +74,10 @@ function parseTagsFromText(text: string): Array<{ type: "text" | "tag"; value: s
// Regular text
// Regular text
let
j
=
i
+
1
;
let
j
=
i
+
1
;
while
(
j
<
text
.
length
&&
text
[
j
]
!==
"#"
)
{
while
(
j
<
chars
.
length
&&
chars
[
j
]
!==
"#"
)
{
j
++
;
j
++
;
}
}
segments
.
push
({
type
:
"text"
,
value
:
text
.
slice
(
i
,
j
)
});
segments
.
push
({
type
:
"text"
,
value
:
chars
.
slice
(
i
,
j
).
join
(
""
)
});
i
=
j
;
i
=
j
;
}
}
...
...
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