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
2163d386
Commit
2163d386
authored
3 years ago
by
marihachi
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into master
parents
15c2ad5c
70d49f92
No related branches found
Branches containing commit
Tags
v0.17.0
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
docs/syntax.md
+3
-3
3 additions, 3 deletions
docs/syntax.md
package.json
+1
-1
1 addition, 1 deletion
package.json
src/parser.pegjs
+3
-3
3 additions, 3 deletions
src/parser.pegjs
test/parser.ts
+39
-9
39 additions, 9 deletions
test/parser.ts
with
46 additions
and
16 deletions
docs/syntax.md
+
3
−
3
View file @
2163d386
...
...
@@ -300,7 +300,7 @@ _italic_
構文2,3のみ:
※1つ目の
`*`
と
`_`
を開始記号と呼ぶ。
-
内容には
`[a-z0-9 \t]i`
にマッチする文字が使用できる。
-
開始記号の前の文字が(無い、改行、半角スペース)のいずれかの時にイタリック文字として判定される。
-
開始記号の前の文字が(無い、改行、半角スペース
、[a-zA-Z0-9]に一致しない
)のいずれかの時にイタリック文字として判定される。
...
...
@@ -410,7 +410,7 @@ _italic_
## 詳細
-
インライン構文。
-
最初の
`@`
の前の文字が(改行、スペース、無し)のいずれかの場合にメンションとして認識する。
-
最初の
`@`
の前の文字が(改行、スペース、無し
、[a-zA-Z0-9]に一致しない
)のいずれかの場合にメンションとして認識する。
### ユーザ名
-
1文字以上。
...
...
@@ -446,7 +446,7 @@ _italic_
-
内容には半角スペース、全角スペース、改行、タブ文字を含めることができない。
-
内容には
`.`
`,`
`!`
`?`
`'`
`"`
`#`
`:`
`/`
`【`
`】`
を含めることができない。
-
括弧は対になっている時のみ内容に含めることができる。対象:
`()`
`[]`
`「」`
-
`#`
の前の文字が(改行、スペース、無し)のいずれかの場合にハッシュタグとして認識する。
-
`#`
の前の文字が(改行、スペース、無し
、[a-zA-Z0-9]に一致しない
)のいずれかの場合にハッシュタグとして認識する。
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
2163d386
{
"name"
:
"mfm-js"
,
"version"
:
"0.16.
3
"
,
"version"
:
"0.16.
4
"
,
"description"
:
"An MFM parser implementation with PEG.js"
,
"main"
:
"./built/index.js"
,
"types"
:
"./built/index.d.ts"
,
...
...
This diff is collapsed.
Click to expand it.
src/parser.pegjs
+
3
−
3
View file @
2163d386
...
...
@@ -285,12 +285,12 @@ italicTag
}
italicAlt
= "*" content:$(!"*" ([a-z0-9]i / _))+ "*" &(EOF / LF / _)
= "*" content:$(!"*" ([a-z0-9]i / _))+ "*" &(EOF / LF / _
/ ![a-z0-9]i
)
{
const parsedContent = applyParser(content, 'inlineParser');
return ITALIC(parsedContent);
}
/ "_" content:$(!"_" ([a-z0-9]i / _))+ "_" &(EOF / LF / _)
/ "_" content:$(!"_" ([a-z0-9]i / _))+ "_" &(EOF / LF / _
/ ![a-z0-9]i
)
{
const parsedContent = applyParser(content, 'inlineParser');
return ITALIC(parsedContent);
...
...
@@ -476,7 +476,7 @@ fnContentPart
// inline: text
inlineText
= !(LF / _)
.
&(hashtag / mention / italicAlt) . { return text(); } // hashtag, mention, italic ignore
= !(LF / _)
[a-z0-9]i
&(hashtag / mention / italicAlt) . { return text(); } // hashtag, mention, italic ignore
/ . /* text node */
// inline: text (for plainParser)
...
...
This diff is collapsed.
Click to expand it.
test/parser.ts
+
39
−
9
View file @
2163d386
...
...
@@ -447,9 +447,19 @@ describe('FullParser', () => {
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore a italic syntax if the before char is neither a space nor an LF
'
,
()
=>
{
const
input
=
'
before*abc*after
'
;
const
output
=
[
TEXT
(
'
before*abc*after
'
)];
it
(
'
ignore a italic syntax if the before char is neither a space nor an LF nor [^a-z0-9]i
'
,
()
=>
{
let
input
=
'
before*abc*after
'
;
let
output
:
mfm
.
MfmNode
[]
=
[
TEXT
(
'
before*abc*after
'
)];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
input
=
'
あいう*abc*えお
'
;
output
=
[
TEXT
(
'
あいう
'
),
ITALIC
([
TEXT
(
'
abc
'
)
]),
TEXT
(
'
えお
'
)
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
});
...
...
@@ -477,9 +487,19 @@ describe('FullParser', () => {
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore a italic syntax if the before char is neither a space nor an LF
'
,
()
=>
{
const
input
=
'
before_abc_after
'
;
const
output
=
[
TEXT
(
'
before_abc_after
'
)];
it
(
'
ignore a italic syntax if the before char is neither a space nor an LF nor [^a-z0-9]i
'
,
()
=>
{
let
input
=
'
before_abc_after
'
;
let
output
:
mfm
.
MfmNode
[]
=
[
TEXT
(
'
before_abc_after
'
)];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
input
=
'
あいう_abc_えお
'
;
output
=
[
TEXT
(
'
あいう
'
),
ITALIC
([
TEXT
(
'
abc
'
)
]),
TEXT
(
'
えお
'
)
];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
});
...
...
@@ -526,6 +546,12 @@ describe('FullParser', () => {
const
output
=
[
TEXT
(
'
abc@example.com
'
)];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
detect as a mention if the before char is [^a-z0-9]i
'
,
()
=>
{
const
input
=
'
あいう@abc
'
;
const
output
=
[
TEXT
(
'
あいう
'
),
MENTION
(
'
abc
'
,
null
,
'
@abc
'
)];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
});
describe
(
'
hashtag
'
,
()
=>
{
...
...
@@ -554,9 +580,13 @@ describe('FullParser', () => {
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
});
it
(
'
ignore a hashtag if the before char is neither a space nor an LF
'
,
()
=>
{
const
input
=
'
abc#abc
'
;
const
output
=
[
TEXT
(
'
abc#abc
'
)];
it
(
'
ignore a hashtag if the before char is neither a space nor an LF nor [^a-z0-9]i
'
,
()
=>
{
let
input
=
'
abc#abc
'
;
let
output
:
mfm
.
MfmNode
[]
=
[
TEXT
(
'
abc#abc
'
)];
assert
.
deepStrictEqual
(
mfm
.
parse
(
input
),
output
);
input
=
'
あいう#abc
'
;
output
=
[
TEXT
(
'
あいう
'
),
HASHTAG
(
'
abc
'
)];
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