From 22211ae18076c17bf0536939a85b734fbee33013 Mon Sep 17 00:00:00 2001 From: James Dabbs Date: Tue, 7 Nov 2023 07:20:24 -0700 Subject: [PATCH] feat: support {S#|P#} syntax for linking to traits (#78) fixes #66 --- packages/viewer/cypress/e2e/typesetting.spec.ts | 17 +++++++++++++++++ .../viewer/src/components/Dev/Example.svelte | 4 ++++ .../viewer/src/components/Dev/Preview.svelte | 9 +++++++-- .../viewer/src/components/Shared/Typeset.svelte | 13 ++++++++++++- .../viewer/src/parser/internalLinks.test.ts | 9 +++++++++ packages/viewer/src/parser/internalLinks.ts | 14 ++++++++++++++ packages/viewer/vite.config.js | 6 +++--- 7 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 packages/viewer/cypress/e2e/typesetting.spec.ts diff --git a/packages/viewer/cypress/e2e/typesetting.spec.ts b/packages/viewer/cypress/e2e/typesetting.spec.ts new file mode 100644 index 00000000..4ea0869e --- /dev/null +++ b/packages/viewer/cypress/e2e/typesetting.spec.ts @@ -0,0 +1,17 @@ +import { deduce, setup } from '../support' + +beforeEach(setup) + +it('renders internal links', () => { + cy.visit('dev/preview') + deduce() + + cy.get('[data-testid=input]').type( + // {{} is Cypress escaping for {. See https://docs.cypress.io/api/commands/type#Arguments + `{{}S000001} is {{}P000001} as noted in {{}S000001|P000001}`, + ) + + cy.get('[data-testid=output]').contains( + 'Discrete topology on a two-point set is $T_0$ as noted in Discrete topology on a two-point set | $T_0$', + ) +}) diff --git a/packages/viewer/src/components/Dev/Example.svelte b/packages/viewer/src/components/Dev/Example.svelte index 8876b6de..66877aca 100644 --- a/packages/viewer/src/components/Dev/Example.svelte +++ b/packages/viewer/src/components/Dev/Example.svelte @@ -8,6 +8,7 @@ This is a list of links * {S000123} * {P000123} * {T000123} +* {S000123|P000123} * {{doi:123}} * {{mr:123}} * {{wikipedia:123}} @@ -37,6 +38,9 @@ This is a list of links - e.g. {'{S000001}'} for space 1 +
+ {'{S000001|P000002}'} + for space 1's value of property 2 diff --git a/packages/viewer/src/components/Dev/Preview.svelte b/packages/viewer/src/components/Dev/Preview.svelte index 2dd52f9a..d0e1b0ee 100644 --- a/packages/viewer/src/components/Dev/Preview.svelte +++ b/packages/viewer/src/components/Dev/Preview.svelte @@ -11,7 +11,12 @@
-