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)}`; }