Skip to content

Commit

Permalink
Add version check
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed Feb 10, 2024
1 parent c6f5127 commit 568c4f7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
18 changes: 14 additions & 4 deletions docs/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
const previewElm = $('preview');
const htmlElm= $$('#html pre');
const permelinkElm = $('permalink')
const messageElm = $('message');

messageElm.innerText = "";
const options = getOptions();
const html = toHtml(inputElm.value, options);
previewElm.innerHTML = html;
Expand Down Expand Up @@ -84,13 +86,20 @@
const onload = function(obj) {
wasm = obj.instance;
go.run(wasm);
document.getElementById("convert-markdown").disabled = false;
$("convert-markdown").disabled = false;
const u = new URL(location.href);
if(u.searchParams.has("m")) {
setOptions(u.searchParams.get("o"));
$("input").value = decodeURIComponent(u.searchParams.get("m"));
convert();
}

if(u.searchParams.has("v")) {
const v = u.searchParams.get("v")
if(v !== goldmarkVersion) {
$("message").innerHTML = "<div class=\"warn\">This link was created for goldmark@"+v+". Results may differ with this version.</div>";
}
}
};

if ('instantiateStreaming' in WebAssembly) {
Expand All @@ -101,8 +110,7 @@
).then(bytes => WebAssembly.instantiate(bytes, go.importObject).then(onload));
}

[...document.querySelectorAll('#container pre')]
.map(pre => {
for(const pre of [...document.querySelectorAll('#container pre')]){
const button = document.createElement('button');
pre.parentNode.insertBefore(button, pre);
button.textContent = 'copy';
Expand All @@ -121,7 +129,7 @@
button.textContent = 'copy';
}, 500);
});
});
}

});

Expand All @@ -130,6 +138,8 @@

<body>
<h1>goldmark@v1.7.0 playground</h1>
<section id="message">
</section>
<div id="container">
<div id="markdown">
<div>
Expand Down
4 changes: 4 additions & 0 deletions docs/playground/playground.css
Original file line number Diff line number Diff line change
Expand Up @@ -1148,3 +1148,7 @@ button.pre-copy {
font-size: .8em;
cursor: pointer;
}

#message .warn {
color: var(--color-danger-fg);
}
13 changes: 12 additions & 1 deletion src/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
const previewElm = $('preview');
const htmlElm= $$('#html pre');
const permelinkElm = $('permalink')
const messageElm = $('message');

messageElm.innerText = "";
const options = getOptions();
const html = toHtml(inputElm.value, options);
previewElm.innerHTML = html;
Expand Down Expand Up @@ -84,13 +86,20 @@
const onload = function(obj) {
wasm = obj.instance;
go.run(wasm);
document.getElementById("convert-markdown").disabled = false;
$("convert-markdown").disabled = false;
const u = new URL(location.href);
if(u.searchParams.has("m")) {
setOptions(u.searchParams.get("o"));
$("input").value = decodeURIComponent(u.searchParams.get("m"));
convert();
}

if(u.searchParams.has("v")) {
const v = u.searchParams.get("v")
if(v !== goldmarkVersion) {
$("message").innerHTML = "<div class=\"warn\">This link was created for goldmark@"+v+". Results may differ with this version.</div>";
}
}
};

if ('instantiateStreaming' in WebAssembly) {
Expand Down Expand Up @@ -129,6 +138,8 @@

<body>
<h1>goldmark@{{version}} playground</h1>
<section id="message">
</section>
<div id="container">
<div id="markdown">
<div>
Expand Down
4 changes: 4 additions & 0 deletions src/playground/playground.css
Original file line number Diff line number Diff line change
Expand Up @@ -1148,3 +1148,7 @@ button.pre-copy {
font-size: .8em;
cursor: pointer;
}

#message .warn {
color: var(--color-danger-fg);
}

0 comments on commit 568c4f7

Please sign in to comment.