Skip to content
Snippets Groups Projects
Commit 2163d386 authored by marihachi's avatar marihachi
Browse files

Merge branch 'develop' into master

parents 15c2ad5c 70d49f92
No related branches found
Tags v0.17.0
No related merge requests found
......@@ -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]に一致しない)のいずれかの場合にハッシュタグとして認識する。
......
{
"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",
......
......@@ -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)
......
......@@ -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);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment