FIX: When quoting an attachment, keep the |attachment in markdown (#11347)
This commit is contained in:
parent
3e1b94c227
commit
2348a7972e
|
@ -273,7 +273,13 @@ export class Tag {
|
||||||
|
|
||||||
if (attr.href && text !== attr.href) {
|
if (attr.href && text !== attr.href) {
|
||||||
text = text.replace(/\n{2,}/g, "\n");
|
text = text.replace(/\n{2,}/g, "\n");
|
||||||
return "[" + text + "](" + attr.href + ")";
|
|
||||||
|
let linkModifier = "";
|
||||||
|
if (attr.class && attr.class.includes("attachment")) {
|
||||||
|
linkModifier = "|attachment";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[" + text + linkModifier + "](" + attr.href + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
|
@ -38,6 +38,12 @@ module("Unit | Utility | to-markdown", function () {
|
||||||
assert.equal(toMarkdown(html), markdown);
|
assert.equal(toMarkdown(html), markdown);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("converts a link which is an attachment", function (assert) {
|
||||||
|
let html = `<a class="attachment" href="https://discourse.org/pdfs/stuff.pdf">stuff.pdf</a>`;
|
||||||
|
let markdown = `[stuff.pdf|attachment](https://discourse.org/pdfs/stuff.pdf)`;
|
||||||
|
assert.equal(toMarkdown(html), markdown);
|
||||||
|
});
|
||||||
|
|
||||||
test("put raw URL instead of converting the link", function (assert) {
|
test("put raw URL instead of converting the link", function (assert) {
|
||||||
let url = "https://discourse.org";
|
let url = "https://discourse.org";
|
||||||
const html = () => `<a href="${url}">${url}</a>`;
|
const html = () => `<a href="${url}">${url}</a>`;
|
||||||
|
|
Loading…
Reference in New Issue