Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
marihachi committed Jun 5, 2021
2 parents 11a763f + cfbe5b3 commit b31a705
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 15.x]
node-version: [12.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
17 changes: 17 additions & 0 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ _italic_
## 詳細
- インライン構文。
- 内容には改行を含めることができない。
- 内容には「´」を含めることができない。



Expand Down Expand Up @@ -447,12 +448,14 @@ _italic_
- 内容には`.` `,` `!` `?` `'` `"` `#` `:` `/` `` `` を含めることができない。
- 括弧は対になっている時のみ内容に含めることができる。対象: `()` `[]` `「」`
- `#`の前の文字が(改行、スペース、無し、[a-zA-Z0-9]に一致しない)のいずれかの場合にハッシュタグとして認識する。
- 内容が数字のみの場合はハッシュタグとして認識しない。



<h1 id="url">URL</h2>

## 形式
構文1:
```
https://misskey.io/@ai
```
Expand All @@ -461,6 +464,15 @@ https://misskey.io/@ai
http://hoge.jp/abc
```

構文2:
```
<https://misskey.io/@ai>
```

```
<http://藍.jp/abc>
```

## ノード
```js
{
Expand All @@ -473,10 +485,15 @@ http://hoge.jp/abc

## 詳細
- インライン構文。

構文1のみ:
- 内容には`[.,a-z0-9_/:%#@$&?!~=+-]i`にマッチする文字を使用できる。
- 内容には対になっている括弧を使用できる。対象: `(` `)` `[` `]`
- `.``,`は最後の文字にできない。

構文2のみ:
- 内容には改行、スペース以外の文字を使用できる。



<h1 id="link">リンク</h2>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mfm-js",
"version": "0.16.5",
"version": "0.17.0",
"description": "An MFM parser implementation with PEG.js",
"main": "./built/index.js",
"types": "./built/index.d.ts",
Expand Down
23 changes: 16 additions & 7 deletions src/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ strike
// inline: inlineCode

inlineCode
= "`" content:$(!"`" c:CHAR { return c; })+ "`"
= "`" content:$(![`´] c:CHAR { return c; })+ "`"
{
return INLINE_CODE(content);
}
Expand Down Expand Up @@ -341,7 +341,13 @@ hashtag
}

hashtagContent
= (hashtagBracketPair / hashtagChar)+ { return text(); }
= !(invalidHashtagContent !hashtagContentPart) hashtagContentPart+ { return text(); }

invalidHashtagContent
= [0-9]+

hashtagContentPart
= hashtagBracketPair / hashtagChar

hashtagBracketPair
= "(" hashtagContent* ")"
Expand All @@ -354,7 +360,7 @@ hashtagChar
// inline: URL

url
= "<" url:urlFormat ">"
= "<" url:altUrlFormat ">"
{
return N_URL(url);
}
Expand All @@ -364,14 +370,11 @@ url
}

urlFormat
= "http" "s"? "://" urlContent
= "http" "s"? "://" urlContentPart+
{
return text();
}

urlContent
= urlContentPart+

urlContentPart
= urlBracketPair
/ [.,] &urlContentPart // last char is neither "." nor ",".
Expand All @@ -381,6 +384,12 @@ urlBracketPair
= "(" urlContentPart* ")"
/ "[" urlContentPart* "]"

altUrlFormat
= "http" "s"? "://" (!(">" / _) CHAR)+
{
return text();
}

// inline: link

link
Expand Down
Loading

0 comments on commit b31a705

Please sign in to comment.