diff --git a/PR.md b/PR.md new file mode 100644 index 00000000..80a7ad88 --- /dev/null +++ b/PR.md @@ -0,0 +1,21 @@ +# fix/render-hierarchical-tags + +Fixes: https://github.com/callumalpass/tasknotes/issues/1428 + +## Fix hierarchical tags in Agenda + +Render hierarchical tags with slashes (e.g., #g/tog) as a single tag token in Agenda/Task list views. This prevents the slash suffix from being rendered as plain text. + +Examples (illustrative): + +- #g/tog renders as one tag +- #project/sub-project renders as one tag + +## Changelog + +- expand tag regex in link text rendering to include slashes +- enable regression test for hierarchical tag rendering in link text + +## Tests + +- npm run test:unit -- --runTestsByPath tests/unit/issues/issue-1428-hashtags-with-slashes.test.ts diff --git a/src/ui/renderers/linkRenderer.ts b/src/ui/renderers/linkRenderer.ts index a0a96728..170759c0 100644 --- a/src/ui/renderers/linkRenderer.ts +++ b/src/ui/renderers/linkRenderer.ts @@ -198,7 +198,7 @@ export function renderTextWithLinks( const remainingText = text.slice(lastIndex); if (remainingText && options?.onTagClick) { // Look for tags in the remaining text - const tagRegex = /(^|\s)(#\w+)/g; + const tagRegex = /(^|\s)(#[\p{L}\p{N}\p{M}_/-]+)/gu; let tagLastIndex = 0; let tagMatch: RegExpExecArray | null; diff --git a/tests/unit/issues/issue-1428-hashtags-with-slashes.test.ts b/tests/unit/issues/issue-1428-hashtags-with-slashes.test.ts index 9aba7336..8d53affc 100644 --- a/tests/unit/issues/issue-1428-hashtags-with-slashes.test.ts +++ b/tests/unit/issues/issue-1428-hashtags-with-slashes.test.ts @@ -24,7 +24,7 @@ import { renderTextWithLinks, LinkServices } from '../../../src/ui/renderers/linkRenderer'; import { makeContainer } from '../../helpers/dom-helpers'; -describe.skip('Issue #1428: Hashtags with slashes not rendered correctly', () => { +describe('Issue #1428: Hashtags with slashes not rendered correctly', () => { // Mock LinkServices for rendering const mockLinkServices: LinkServices = { metadataCache: {