Skip to content

Instantly share code, notes, and snippets.

@zlargon
Last active April 26, 2016 08:39
Show Gist options
  • Save zlargon/1d598f471e1ebcf6d2779f64d0c10921 to your computer and use it in GitHub Desktop.
Save zlargon/1d598f471e1ebcf6d2779f64d0c10921 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Github Flavored Markdown</title>
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css">
<style>
.markdown-body {
width: 980px;
margin: 20px auto;
padding: 45px;
border: 1px solid lightgray;
border-radius: 3px;
}
</style>
</head>
<body>
<div id="root" class="markdown-body"></div>
<script type="text/javascript">
fetch('https://api.github.com/markdown', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"text": "# Hello world\n\ngithub/linguist#1 **cool**, and #1!",
"mode": "gfm",
"context": "github/gollum"
})
})
.then(res => {
if (res.status !== 200) {
throw new Error(`request failed, status code = ${res.status} (${res.statusText})`);
}
return res.text();
})
.then(html => {
document.getElementById('root').innerHTML = html;
})
.catch(console.error);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment