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 12, 2021
2 parents 2926855 + de03976 commit fcd1632
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- `>`の後に続く0~1文字のスペースを無視する。
- 隣接する引用の行は一つになる。
- 複数行の引用では空行も含めることができる。
- 引用の後ろにある空行は無視される。([#61](https://github.com/misskey-dev/mfm.js/issues/61))



Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "mfm-js",
"version": "0.18.0",
"version": "0.19.0",
"description": "An MFM parser implementation with PEG.js",
"main": "./built/index.js",
"types": "./built/index.d.ts",
"scripts": {
"build": "npm run tsc && npm run peg",
"build-debug": "npm run tsc && npm run peg-debug",
"peg": "peggy --cache -o built/parser.js --allowed-start-rules fullParser,inlineParser,plainParser src/parser.pegjs",
"peg-debug": "peggy --cache -o built/parser.js --allowed-start-rules fullParser,inlineParser,plainParser --trace src/parser.pegjs",
"peg": "peggy --cache -o built/internal/parser.js --allowed-start-rules fullParser,inlineParser,plainParser src/internal/parser.pegjs",
"peg-debug": "peggy --cache -o built/internal/parser.js --allowed-start-rules fullParser,inlineParser,plainParser --trace src/internal/parser.pegjs",
"tsc": "tsc",
"tsd": "tsd",
"parse": "node ./built/cli/parse",
Expand Down
4 changes: 2 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import peg from 'peggy';
import { MfmNode, MfmPlainNode } from './node';
import { stringifyNode, stringifyTree, inspectOne } from './util';
import { stringifyNode, stringifyTree, inspectOne } from './internal/util';

const parser: peg.Parser = require('./parser');
const parser: peg.Parser = require('./internal/parser');

/**
* Generates a MfmNode tree from the MFM string.
Expand Down
4 changes: 2 additions & 2 deletions src/parser.pegjs → src/internal/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
LINK,
FN,
TEXT
} = require('./node');
} = require('../node');

const {
mergeText,
Expand Down Expand Up @@ -128,7 +128,7 @@ plain
// block: quote

quote
= &(BEGIN ">") q:quoteInner { return q; }
= &(BEGIN ">") q:quoteInner LF? { return q; }

quoteInner
= head:quoteMultiLine tails:quoteMultiLine+
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts → src/internal/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isMfmBlock, MfmNode, TEXT } from './node';
import { isMfmBlock, MfmNode, TEXT } from '../node';

export function mergeText(nodes: (MfmNode | string)[]): MfmNode[] {
const dest: MfmNode[] = [];
Expand Down
14 changes: 14 additions & 0 deletions test/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ describe('FullParser', () => {
];
assert.deepStrictEqual(mfm.parse(input), output);
});
it('引用ブロックの後ろの空行は無視される', () => {
const input = `
> foo
> bar
hoge`;
const output = [
QUOTE([
TEXT('foo\nbar')
]),
TEXT('hoge')
];
assert.deepStrictEqual(mfm.parse(input), output);
});
});

describe('search', () => {
Expand Down

0 comments on commit fcd1632

Please sign in to comment.