viewers/markdown/readme.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/github-markdown.css" />
<style type="text/css">
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding-left: 40px;
}
</style>
</head>
<body>
<article class="markdown-body">
<div id="content"></div>
</article>
<script>
'use strict';
const marked = require('marked');
const openurl = require('openurl');
const fs = require('fs');
var renderer = new marked.Renderer();
renderer.link = function (href, title, text) {
var out = '<a href="javascript:void(0);"';
if (title) {
out += ' title="' + title + '"';
}
out += ' onclick="openurl.open(\'' + href + '\')"';
out += '>' + text + '</a>';
return out;
};
window.onload = function () {
const text = fs.readFileSync(
decodeURIComponent(
(new RegExp('[?|&]readme=([^&;]+?)(&|#|;|$)').exec(
location.search
) || [null, ''])[1].replace(/\+/g, '%20')
) || null,
'utf8'
);
if (text) {
document.getElementById('content').innerHTML = marked(text, {
renderer: renderer,
});
}
};
</script>
</body>
</html>