Skip to content

Commit

Permalink
🧊 Don't replace node.data, append-new/override individual fields (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejpurves authored May 9, 2024
1 parent 4661c47 commit 7c6f45c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-apes-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-transforms': patch
---

Enable existing `node.data` to flow through transforms, allowing upstream user data to be preserved and available in the AST.
2 changes: 1 addition & 1 deletion packages/myst-transforms/src/links/doi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class DOITransformer implements LinkTransformer {
return false;
}
link.url = doiUrl;
link.data = { doi: doi.normalize(doiUrl) };
link.data = { ...link.data, doi: doi.normalize(doiUrl) };
link.internal = false;
updateLinkTextIfEmpty(link, '');
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-transforms/src/links/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class GithubTransformer implements LinkTransformer {
return false;
}
const [defaultText, data] = parsed;
link.data = data;
link.data = { ...link.data, ...data };
link.internal = false;
updateLinkTextIfEmpty(link, defaultText);
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-transforms/src/links/rrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class RRIDTransformer implements LinkTransformer {
return false;
}
link.url = `${RESOLVER}${rrid}`;
link.data = { rrid };
link.data = { ...link.data, rrid };
link.internal = false;
updateLinkTextIfEmpty(link, rrid);
return true;
Expand Down
1 change: 1 addition & 0 deletions packages/myst-transforms/src/links/wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class WikiTransformer implements LinkTransformer {
.replace(/(?:^_)|(?:_$)/g, '');
link.url = `${result.wiki}wiki/${page}`;
link.data = {
...link.data,
page: page,
wiki: result.wiki,
lang: result.lang,
Expand Down

0 comments on commit 7c6f45c

Please sign in to comment.