2023-06-25 18:16:06 +02:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
|
|
|
|
<title>Just Share Please</title>
|
|
|
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.0/dist/jquery.min.js"></script>
|
2023-08-11 20:51:34 +02:00
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.5/dist/purify.js"></script>
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.8.0/build/highlight.min.js"></script>
|
2023-08-16 12:13:00 +02:00
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js"></script>
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/markdown-it@13.0.1/dist/markdown-it.min.js"></script>
|
2023-08-17 12:40:32 +02:00
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/markdown-it-texmath@1.0.0/texmath.min.js"></script>
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/markdown-it-anchor@8.6.7/dist/markdownItAnchor.umd.js"></script>
|
2023-06-25 18:16:06 +02:00
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter&display=swap">
|
|
|
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=JetBrains+Mono&display=swap">
|
2023-08-11 20:51:34 +02:00
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css">
|
2023-08-13 15:38:12 +02:00
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.8.0/build/styles/github-dark.min.css" media="(prefers-color-scheme: dark)">
|
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.8.0/build/styles/github.min.css" media="not (prefers-color-scheme: dark)">
|
2023-08-11 22:49:12 +02:00
|
|
|
|
<link rel="stylesheet" href="style.css">
|
2023-06-25 18:16:06 +02:00
|
|
|
|
<link rel="icon" href="favicon.ico">
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<div id="main">
|
|
|
|
|
<script>
|
2023-08-16 12:13:00 +02:00
|
|
|
|
let md = markdownit({
|
|
|
|
|
html: true,
|
|
|
|
|
linkify: true,
|
2023-08-13 15:52:05 +02:00
|
|
|
|
langPrefix: "hljs language-",
|
|
|
|
|
highlight: (c, l) => {
|
|
|
|
|
const language = hljs.getLanguage(l) ? l : "plaintext";
|
|
|
|
|
return hljs.highlight(c, {language}).value;
|
|
|
|
|
}
|
2023-08-16 12:13:00 +02:00
|
|
|
|
});
|
|
|
|
|
md.use(texmath, {
|
|
|
|
|
engine: katex,
|
|
|
|
|
delimiters: ["dollars", "beg_end"]
|
|
|
|
|
});
|
2023-08-17 12:40:32 +02:00
|
|
|
|
md.use(markdownItAnchor, {
|
|
|
|
|
permalink: markdownItAnchor.permalink.linkInsideHeader({
|
|
|
|
|
placement: "after",
|
|
|
|
|
ariaHidden: true
|
|
|
|
|
}),
|
|
|
|
|
// prepend current file id to the anchor permalink (see getId)
|
2023-08-17 14:31:55 +02:00
|
|
|
|
slugify: s => `${getId() ?? ""}-${encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, "-").replace(/[^A-Za-z0-9_-]/g, ""))}`
|
2023-08-17 12:40:32 +02:00
|
|
|
|
});
|
2023-08-11 20:51:34 +02:00
|
|
|
|
|
2023-08-13 15:52:05 +02:00
|
|
|
|
let main = $("#main");
|
2023-06-25 18:16:06 +02:00
|
|
|
|
$(window).on("hashchange", display);
|
|
|
|
|
display();
|
|
|
|
|
|
|
|
|
|
function display() {
|
2023-08-17 12:40:32 +02:00
|
|
|
|
let id = getId();
|
2023-06-25 18:16:06 +02:00
|
|
|
|
$.ajax({
|
2023-08-09 20:13:44 +02:00
|
|
|
|
method: "get",
|
2023-08-17 12:40:32 +02:00
|
|
|
|
url: id ? `share.php?id=${id}` : "index.md",
|
|
|
|
|
success: t => {
|
|
|
|
|
main.html(DOMPurify.sanitize(md.render(t)));
|
|
|
|
|
|
|
|
|
|
// scroll to anchor
|
2023-08-17 13:51:31 +02:00
|
|
|
|
$(() => {
|
|
|
|
|
let element = $(window.location.hash);
|
|
|
|
|
if (element.length)
|
|
|
|
|
$(window).scrollTop(element.offset().top);
|
|
|
|
|
});
|
2023-08-17 12:40:32 +02:00
|
|
|
|
},
|
|
|
|
|
error: (r, s, e) => main.html(`<div class="error"><p>Error loading shared note with id <code>${id}</code>: ${e}</p><p><a href="#">Home</a></p></div>`)
|
2023-06-25 18:16:06 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
2023-08-17 12:40:32 +02:00
|
|
|
|
|
|
|
|
|
function getId() {
|
|
|
|
|
let hash = window.location.hash;
|
|
|
|
|
if (!hash)
|
|
|
|
|
return undefined;
|
|
|
|
|
// hashes consist of the file id, a dash and then the permalink anchor name
|
|
|
|
|
let dash = hash.indexOf("-");
|
|
|
|
|
return hash.substring(1, dash > 0 ? dash : hash.length);
|
|
|
|
|
}
|
2023-06-25 18:16:06 +02:00
|
|
|
|
</script>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="footer">
|
2023-08-17 12:40:32 +02:00
|
|
|
|
Created using <a href="/">Just Share Please</a> for <a href="https://obsidian.md">Obsidian</a>
|
2023-06-25 18:16:06 +02:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
</html>
|