-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🎓 Add better warning message for valid dois without bibtex * 🎓 Get year from citation issued literal if it is not parsed * 🎓 Stop removing urls from citation html * 🚨 Add cli warnings for invalid citation labels * 🎓 Add enumerator to citations and cite nodes * 🎓 Pull url from citation data and add to citation node * 🧪 Add transformCitations tests
- Loading branch information
Showing
15 changed files
with
335 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'citation-js-utils': patch | ||
--- | ||
|
||
Get year from citation issued literal if it is not parsed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'citation-js-utils': patch | ||
'myst-cli': patch | ||
--- | ||
|
||
Pull url from citation data and add to citation node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'myst-cli': patch | ||
--- | ||
|
||
Add better warning message for valid dois without bibtex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'myst-spec-ext': patch | ||
'myst-common': patch | ||
'myst-cli': patch | ||
--- | ||
|
||
Add enumerator to citations and cite nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'myst-common': patch | ||
'myst-cli': patch | ||
--- | ||
|
||
Add cli warnings for invalid citation labels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'citation-js-utils': patch | ||
--- | ||
|
||
Stop removing urls from citation html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { Session } from '../session'; | ||
import { transformCitations } from './citations'; | ||
import type { CitationRenderer } from 'citation-js-utils'; | ||
import type { References } from 'myst-common'; | ||
|
||
const RENDERER: CitationRenderer = { | ||
author1: { | ||
render: () => '<rendered 1/>', | ||
inline: () => { | ||
return [{ type: 'text', value: 'inline 1' }]; | ||
}, | ||
getDOI: () => 'abc123', | ||
getURL: () => 'https://example.com', | ||
cite: { id: 'my-cite-1' }, | ||
}, | ||
author2: { | ||
render: () => '<rendered 2/>', | ||
inline: () => { | ||
return [{ type: 'text', value: 'inline 2' }]; | ||
}, | ||
getDOI: () => undefined, | ||
getURL: () => undefined, | ||
cite: { id: 'my-cite-2' }, | ||
}, | ||
}; | ||
|
||
describe('transformCitations', () => { | ||
it('citation transforms', async () => { | ||
const mdast: any = { | ||
type: 'root', | ||
children: [ | ||
{ | ||
type: 'cite', | ||
label: 'author1', | ||
}, | ||
], | ||
}; | ||
const references: References = {}; | ||
transformCitations(new Session(), '', mdast, RENDERER, references); | ||
expect(mdast.children[0].children).toEqual([{ type: 'text', value: 'inline 1' }]); | ||
expect(mdast.children[0].enumerator).toEqual('1'); | ||
expect(references.cite?.order).toEqual(['author1']); | ||
expect(references.cite?.data?.author1).toEqual({ | ||
label: 'author1', | ||
doi: 'abc123', | ||
url: 'https://example.com', | ||
enumerator: '1', | ||
html: '<rendered 1/>', | ||
}); | ||
}); | ||
it('multiple citations transform', async () => { | ||
const mdast: any = { | ||
type: 'root', | ||
children: [ | ||
{ | ||
type: 'cite', | ||
label: 'author2', | ||
}, | ||
{ | ||
type: 'cite', | ||
label: 'author1', | ||
}, | ||
{ | ||
type: 'cite', | ||
label: 'author2', | ||
}, | ||
], | ||
}; | ||
const references: References = {}; | ||
transformCitations(new Session(), '', mdast, RENDERER, references); | ||
expect(mdast.children[0].children).toEqual([{ type: 'text', value: 'inline 2' }]); | ||
expect(mdast.children[0].enumerator).toEqual('1'); | ||
expect(mdast.children[1].children).toEqual([{ type: 'text', value: 'inline 1' }]); | ||
expect(mdast.children[1].enumerator).toEqual('2'); | ||
expect(mdast.children[2].children).toEqual([{ type: 'text', value: 'inline 2' }]); | ||
expect(mdast.children[2].enumerator).toEqual('1'); | ||
expect(references.cite?.order).toEqual(['author2', 'author1']); | ||
expect(references.cite?.data?.author1).toEqual({ | ||
label: 'author1', | ||
doi: 'abc123', | ||
url: 'https://example.com', | ||
enumerator: '2', | ||
html: '<rendered 1/>', | ||
}); | ||
expect(references.cite?.data?.author2).toEqual({ | ||
label: 'author2', | ||
enumerator: '1', | ||
html: '<rendered 2/>', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.