From f2ec6fbfa7d71d595b0bef8e0fe6c9c1fbd388ee Mon Sep 17 00:00:00 2001 From: Shuaib Hasan Akib Date: Thu, 4 Sep 2025 01:51:29 +0600 Subject: [PATCH] docs(docs-infra): quote title attributes in links (#63578) Prevent broken HTML when link titles contain spaces by properly quoting the title attribute PR Close #63578 --- adev/shared-docs/pipeline/shared/marked/test/link/link.md | 3 ++- .../pipeline/shared/marked/test/link/link.spec.mts | 6 ++++++ .../pipeline/shared/marked/transformations/link.mts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/adev/shared-docs/pipeline/shared/marked/test/link/link.md b/adev/shared-docs/pipeline/shared/marked/test/link/link.md index a25130fef56..8a8b0b9960a 100644 --- a/adev/shared-docs/pipeline/shared/marked/test/link/link.md +++ b/adev/shared-docs/pipeline/shared/marked/test/link/link.md @@ -1,3 +1,4 @@ [Angular Site](https://angular.dev) [same page](#test) -[same site](../other/page) \ No newline at end of file +[same site](../other/page) +[npm packages](https://docs.npmjs.com/getting-started/what-is-npm "What is npm?") \ No newline at end of file diff --git a/adev/shared-docs/pipeline/shared/marked/test/link/link.spec.mts b/adev/shared-docs/pipeline/shared/marked/test/link/link.spec.mts index cd3ca99cf0b..7ad4a1e6b2e 100644 --- a/adev/shared-docs/pipeline/shared/marked/test/link/link.spec.mts +++ b/adev/shared-docs/pipeline/shared/marked/test/link/link.spec.mts @@ -31,4 +31,10 @@ describe('markdown to html', () => { it('should render internal links that are relative paths', () => { expect(parsedMarkdown).toContain('same site'); }); + + it('should render links with title attributes properly quoted', () => { + expect(parsedMarkdown).toContain( + 'npm packages', + ); + }); }); diff --git a/adev/shared-docs/pipeline/shared/marked/transformations/link.mts b/adev/shared-docs/pipeline/shared/marked/transformations/link.mts index 550799dec21..4b196327d7c 100644 --- a/adev/shared-docs/pipeline/shared/marked/transformations/link.mts +++ b/adev/shared-docs/pipeline/shared/marked/transformations/link.mts @@ -24,6 +24,6 @@ export function linkRender(this: Renderer, {href, title, tokens}: Tokens.Link) { return this.parser.parseInline(tokens); } - const titleAttribute = title ? ` title=${title}` : ''; + const titleAttribute = title ? ` title="${title}"` : ''; return `${this.parser.parseInline(tokens)}`; }