Skip to content

Commit

Permalink
Add vflip
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed May 12, 2019
1 parent 8c870cd commit 428be0b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/client/app/common/views/components/mfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ export default Vue.component('misskey-flavored-markdown', {
}, genEl(token.children));
}

case 'vflip': {
return (createElement as any)('span', {
attrs: {
style: 'display: inline-block; transform: scaleY(-1);'
},
}, genEl(token.children));
}

case 'url': {
return [createElement(MkUrl, {
key: Math.random(),
Expand Down
2 changes: 2 additions & 0 deletions src/mfm/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const mfmLanguage = P.createLanguage({
r.spin,
r.jump,
r.flip,
r.vflip,
r.inlineCode,
r.mathInline,
r.mention,
Expand Down Expand Up @@ -131,6 +132,7 @@ export const mfmLanguage = P.createLanguage({
},
jump: r => P.alt(P.regexp(/<jump>(.+?)<\/jump>/, 1), P.regexp(/\{\{\{([\s\S]+?)\}\}\}/, 1)).map(x => createTree('jump', r.inline.atLeast(1).tryParse(x), {})),
flip: r => P.regexp(/<flip>(.+?)<\/flip>/, 1).map(x => createTree('flip', r.inline.atLeast(1).tryParse(x), {})),
vflip: r => P.regexp(/<vflip>(.+?)<\/vflip>/, 1).map(x => createTree('vflip', r.inline.atLeast(1).tryParse(x), {})),
center: r => r.startOfLine.then(P.regexp(/<center>([\s\S]+?)<\/center>/, 1).map(x => createTree('center', r.inline.atLeast(1).tryParse(x), {}))),
inlineCode: () => P.regexp(/`([^´\n]+?)`/, 1).map(x => createLeaf('inlineCode', { code: x })),
mathBlock: r => r.startOfLine.then(P.regexp(/\\\[([\s\S]+?)\\\]/, 1).map(x => createLeaf('mathBlock', { formula: x.trim() }))),
Expand Down
6 changes: 6 additions & 0 deletions src/mfm/toHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export function toHtml(tokens: MfmForest, mentionedRemoteUsers: INote['mentioned
return el;
},

vflip(token) {
const el = doc.createElement('span');
appendChildren(token.children, el);
return el;
},

blockCode(token) {
const pre = doc.createElement('pre');
const inner = doc.createElement('code');
Expand Down
9 changes: 9 additions & 0 deletions test/mfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ describe('MFM', () => {
]);
});

it('vflip', () => {
const tokens = parse('<vflip>foo</vflip>');
assert.deepStrictEqual(tokens, [
tree('vflip', [
text('foo')
], {}),
]);
});

describe('spin', () => {
it('text', () => {
const tokens = parse('<spin>foo</spin>');
Expand Down

0 comments on commit 428be0b

Please sign in to comment.