Skip to content

Instantly share code, notes, and snippets.

@ahaggart
Last active August 2, 2018 04:38
Show Gist options
  • Save ahaggart/d796a51bb1cb76f669ccc9ed2a872254 to your computer and use it in GitHub Desktop.
Save ahaggart/d796a51bb1cb76f669ccc9ed2a872254 to your computer and use it in GitHub Desktop.
var client = new XMLHttpRequest();
client.open('GET', 'content.md');
client.onreadystatechange = function() {
var text = client.responseText;
var converter = new showdown.Converter();
var options = [
['openLinksInNewWindow', true],
['metadata', true],
['simplifiedAutoLink', true],
['excludeTrailingPunctuationFromURLs', true],
['literalMidWordUnderscores', true],
['literalMidWordAsterisks', true],
['strikethrough', true],
['tables', true],
['tasklists', true],
['parseImgDimensions', true],
];
options.forEach((pair)=>converter.setOption(pair[0] ,pair[1]));
var html = converter.makeHtml(text);
var title = converter.getMetadata().title
if(title != undefined){
document.title = title
}
document.getElementById("root").innerHTML = html;
}
client.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment