Skip to content

Commit

Permalink
md_links (#588)
Browse files Browse the repository at this point in the history
* md_links

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
theosanderson and pre-commit-ci[bot] committed May 3, 2024
1 parent 783002a commit f1dfe13
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions taxonium_component/src/utils/processNextstrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,23 @@ async function json_to_tree(json) {
config.enabled_by_gisaid = true;
}

config.overlay = `<p>This is a tree extracted from a <a href='//nextstrain.org'>Nextstrain</a> JSON file, being visualised in Taxonium.</p>.`;
function markdownToHTML(md) {
// Regular expression to match Markdown links
var markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;

// Replace Markdown links with HTML <a> tags
var html = md.replace(
markdownLinkRegex,
'<a class="underline" href="$2">$1</a>'
);

return html;
}

config.overlay = `<p>This is a tree extracted from a <a class='underline' href='//nextstrain.org'>Nextstrain</a> JSON file, being visualised in Taxonium.</p>.`;
if (json.meta.description) {
config.overlay = config.overlay + "<p>" + json.meta.description + "</p>";
config.overlay =
config.overlay + "<p>" + markdownToHTML(json.meta.description) + "</p>";
}

if (json.meta && json.meta.updated) {
Expand Down

0 comments on commit f1dfe13

Please sign in to comment.