forked from FoundKeyGang/FoundKey
Add small syntax (#3506)
This commit is contained in:
parent
dc8f4c8d6a
commit
66836836ab
4 changed files with 38 additions and 0 deletions
|
@ -123,6 +123,10 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}, genEl(token.children));
|
}, genEl(token.children));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'small': {
|
||||||
|
return [createElement('small', genEl(token.children))];
|
||||||
|
}
|
||||||
|
|
||||||
case 'center': {
|
case 'center': {
|
||||||
return [createElement('div', {
|
return [createElement('div', {
|
||||||
attrs: {
|
attrs: {
|
||||||
|
|
|
@ -31,6 +31,12 @@ export default (tokens: Node[], mentionedRemoteUsers: INote['mentionedRemoteUser
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
small(token) {
|
||||||
|
const el = doc.createElement('small');
|
||||||
|
dive(token.children).forEach(child => el.appendChild(child));
|
||||||
|
return el;
|
||||||
|
},
|
||||||
|
|
||||||
strike(token) {
|
strike(token) {
|
||||||
const el = doc.createElement('del');
|
const el = doc.createElement('del');
|
||||||
dive(token.children).forEach(child => el.appendChild(child));
|
dive(token.children).forEach(child => el.appendChild(child));
|
||||||
|
|
|
@ -67,6 +67,7 @@ const newline = P((input, i) => {
|
||||||
const mfm = P.createLanguage({
|
const mfm = P.createLanguage({
|
||||||
root: r => P.alt(
|
root: r => P.alt(
|
||||||
r.big,
|
r.big,
|
||||||
|
r.small,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
@ -102,6 +103,20 @@ const mfm = P.createLanguage({
|
||||||
).atLeast(1).tryParse(x))),
|
).atLeast(1).tryParse(x))),
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region Small
|
||||||
|
small: r =>
|
||||||
|
P.regexp(/<small>([\s\S]+?)<\/small>/, 1)
|
||||||
|
.map(x => makeNodeWithChildren('small', P.alt(
|
||||||
|
r.strike,
|
||||||
|
r.italic,
|
||||||
|
r.mention,
|
||||||
|
r.hashtag,
|
||||||
|
r.emoji,
|
||||||
|
r.math,
|
||||||
|
r.text
|
||||||
|
).atLeast(1).tryParse(x))),
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region Block code
|
//#region Block code
|
||||||
blockCode: r =>
|
blockCode: r =>
|
||||||
newline.then(
|
newline.then(
|
||||||
|
@ -134,6 +149,7 @@ const mfm = P.createLanguage({
|
||||||
P.regexp(/<center>([\s\S]+?)<\/center>/, 1)
|
P.regexp(/<center>([\s\S]+?)<\/center>/, 1)
|
||||||
.map(x => makeNodeWithChildren('center', P.alt(
|
.map(x => makeNodeWithChildren('center', P.alt(
|
||||||
r.big,
|
r.big,
|
||||||
|
r.small,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
@ -211,6 +227,7 @@ const mfm = P.createLanguage({
|
||||||
.map((x: any) => {
|
.map((x: any) => {
|
||||||
return makeNodeWithChildren('link', P.alt(
|
return makeNodeWithChildren('link', P.alt(
|
||||||
r.big,
|
r.big,
|
||||||
|
r.small,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
@ -253,6 +270,7 @@ const mfm = P.createLanguage({
|
||||||
P.alt(P.regexp(/\(\(\(([\s\S]+?)\)\)\)/, 1), P.regexp(/<motion>(.+?)<\/motion>/, 1))
|
P.alt(P.regexp(/\(\(\(([\s\S]+?)\)\)\)/, 1), P.regexp(/<motion>(.+?)<\/motion>/, 1))
|
||||||
.map(x => makeNodeWithChildren('motion', P.alt(
|
.map(x => makeNodeWithChildren('motion', P.alt(
|
||||||
r.bold,
|
r.bold,
|
||||||
|
r.small,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
r.mention,
|
r.mention,
|
||||||
|
@ -312,6 +330,7 @@ const mfm = P.createLanguage({
|
||||||
const q = match[1].trim().substring(1, match[1].length - 1);
|
const q = match[1].trim().substring(1, match[1].length - 1);
|
||||||
const contents = P.alt(
|
const contents = P.alt(
|
||||||
r.big,
|
r.big,
|
||||||
|
r.small,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
|
|
@ -70,6 +70,15 @@ describe('Text', () => {
|
||||||
], tokens);
|
], tokens);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('small', () => {
|
||||||
|
const tokens = analyze('<small>smaller</small>');
|
||||||
|
assert.deepEqual([
|
||||||
|
nodeWithChildren('small', [
|
||||||
|
text('smaller')
|
||||||
|
]),
|
||||||
|
], tokens);
|
||||||
|
});
|
||||||
|
|
||||||
describe('motion', () => {
|
describe('motion', () => {
|
||||||
it('by triple brackets', () => {
|
it('by triple brackets', () => {
|
||||||
const tokens = analyze('(((foo)))');
|
const tokens = analyze('(((foo)))');
|
||||||
|
|
Loading…
Reference in a new issue