Skip to content

Commit

Permalink
use only zb rather than zbmath (#154)
Browse files Browse the repository at this point in the history
* update pnpm lock

* switch zbmath to just zb

* lint

* revert pnpm-lock

* fix test
  • Loading branch information
StevenClontz authored May 15, 2024
1 parent 390b3e8 commit 5785f14
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 14 deletions.
4 changes: 1 addition & 3 deletions packages/core/src/Parser/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ function isExternalLink(node: any): node is ExternalLinkNode {
}

function isExternalKind(kind: any): kind is ExternalLinkNode['kind'] {
return (
kind && ['doi', 'wikipedia', 'mr', 'mathse', 'mo', 'zbmath'].includes(kind)
)
return kind && ['doi', 'wikipedia', 'mr', 'mathse', 'mo', 'zb'].includes(kind)
}

function isInternalLink(node: any): node is InternalLinkNode {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const refSchema = z.intersection(
z.object({ mr: z.number() }),
z.object({ mathse: z.number() }),
z.object({ mo: z.number() }),
z.object({ zbmath: z.string() }),
z.object({ zb: z.string() }),
]),
)
export type Ref = z.infer<typeof refSchema>
Expand All @@ -22,7 +22,7 @@ export type TaggedRef =
| { kind: 'mr'; id: string; name?: string }
| { kind: 'mathse'; id: string; name?: string }
| { kind: 'mo'; id: string; name?: string }
| { kind: 'zbmath'; id: string; name?: string }
| { kind: 'zb'; id: string; name?: string }

export function tag(ref: Ref): TaggedRef {
const { name } = ref
Expand All @@ -38,6 +38,6 @@ export function tag(ref: Ref): TaggedRef {
} else if ('mo' in ref) {
return { kind: 'mo', id: String(ref.mo), name }
} else {
return { kind: 'zbmath', id: String(ref.zbmath), name }
return { kind: 'zb', id: String(ref.zb), name }
}
}
2 changes: 1 addition & 1 deletion packages/core/test/Bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Bundle', () => {
{ name: 'mr', mr: 'mr' },
{ name: 'mathse', mathse: 1 },
{ name: 'mo', mo: 2 },
{ name: 'zbmath', zbmath: 'zbmath' },
{ name: 'zb', zb: 'zb' },
],
}),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/Parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This is a list of links
* {{wikipedia:123}}
* {{mathse:123}}
* {{mo:123}}
* {{zbmath:123}}
* {{zb:123}}
`

expect(parse(example)).resolves.toMatchSnapshot()
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/__snapshots__/Parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`parses a complex example 1`] = `
<li><a href=\\"wikipedia://123\\" title=\\"123\\" class=\\"external-link\\">123</a></li>
<li><a href=\\"mathse://123\\" title=\\"123\\" class=\\"external-link\\">123</a></li>
<li><a href=\\"mo://123\\" title=\\"123\\" class=\\"external-link\\">123</a></li>
<li><a href=\\"zbmath://123\\" title=\\"123\\" class=\\"external-link\\">123</a></li>
<li><a href=\\"zb://123\\" title=\\"123\\" class=\\"external-link\\">123</a></li>
</ul>"
`;
Expand Down
4 changes: 2 additions & 2 deletions packages/viewer/src/components/Dev/Example.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a list of links
* {{wikipedia:123}}
* {{mathse:123}}
* {{mo:123}}
* {{zbmath:123}}
* {{zb:123}}
`
</script>

Expand Down Expand Up @@ -60,7 +60,7 @@ This is a list of links
<code>wikipedia</code>,
<code>mathse</code>, or
<code>mo</code>, or
<code>zbmath</code>
<code>zb</code>
</p>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/parser/externalLinks.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, it } from 'vitest'
import { external } from './externalLinks'

const providers = ['doi', 'mr', 'wikipedia', 'mathse', 'mo', 'zbmath'] as const
const providers = ['doi', 'mr', 'wikipedia', 'mathse', 'mo', 'zb'] as const

providers.forEach(provider => {
it(`parses ${provider} links`, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/parser/externalLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function format({
href: `https://mathoverflow.net/questions/${id}`,
title: name || `MathOverflow ${id}`,
}
case 'zbmath':
case 'zb':
return {
href: `https://zbmath.org/${id}`,
title: name || `zbMATH ${id}`,
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5785f14

Please sign in to comment.