Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion _includes/head.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
{% if page.url == '/' -%}
{{- siteTitle -}}
{%- else -%}
{{- title }} · {{ siteTitle -}}
{%- comment -%}
Once, not plain escape: a hand-written title may already carry an
entity, while an SDK API title such as Guard<T> is plain text that
the minifier would otherwise read as a tag.
{%- endcomment -%}
{{- title | escape_once }} &middot; {{ siteTitle -}}
{%- endif %}
</title>
{% if env == 'production' -%}
Expand Down
4 changes: 3 additions & 1 deletion build/shared/sdk-docs.mts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export function stripTypeDocChrome(markdown: string) {

if (heading !== null) {
return {
title: heading[1],
// TypeDoc escapes a heading's Markdown punctuation, as in `Guard\<T\>`,
// but the title is printed as plain text, where a backslash would show.
title: heading[1].replace(/\\([!-/:-@[-`{-~])/g, '$1'),
content: content.slice(heading[0].length),
};
}
Expand Down
12 changes: 12 additions & 0 deletions build/shared/sdk-docs.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ describe('stripTypeDocChrome', () => {
);
});

test('unescapes the Markdown punctuation in a generic type’s title', () => {
deepStrictEqual(
stripTypeDocChrome(
'[**OpenINF**](../../README.md)\n\n***\n\n[OpenINF](../../packages.md) / [@openinf/util-types](../README.md) / Guard\n\n# Type Alias: Guard\\<T\\>\n\n> **Guard**\\<`T`\\> = (`value`) => `value is T`\n'
),
{
title: 'Type Alias: Guard<T>',
content: '> **Guard**\\<`T`\\> = (`value`) => `value is T`\n',
}
);
});

test('handles a package readme with an HTML h1', () => {
deepStrictEqual(
stripTypeDocChrome(
Expand Down
Loading