mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2025-08-21 05:44:48 +00:00
fix Mastodon link verification
the top element must be a single <a> in order for verification to work, so MfmService has gained an 'inline' argument to remove the <p> added by default
This commit is contained in:
parent
a4c0ef824c
commit
afd57f99c5
3 changed files with 15 additions and 3 deletions
|
@ -377,7 +377,7 @@ export class MfmService {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMentionedRemoteUsers = [], additionalAppenders: Appender[] = []) {
|
||||
public toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMentionedRemoteUsers = [], additionalAppenders: Appender[] = [], inline = false) {
|
||||
if (nodes == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -626,9 +626,15 @@ export class MfmService {
|
|||
additionalAppender(doc, body);
|
||||
}
|
||||
|
||||
return domserializer.render(body, {
|
||||
let result = domserializer.render(body, {
|
||||
encodeEntities: 'utf8'
|
||||
});
|
||||
|
||||
if (inline) {
|
||||
result = result.replace(/^<p>/, '').replace(/<\/p>$/, '');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// the toMastoApiHtml function was taken from Iceshrimp and written by zotan and modified by marie to work with the current MK version
|
||||
|
|
|
@ -584,7 +584,7 @@ export class ApRendererService {
|
|||
const attachment = profile.fields.map(field => ({
|
||||
type: 'PropertyValue',
|
||||
name: field.name,
|
||||
value: this.mfmService.toHtml(mfm.parse(field.value)),
|
||||
value: this.mfmService.toHtml(mfm.parse(field.value), [], [], true),
|
||||
}));
|
||||
|
||||
const emojis = await this.getEmojis(user.emojis);
|
||||
|
|
|
@ -63,6 +63,12 @@ describe('MfmService', () => {
|
|||
const output = '<p><ruby><span><i>some</i> text</span><rp>(</rp><rt>ignore me</rt><rp>)</rp></ruby></p>';
|
||||
assert.equal(mfmService.toHtml(mfm.parse(input)), output);
|
||||
});
|
||||
|
||||
test('inline', () => {
|
||||
const input = 'https://example.com';
|
||||
const output = '<a href="https://example.com">https://example.com</a>';
|
||||
assert.equal(mfmService.toHtml(mfm.parse(input), [], [], true), output);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toMastoApiHtml', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue