mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-14 06:00:44 +01:00
parent
20c0690352
commit
ed4860dfd9
4 changed files with 50 additions and 0 deletions
|
@ -100,6 +100,14 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
return [createElement('del', genEl(token.children))];
|
||||
}
|
||||
|
||||
case 'italic': {
|
||||
return (createElement as any)('i', {
|
||||
attrs: {
|
||||
style: 'font-style: oblique;'
|
||||
},
|
||||
}, genEl(token.children));
|
||||
}
|
||||
|
||||
case 'big': {
|
||||
bigCount++;
|
||||
const isLong = getTextCount(token.children) > 10 || getChildrenCount(token.children) > 5;
|
||||
|
|
|
@ -37,6 +37,12 @@ export default (tokens: Node[], mentionedRemoteUsers: INote['mentionedRemoteUser
|
|||
return el;
|
||||
},
|
||||
|
||||
italic(token) {
|
||||
const el = doc.createElement('i');
|
||||
dive(token.children).forEach(child => el.appendChild(child));
|
||||
return el;
|
||||
},
|
||||
|
||||
motion(token) {
|
||||
const el = doc.createElement('i');
|
||||
dive(token.children).forEach(child => el.appendChild(child));
|
||||
|
|
|
@ -69,6 +69,7 @@ const mfm = P.createLanguage({
|
|||
r.big,
|
||||
r.bold,
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.motion,
|
||||
r.url,
|
||||
r.link,
|
||||
|
@ -91,6 +92,8 @@ const mfm = P.createLanguage({
|
|||
big: r =>
|
||||
P.regexp(/^\*\*\*([\s\S]+?)\*\*\*/, 1)
|
||||
.map(x => makeNodeWithChildren('big', P.alt(
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.emoji,
|
||||
|
@ -115,6 +118,8 @@ const mfm = P.createLanguage({
|
|||
bold: r =>
|
||||
P.regexp(/\*\*([\s\S]+?)\*\*/, 1)
|
||||
.map(x => makeNodeWithChildren('bold', P.alt(
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.url,
|
||||
|
@ -131,6 +136,7 @@ const mfm = P.createLanguage({
|
|||
r.big,
|
||||
r.bold,
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.motion,
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
|
@ -176,6 +182,21 @@ const mfm = P.createLanguage({
|
|||
.map(x => makeNode('inlineCode', { code: x })),
|
||||
//#endregion
|
||||
|
||||
//#region Italic
|
||||
italic: r =>
|
||||
P.regexp(/<i>([\s\S]+?)<\/i>/, 1)
|
||||
.map(x => makeNodeWithChildren('italic', P.alt(
|
||||
r.bold,
|
||||
r.strike,
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.url,
|
||||
r.link,
|
||||
r.emoji,
|
||||
r.text
|
||||
).atLeast(1).tryParse(x))),
|
||||
//#endregion
|
||||
|
||||
//#region Link
|
||||
link: r =>
|
||||
P.seqObj(
|
||||
|
@ -192,6 +213,7 @@ const mfm = P.createLanguage({
|
|||
r.big,
|
||||
r.bold,
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.motion,
|
||||
r.emoji,
|
||||
r.text
|
||||
|
@ -232,6 +254,7 @@ const mfm = P.createLanguage({
|
|||
.map(x => makeNodeWithChildren('motion', P.alt(
|
||||
r.bold,
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.emoji,
|
||||
|
@ -270,6 +293,7 @@ const mfm = P.createLanguage({
|
|||
P.regexp(/~~(.+?)~~/, 1)
|
||||
.map(x => makeNodeWithChildren('strike', P.alt(
|
||||
r.bold,
|
||||
r.italic,
|
||||
r.mention,
|
||||
r.hashtag,
|
||||
r.url,
|
||||
|
@ -290,6 +314,7 @@ const mfm = P.createLanguage({
|
|||
r.big,
|
||||
r.bold,
|
||||
r.strike,
|
||||
r.italic,
|
||||
r.motion,
|
||||
r.url,
|
||||
r.link,
|
||||
|
|
11
test/mfm.ts
11
test/mfm.ts
|
@ -713,6 +713,17 @@ describe('Text', () => {
|
|||
], tokens);
|
||||
});
|
||||
});
|
||||
|
||||
describe('italic', () => {
|
||||
it('simple', () => {
|
||||
const tokens = analyze('<i>foo</i>');
|
||||
assert.deepEqual([
|
||||
nodeWithChildren('italic', [
|
||||
text('foo')
|
||||
]),
|
||||
], tokens);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('toHtml', () => {
|
||||
|
|
Loading…
Reference in a new issue