mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 19:53:53 -06:00
FIX: Generate valid heading ids (#14840)
This commit is contained in:
parent
9ddb3a9ca6
commit
7fb693c8f6
@ -701,6 +701,16 @@ eviltrout</p>
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Heading anchors are valid", function (assert) {
|
||||||
|
assert.cooked(
|
||||||
|
"# One\n\n# 1\n\n# $$",
|
||||||
|
'<h1><a name="one-1" class="anchor" href="#one-1"></a>One</h1>\n' +
|
||||||
|
'<h1><a name="h-1-2" class="anchor" href="#h-1-2"></a>1</h1>\n' +
|
||||||
|
'<h1><a name="h-3" class="anchor" href="#h-3"></a>$$</h1>',
|
||||||
|
"It will bold the heading"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("bold and italics", function (assert) {
|
test("bold and italics", function (assert) {
|
||||||
assert.cooked(
|
assert.cooked(
|
||||||
'a "**hello**"',
|
'a "**hello**"',
|
||||||
|
@ -39,7 +39,11 @@ export function setup(helper) {
|
|||||||
.replace(/^-+/, "")
|
.replace(/^-+/, "")
|
||||||
.replace(/-+$/, "");
|
.replace(/-+$/, "");
|
||||||
|
|
||||||
slug = `${slug || "heading"}-${++headingId}`;
|
if (slug.match(/^[^a-z]/)) {
|
||||||
|
slug = `h-${slug}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
slug = `${slug || "h"}-${++headingId}`;
|
||||||
|
|
||||||
linkOpen.attrSet("name", slug);
|
linkOpen.attrSet("name", slug);
|
||||||
linkOpen.attrSet("class", "anchor");
|
linkOpen.attrSet("class", "anchor");
|
||||||
|
Loading…
Reference in New Issue
Block a user