Skip to content

Commit

Permalink
use marked.js to render MD
Browse files Browse the repository at this point in the history
  • Loading branch information
sopo-to-iki committed Apr 26, 2013
1 parent 6d72fef commit 38abbc5
Show file tree
Hide file tree
Showing 4 changed files with 792 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"permissions": ["tabs", "\u003Call_urls\u003E"],
"content_scripts": [{
"js": ["prettify.js", "showdown.js", "markdownreader.js"],
"js": ["prettify.js", "markdownreader.js","marked.js"],
"matches": ["*://*/*.md", "file://*/*.md", "*://*/*.markdown", "file://*/*.markdown", "*://*/*.mdown", "file://*/*.mdown", "*://*/*.mkdn", "file://*/*.mkdn", "*://*/*.mkd", "file://*/*.mkd", "*://*/*.text", "file://*/*.text", "*://*/*.mdtext", "file://*/*.mdtext", "*://*/*.mdtxt", "file://*/*.mdtxt"],
"run_at": "document_end"
}],
Expand Down
15 changes: 10 additions & 5 deletions markdownreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,26 @@
link.rel = 'stylesheet';
link.href = chrome.extension.getURL('prettify.css');
document.head.appendChild(link);
document.body.innerHTML = '<div id="markdown-container"></div><div id="markdown-outline">'+
document.body.innerHTML = '<div id="markdown-container"></div><div id="markdown-outline">'+
'</div><div id="markdown-backTop" onclick="window.scrollTo(0,0);">'+
'</div><div id="markdown-bottom" onclick="window.scrollTo(0, document.body.scrollHeight);"></div>'+
'<div id="markdown-raw" onclick="window.location=\'view-source:\' + window.location.href;"></div>';

window.onresize = showOutline;

var markdownConverter = new Showdown.converter();
//var markdownConverter = new Showdown.converter();
var lastText = null;

function updateMarkdown(text) {
if (text !== lastText) {
marked.setOptions({
gfm: true,
pedantic: false,
sanitize: false
});
lastText = text;
markdownConverter.makeHtml(lastText)
document.getElementById('markdown-container').innerHTML = markdownConverter.makeHtml(lastText);
//markdownConverter.makeHtml(lastText)
document.getElementById('markdown-container').innerHTML = marked(lastText);
prettyPrint();
updateOutline();
}
Expand Down Expand Up @@ -70,7 +75,7 @@
outline.innerHTML = arrOutline.join('');
showOutline();
}
else outline.style.display = 'none';
else outline.style.display = 'none';
}

function showOutline() {
Expand Down
Loading

0 comments on commit 38abbc5

Please sign in to comment.