mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Add version check
This commit is contained in:
parent
c6f5127385
commit
568c4f75d9
4 changed files with 34 additions and 5 deletions
|
|
@ -56,7 +56,9 @@
|
||||||
const previewElm = $('preview');
|
const previewElm = $('preview');
|
||||||
const htmlElm= $$('#html pre');
|
const htmlElm= $$('#html pre');
|
||||||
const permelinkElm = $('permalink')
|
const permelinkElm = $('permalink')
|
||||||
|
const messageElm = $('message');
|
||||||
|
|
||||||
|
messageElm.innerText = "";
|
||||||
const options = getOptions();
|
const options = getOptions();
|
||||||
const html = toHtml(inputElm.value, options);
|
const html = toHtml(inputElm.value, options);
|
||||||
previewElm.innerHTML = html;
|
previewElm.innerHTML = html;
|
||||||
|
|
@ -84,13 +86,20 @@
|
||||||
const onload = function(obj) {
|
const onload = function(obj) {
|
||||||
wasm = obj.instance;
|
wasm = obj.instance;
|
||||||
go.run(wasm);
|
go.run(wasm);
|
||||||
document.getElementById("convert-markdown").disabled = false;
|
$("convert-markdown").disabled = false;
|
||||||
const u = new URL(location.href);
|
const u = new URL(location.href);
|
||||||
if(u.searchParams.has("m")) {
|
if(u.searchParams.has("m")) {
|
||||||
setOptions(u.searchParams.get("o"));
|
setOptions(u.searchParams.get("o"));
|
||||||
$("input").value = decodeURIComponent(u.searchParams.get("m"));
|
$("input").value = decodeURIComponent(u.searchParams.get("m"));
|
||||||
convert();
|
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) {
|
if ('instantiateStreaming' in WebAssembly) {
|
||||||
|
|
@ -101,8 +110,7 @@
|
||||||
).then(bytes => WebAssembly.instantiate(bytes, go.importObject).then(onload));
|
).then(bytes => WebAssembly.instantiate(bytes, go.importObject).then(onload));
|
||||||
}
|
}
|
||||||
|
|
||||||
[...document.querySelectorAll('#container pre')]
|
for(const pre of [...document.querySelectorAll('#container pre')]){
|
||||||
.map(pre => {
|
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
pre.parentNode.insertBefore(button, pre);
|
pre.parentNode.insertBefore(button, pre);
|
||||||
button.textContent = 'copy';
|
button.textContent = 'copy';
|
||||||
|
|
@ -121,7 +129,7 @@
|
||||||
button.textContent = 'copy';
|
button.textContent = 'copy';
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -130,6 +138,8 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>goldmark@v1.7.0 playground</h1>
|
<h1>goldmark@v1.7.0 playground</h1>
|
||||||
|
<section id="message">
|
||||||
|
</section>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="markdown">
|
<div id="markdown">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -1148,3 +1148,7 @@ button.pre-copy {
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#message .warn {
|
||||||
|
color: var(--color-danger-fg);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,9 @@
|
||||||
const previewElm = $('preview');
|
const previewElm = $('preview');
|
||||||
const htmlElm= $$('#html pre');
|
const htmlElm= $$('#html pre');
|
||||||
const permelinkElm = $('permalink')
|
const permelinkElm = $('permalink')
|
||||||
|
const messageElm = $('message');
|
||||||
|
|
||||||
|
messageElm.innerText = "";
|
||||||
const options = getOptions();
|
const options = getOptions();
|
||||||
const html = toHtml(inputElm.value, options);
|
const html = toHtml(inputElm.value, options);
|
||||||
previewElm.innerHTML = html;
|
previewElm.innerHTML = html;
|
||||||
|
|
@ -84,13 +86,20 @@
|
||||||
const onload = function(obj) {
|
const onload = function(obj) {
|
||||||
wasm = obj.instance;
|
wasm = obj.instance;
|
||||||
go.run(wasm);
|
go.run(wasm);
|
||||||
document.getElementById("convert-markdown").disabled = false;
|
$("convert-markdown").disabled = false;
|
||||||
const u = new URL(location.href);
|
const u = new URL(location.href);
|
||||||
if(u.searchParams.has("m")) {
|
if(u.searchParams.has("m")) {
|
||||||
setOptions(u.searchParams.get("o"));
|
setOptions(u.searchParams.get("o"));
|
||||||
$("input").value = decodeURIComponent(u.searchParams.get("m"));
|
$("input").value = decodeURIComponent(u.searchParams.get("m"));
|
||||||
convert();
|
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) {
|
if ('instantiateStreaming' in WebAssembly) {
|
||||||
|
|
@ -129,6 +138,8 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>goldmark@{{version}} playground</h1>
|
<h1>goldmark@{{version}} playground</h1>
|
||||||
|
<section id="message">
|
||||||
|
</section>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="markdown">
|
<div id="markdown">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -1148,3 +1148,7 @@ button.pre-copy {
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#message .warn {
|
||||||
|
color: var(--color-danger-fg);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue