Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sfm-js
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
sfm-js
Commits
013f3af2
Commit
013f3af2
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
improve emoji code parsing
Fix #129
parent
363b091a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/internal/parser.ts
+4
-1
4 additions, 1 deletion
src/internal/parser.ts
test/parser.ts
+13
-1
13 additions, 1 deletion
test/parser.ts
with
17 additions
and
2 deletions
src/internal/parser.ts
+
4
−
1
View file @
013f3af2
...
...
@@ -626,12 +626,15 @@ export const language = P.createLanguage({
},
emojiCode
:
r
=>
{
const
side
=
P
.
notMatch
(
P
.
regexp
(
/
[
a-z0-9
]
/i
));
const
mark
=
P
.
str
(
'
:
'
);
return
P
.
seq
([
P
.
alt
([
P
.
lineBegin
,
side
]),
mark
,
P
.
regexp
(
/
[
a-z0-9_+-
]
+/i
),
mark
,
],
1
).
map
(
name
=>
M
.
EMOJI_CODE
(
name
as
string
));
P
.
alt
([
P
.
lineEnd
,
side
]),
],
2
).
map
(
name
=>
M
.
EMOJI_CODE
(
name
as
string
));
},
link
:
r
=>
{
...
...
This diff is collapsed.
Click to expand it.
test/parser.ts
+
13
−
1
View file @
013f3af2
...
...
@@ -34,7 +34,19 @@ describe('SimpleParser', () => {
it
(
'
between texts
'
,
()
=>
{
const
input
=
'
foo:bar:baz
'
;
const
output
=
[
TEXT
(
'
foo
'
),
EMOJI_CODE
(
'
bar
'
),
TEXT
(
'
baz
'
)];
const
output
=
[
TEXT
(
'
foo:bar:baz
'
)];
assert
.
deepStrictEqual
(
mfm
.
parseSimple
(
input
),
output
);
});
it
(
'
between texts 2
'
,
()
=>
{
const
input
=
'
12:34:56
'
;
const
output
=
[
TEXT
(
'
12:34:56
'
)];
assert
.
deepStrictEqual
(
mfm
.
parseSimple
(
input
),
output
);
});
it
(
'
between texts 3
'
,
()
=>
{
const
input
=
'
あ:bar:い
'
;
const
output
=
[
TEXT
(
'
あ
'
),
EMOJI_CODE
(
'
bar
'
),
TEXT
(
'
い
'
)];
assert
.
deepStrictEqual
(
mfm
.
parseSimple
(
input
),
output
);
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment