From f5c9d8e82970dc955a398898a201c00e18adb95e Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 18 Jul 2022 14:32:51 -0700 Subject: [PATCH] Revert "Removes trailing dash from generated slugs in markdown (#3044)" This reverts commit 8530cce14f9953e0e5d6b12807720e62b9b5cf1f. --- .changeset/cold-bears-sneeze.md | 5 ----- packages/markdown/remark/src/rehype-collect-headers.ts | 6 +----- packages/markdown/remark/test/expressions.test.js | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 .changeset/cold-bears-sneeze.md diff --git a/.changeset/cold-bears-sneeze.md b/.changeset/cold-bears-sneeze.md deleted file mode 100644 index 483d87cd3..000000000 --- a/.changeset/cold-bears-sneeze.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/markdown-remark': minor ---- - -fixed generated slugs in markdown that ends with a dash diff --git a/packages/markdown/remark/src/rehype-collect-headers.ts b/packages/markdown/remark/src/rehype-collect-headers.ts index 50a9c5da1..f8cedd0d5 100644 --- a/packages/markdown/remark/src/rehype-collect-headers.ts +++ b/packages/markdown/remark/src/rehype-collect-headers.ts @@ -53,11 +53,7 @@ export default function createCollectHeaders() { node as any ).value = `<${node.tagName} id={${node.properties.id}}>${raw}`; } else { - let slug = slugger.slug(text); - - if (slug.endsWith('-')) slug = slug.slice(0, -1); - - node.properties.id = slug; + node.properties.id = slugger.slug(text); } } diff --git a/packages/markdown/remark/test/expressions.test.js b/packages/markdown/remark/test/expressions.test.js index 828f70561..db351f9d8 100644 --- a/packages/markdown/remark/test/expressions.test.js +++ b/packages/markdown/remark/test/expressions.test.js @@ -54,7 +54,7 @@ describe('expressions', () => { chai .expect(code) .to.equal( - '

{ foo } is a shorthand for { foo: foo }

' + '

{ foo } is a shorthand for { foo: foo }

' ); });