Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sfm-js
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
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
dakkar
sfm-js
Commits
4c20bcb0
Commit
4c20bcb0
authored
3 years ago
by
marihachi
Browse files
Options
Downloads
Patches
Plain Diff
add brackets property of url node
parent
8a7dcab4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
docs/syntax.md
+24
-0
24 additions, 0 deletions
docs/syntax.md
src/internal/parser.pegjs
+1
-1
1 addition, 1 deletion
src/internal/parser.pegjs
src/internal/util.ts
+6
-1
6 additions, 1 deletion
src/internal/util.ts
src/node.ts
+2
-1
2 additions, 1 deletion
src/node.ts
test/parser.ts
+1
-1
1 addition, 1 deletion
test/parser.ts
with
34 additions
and
4 deletions
docs/syntax.md
+
24
−
0
View file @
4c20bcb0
...
...
@@ -475,6 +475,7 @@ http://hoge.jp/abc
```
## ノード
構文1:
```
js
{
type
:
'
url
'
,
...
...
@@ -484,6 +485,29 @@ http://hoge.jp/abc
}
```
または
```
js
{
type
:
'
url
'
,
props
:
{
url
:
'
https://misskey.io/@ai
'
,
brackets
:
false
}
}
```
構文2:
```
js
{
type
:
'
url
'
,
props
:
{
url
:
'
https://misskey.io/@ai
'
,
brackets
:
true
}
}
```
## 詳細
-
インライン構文。
...
...
This diff is collapsed.
Click to expand it.
src/internal/parser.pegjs
+
1
−
1
View file @
4c20bcb0
...
...
@@ -362,7 +362,7 @@ hashtagChar
url
= "<" url:altUrlFormat ">"
{
return N_URL(url);
return N_URL(url
, true
);
}
/ url:urlFormat
{
...
...
This diff is collapsed.
Click to expand it.
src/internal/util.ts
+
6
−
1
View file @
4c20bcb0
...
...
@@ -79,7 +79,12 @@ export function stringifyNode(node: MfmNode): string {
return
`#
${
node
.
props
.
hashtag
}
`
;
}
case
'
url
'
:
{
return
node
.
props
.
url
;
if
(
node
.
props
.
brackets
)
{
return
`<
${
node
.
props
.
url
}
>`
;
}
else
{
return
node
.
props
.
url
;
}
}
case
'
link
'
:
{
const
prefix
=
node
.
props
.
silent
?
'
?
'
:
''
;
...
...
This diff is collapsed.
Click to expand it.
src/node.ts
+
2
−
1
View file @
4c20bcb0
...
...
@@ -143,10 +143,11 @@ export type MfmUrl = {
type
:
'
url
'
;
props
:
{
url
:
string
;
brackets
?:
boolean
;
};
children
?:
[];
};
export
const
N_URL
=
(
value
:
string
):
NodeType
<
'
url
'
>
=>
{
return
{
type
:
'
url
'
,
props
:
{
url
:
value
}
};
};
export
const
N_URL
=
(
value
:
string
,
brackets
?:
boolean
):
NodeType
<
'
url
'
>
=>
{
return
{
type
:
'
url
'
,
props
:
{
url
:
value
,
brackets
}
};
};
export
type
MfmLink
=
{
type
:
'
link
'
;
...
...
This diff is collapsed.
Click to expand it.
test/parser.ts
+
1
−
1
View file @
4c20bcb0
...
...
@@ -878,7 +878,7 @@ hoge`;
it
(
'
match non-ascii characters contained url with angle brackets
'
,
()
=>
{
const
input
=
'
<https://大石泉すき.example.com>
'
;
const
output
=
[
N_URL
(
'
https://大石泉すき.example.com
'
),
N_URL
(
'
https://大石泉すき.example.com
'
,
true
),
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
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