mirror of
https://github.com/markedjs/marked
synced 2024-11-22 17:37:24 +00:00
172 lines
4.7 KiB
HTML
172 lines
4.7 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<title>Marked.js Documentation</title>
|
|
<style>
|
|
body {
|
|
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
|
|
font-size: 16px;
|
|
line-height: 1.5;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
#container {
|
|
position: relative;
|
|
max-width: 800px;
|
|
margin: auto;
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
header { display: flex; }
|
|
|
|
header h1 { margin: 0; }
|
|
|
|
table {
|
|
border-spacing: 0;
|
|
border-collapse: collapse;
|
|
border: 1px solid #ddd;
|
|
}
|
|
|
|
td, th {
|
|
border: 1px solid #ddd;
|
|
padding: 5px;
|
|
}
|
|
|
|
a {
|
|
color: #0366d6;
|
|
text-decoration: none;
|
|
}
|
|
|
|
a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
pre {
|
|
font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
|
|
padding: 16px;
|
|
overflow: auto;
|
|
font-size: 85%;
|
|
line-height: 1.45;
|
|
background-color: #f6f8fa;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
code:not([class]) {
|
|
padding: 0.2em 0.4em;
|
|
margin: 0;
|
|
font-size: 85%;
|
|
background-color: rgba(27,31,35,0.05);
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.github-ribbon {
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
border: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="container">
|
|
<header>
|
|
<a href="#/README.md">
|
|
<img src="img/logo-black.svg" height="64px" width="64px" />
|
|
</a>
|
|
<h1>Marked.js Documentation</h1>
|
|
</header>
|
|
|
|
<a href="https://github.com/markedjs/marked">
|
|
<img class="github-ribbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub">
|
|
</a>
|
|
|
|
<div id="content"></div>
|
|
</div>
|
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/unfetch/dist/unfetch.umd.js"></script>
|
|
<script>
|
|
if (!window.Promise) {
|
|
window.Promise = ES6Promise;
|
|
}
|
|
if (!window.fetch) {
|
|
window.fetch = unfetch;
|
|
}
|
|
|
|
var content = document.querySelector('#content');
|
|
var body = document.querySelector('html');
|
|
var currentPage = 'README.md';
|
|
var currentHash = '';
|
|
var renderedPage = '';
|
|
|
|
function hashChange() {
|
|
var hash = location.hash.slice(1);
|
|
if (!hash) {
|
|
hash = 'README.md';
|
|
}
|
|
|
|
var uri = hash.split('#');
|
|
|
|
if (uri[0].match(/^\//)) {
|
|
currentPage = uri[0].slice(1);
|
|
if (uri.length > 1) {
|
|
currentHash = uri[1];
|
|
} else {
|
|
currentHash = '';
|
|
}
|
|
} else {
|
|
currentHash = uri[0];
|
|
}
|
|
|
|
fetchPage(currentPage).then(function () {
|
|
fetchAnchor(currentHash)
|
|
});
|
|
|
|
history.replaceState('', document.title, '#/' + currentPage + (currentHash ? '#' + currentHash : ''));
|
|
}
|
|
|
|
function fetchAnchor(anchor) {
|
|
if (!anchor) {
|
|
return;
|
|
}
|
|
|
|
var hashElement = document.getElementById(anchor);
|
|
if (hashElement) {
|
|
hashElement.scrollIntoView();
|
|
}
|
|
}
|
|
|
|
function fetchPage(page) {
|
|
if (page === renderedPage) {
|
|
return Promise.resolve();
|
|
}
|
|
return fetch(page)
|
|
.then(function (res) {
|
|
if (!res.ok) {
|
|
throw new Error('Error ' + res.status + ': ' + res.statusText);
|
|
}
|
|
return res.text();
|
|
})
|
|
.then(function (text) {
|
|
renderedPage = page;
|
|
content.innerHTML = marked(text);
|
|
body.scrollTop = 0;
|
|
}).catch(function (e) {
|
|
content.innerHTML = '<p>Oops! There was a problem rendering the page.</p>'
|
|
+ '<p>' + e.message + '</p>';
|
|
});
|
|
}
|
|
|
|
window.addEventListener('hashchange', function (e) {
|
|
e.preventDefault();
|
|
hashChange();
|
|
});
|
|
|
|
hashChange();
|
|
</script>
|
|
</body>
|
|
</html>
|