mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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
This commit is contained in:
parent
f18980c18d
commit
f2ec6fbfa7
3 changed files with 9 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
[Angular Site](https://angular.dev)
|
||||
[same page](#test)
|
||||
[same site](../other/page)
|
||||
[same site](../other/page)
|
||||
[npm packages](https://docs.npmjs.com/getting-started/what-is-npm "What is npm?")
|
||||
|
|
@ -31,4 +31,10 @@ describe('markdown to html', () => {
|
|||
it('should render internal links that are relative paths', () => {
|
||||
expect(parsedMarkdown).toContain('<a href="../other/page">same site</a>');
|
||||
});
|
||||
|
||||
it('should render links with title attributes properly quoted', () => {
|
||||
expect(parsedMarkdown).toContain(
|
||||
'<a href="https://docs.npmjs.com/getting-started/what-is-npm" title="What is npm?" target="_blank">npm packages</a>',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 `<a href="${href}"${titleAttribute}${anchorTarget(href)}>${this.parser.parseInline(tokens)}</a>`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue