-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67cf15d
Showing
13 changed files
with
1,741 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License | ||
================ | ||
|
||
Copyright (c) 2012 alibaba.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
markdownViewer | ||
============== | ||
|
||
markdownViewer is a extention for chrome, used for reading markdown file. | ||
|
||
Features: | ||
============== | ||
|
||
1. Reading markdown file | ||
2. Auto reload local file when file is changed | ||
3. Highlight the code area | ||
4. Show outline beside the content | ||
5. Buttons for GoTop, ViewSource and GoBottom | ||
|
||
License | ||
================ | ||
|
||
markdownViewer is released under the MIT license: | ||
|
||
> The MIT License | ||
> | ||
> | ||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. | ||
Thanks | ||
================ | ||
|
||
* markdownreader.js: [https://github.com/yaniswang/markdownReader](https://github.com/yaniswang/markdownReader) | ||
* showdown.js: [https://github.com/coreyti/showdown](https://github.com/coreyti/showdown) | ||
* prettify: [http://code.google.com/p/google-code-prettify/](http://code.google.com/p/google-code-prettify/) | ||
* GitHub: [https://github.com/](https://github.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TODO | ||
===================== | ||
|
||
1. Theme support |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "Markdown Viewer ", | ||
"version": "1.0.2", | ||
"description": "View markdown file in Chrome.", | ||
"icons": { | ||
"128": "images/favicon.png", | ||
"16": "images/favicon.png", | ||
"48": "images/favicon.png" | ||
}, | ||
"permissions": ["tabs", "\u003Call_urls\u003E"], | ||
"content_scripts": [{ | ||
"js": ["prettify.js", "showdown.js", "markdownreader.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" | ||
}], | ||
"web_accessible_resources": [ | ||
"markdownreader.css", | ||
"prettify.css", | ||
"images/top-icon.png", | ||
"images/source-s-icon.png", | ||
"images/bottom-icon.png" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
*{margin:0;padding:0;} | ||
#markdown-container{ | ||
width: 748px; | ||
margin:10px auto; | ||
background-color: #F8F8F8; | ||
border:1px solid #ccc; | ||
box-shadow:0 0 10px #999; | ||
padding:2em; | ||
line-height:1.4em; | ||
font:13.34px helvetica,arial,freesans,clean,sans-serif; | ||
color:black; | ||
} | ||
p { | ||
margin:1em 0; | ||
line-height:1.5em; | ||
} | ||
table { | ||
font-size:inherit; | ||
font:100%; | ||
margin:1em; | ||
} | ||
table th{border-bottom:1px solid #bbb;padding:.2em 1em;} | ||
table td{border-bottom:1px solid #ddd;padding:.2em 1em;} | ||
input[type=text],input[type=password],input[type=image],textarea{font:99% helvetica,arial,freesans,sans-serif;} | ||
select,option{padding:0 .25em;} | ||
optgroup{margin-top:.5em;} | ||
|
||
img{border:0;max-width:100%;} | ||
abbr{border-bottom:none;} | ||
a{color:#4183c4;text-decoration:none;} | ||
a:hover{text-decoration:underline;} | ||
a code,a:link code,a:visited code{color:#4183c4;} | ||
h2,h3{margin:1em 0;} | ||
h1,h2,h3,h4,h5,h6{border:0;} | ||
h1{font-size:170%;border-bottom:4px solid #aaa;padding-bottom:.5em;margin-top:1.5em;} | ||
h1:first-child{margin-top:0;padding-top:.25em;border-top:none;} | ||
h2{font-size:150%;margin-top:1.5em;border-bottom:4px solid #e0e0e0;padding-bottom:.5em;} | ||
h3{margin-top:1em;} | ||
hr{border:1px solid #ddd;} | ||
ul{margin:1em 0 1em 2em;} | ||
ol{margin:1em 0 1em 2em;} | ||
ul li,ol li{margin-top:.5em;margin-bottom:.5em;} | ||
ul ul,ul ol,ol ol,ol ul{margin-top:0;margin-bottom:0;} | ||
blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555;} | ||
dt{font-weight:bold;margin-left:1em;} | ||
dd{margin-left:2em;margin-bottom:1em;} | ||
|
||
#markdown-outline{ | ||
display:none; | ||
position:fixed; | ||
top:10px; | ||
left:-999px; | ||
border:1px solid #ccc; | ||
box-shadow:5px 5px 2px #ccc; | ||
padding: 5px 10px; | ||
background-color: #fff; | ||
} | ||
#markdown-outline ul{ | ||
margin:5px 0 5px 0; | ||
padding-left:30px; | ||
font-size:12px; | ||
border-left:1px dotted #ccc; | ||
} | ||
#markdown-outline ul:first-child{ | ||
border:none; | ||
} | ||
#markdown-outline li{ | ||
list-style-type:decimal; | ||
margin:3px 0; | ||
} | ||
|
||
#markdown-backTop{ | ||
position: fixed; | ||
right:5px; | ||
bottom:5px; | ||
padding:5px; | ||
width:20px; | ||
height:20px; | ||
background:url(images/top-icon.png) no-repeat 5px 5px; | ||
border:1px solid #ccc; | ||
cursor:pointer; | ||
} | ||
|
||
#markdown-raw{ | ||
position: fixed; | ||
right:60px; | ||
bottom:5px; | ||
padding:5px; | ||
width:20px; | ||
height:20px; | ||
background:url(images/source-s-icon.png) no-repeat 5px 5px; | ||
border:1px solid #ccc; | ||
cursor:pointer; | ||
} | ||
|
||
#markdown-bottom{ | ||
position: fixed; | ||
right:120px; | ||
bottom:5px; | ||
padding:5px; | ||
width:20px; | ||
height:20px; | ||
background:url(images/bottom-icon.png) no-repeat 5px 5px; | ||
border:1px solid #ccc; | ||
cursor:pointer; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
(function(document) { | ||
|
||
if (document.doctype) return; | ||
|
||
var link = document.createElement('link'); | ||
link.rel = 'stylesheet'; | ||
link.href = chrome.extension.getURL('markdownreader.css'); | ||
document.head.appendChild(link); | ||
|
||
link = document.createElement('link'); | ||
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">'+ | ||
'</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 lastText = null; | ||
|
||
function updateMarkdown(text) { | ||
if (text !== lastText) { | ||
lastText = text; | ||
markdownConverter.makeHtml(lastText) | ||
document.getElementById('markdown-container').innerHTML = markdownConverter.makeHtml(lastText); | ||
prettyPrint(); | ||
updateOutline(); | ||
} | ||
} | ||
|
||
function updateOutline() { | ||
var arrAllHeader = document.querySelectorAll("h1,h2,h3,h4,h5,h6"); | ||
var arrOutline = ['<ul>']; | ||
var header, headerText; | ||
var id = 0; | ||
var level = 0, | ||
lastLevel = 1; | ||
var levelCount = 0; | ||
for (var i = 0, c = arrAllHeader.length; i < c; i++) { | ||
header = arrAllHeader[i]; | ||
headerText = header.innerText; | ||
|
||
header.setAttribute('id', id); | ||
|
||
level = header.tagName.match(/^h(\d)$/i)[1]; | ||
levelCount = level - lastLevel; | ||
|
||
if (levelCount > 0) { | ||
for (var j = 0; j < levelCount; j++) { | ||
arrOutline.push('<ul>'); | ||
} | ||
} else if (levelCount < 0) { | ||
levelCount *= -1; | ||
for (var j = 0; j < levelCount; j++) { | ||
arrOutline.push('</ul>'); | ||
} | ||
}; | ||
arrOutline.push('<li>'); | ||
arrOutline.push('<a href="#' + id + '">' + headerText + '</a>'); | ||
arrOutline.push('</li>'); | ||
lastLevel = level; | ||
id++; | ||
} | ||
arrOutline.push('</ul>') | ||
var outline = document.getElementById('markdown-outline'); | ||
if(arrOutline.length > 2){ | ||
outline.innerHTML = arrOutline.join(''); | ||
showOutline(); | ||
} | ||
else outline.style.display = 'none'; | ||
} | ||
|
||
function showOutline() { | ||
var outline = document.getElementById('markdown-outline'); | ||
var markdownContainer = document.getElementById('markdown-container'); | ||
outline.style.left = markdownContainer.offsetLeft + markdownContainer.offsetWidth + 10 + 'px'; | ||
outline.style.display = 'block'; | ||
} | ||
|
||
var xmlhttp = new XMLHttpRequest(); | ||
var fileurl = location.href, | ||
bLocalFile = /^file:\/\//i.test(fileurl); | ||
xmlhttp.onreadystatechange = function() { | ||
if (xmlhttp.readyState == 4 && xmlhttp.status != 404) { | ||
updateMarkdown(xmlhttp.responseText); | ||
} | ||
}; | ||
|
||
function checkUpdate() { | ||
xmlhttp.abort(); | ||
xmlhttp.open("GET", fileurl + '?rnd=' + new Date().getTime(), true); | ||
xmlhttp.send(null); | ||
if (bLocalFile) setTimeout(checkUpdate, 500); | ||
} | ||
|
||
checkUpdate(); | ||
|
||
}(document)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
.com { color: #93a1a1; } | ||
.lit { color: #195f91; } | ||
.pun, .opn, .clo { color: #93a1a1; } | ||
.fun { color: #dc322f; } | ||
.str, .atv { color: #D14; } | ||
.kwd, .linenums .tag { color: #1e347b; } | ||
.typ, .atn, .dec, .var { color: teal; } | ||
.pln { color: #48484c; } | ||
|
||
.prettyprint { | ||
padding: 8px; | ||
background-color: #f7f7f9; | ||
border: 1px solid #e1e1e8; | ||
} | ||
.prettyprint.linenums { | ||
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; | ||
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; | ||
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; | ||
} | ||
|
||
/* Specify class=linenums on a pre to get line numbering */ | ||
ol.linenums { | ||
margin: 0 0 0 33px; /* IE indents via margin-left */ | ||
} | ||
ol.linenums li { | ||
padding-left: 12px; | ||
color: #bebec5; | ||
line-height: 18px; | ||
text-shadow: 0 1px 0 #fff; | ||
} | ||
code, pre { | ||
padding: 0 3px 2px; | ||
font-family: Menlo, Monaco, "Courier New", monospace; | ||
font-size: 12px; | ||
color: #333333; | ||
-webkit-border-radius: 3px; | ||
-moz-border-radius: 3px; | ||
border-radius: 3px; | ||
} | ||
code { | ||
padding: 3px 4px; | ||
color: #d14; | ||
background-color: #f7f7f9; | ||
} | ||
pre { | ||
display: block; | ||
padding: 8.5px; | ||
margin: 0 0 9px; | ||
font-size: 12px; | ||
line-height: 18px; | ||
background-color: #f5f5f5; | ||
border: 1px solid #ccc; | ||
border: 1px solid rgba(0, 0, 0, 0.15); | ||
-webkit-border-radius: 4px; | ||
-moz-border-radius: 4px; | ||
border-radius: 4px; | ||
white-space: pre; | ||
white-space: pre-wrap; | ||
word-break: break-all; | ||
} | ||
pre.prettyprint { | ||
margin-bottom: 18px; | ||
} | ||
pre code { | ||
padding: 0; | ||
background-color: transparent; | ||
} |
Oops, something went wrong.