Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit with minimal working version and README.
- Loading branch information
0 parents
commit d2fdc1f
Showing
21 changed files
with
963 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 @@ | ||
/nbproject/private/ |
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,10 @@ | ||
Copyright (c) 2015 David Stutz | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* Neither the name of David Stutz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,19 @@ | ||
# jQuery Pseudocode | ||
|
||
Lightweight and simple jQuery plugin for displaying pseudo code (similar to several algorithm/pseudocode packages for LaTeX, as for example [`algo.sty`](https://github.com/davidstutz/latex-resources/tree/master/packages)). | ||
|
||
![Example pseudocode.](example.png?raw=true "Example pseudocode.") | ||
|
||
|
||
## License | ||
|
||
Copyright (c) 2015 David Stutz | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* Neither the name of David Stutz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,30 @@ | ||
{ | ||
"name": "jquery-pseudocode", | ||
"description": "jQuery plugin for LaTeX style algorithms/pseudocode.", | ||
"homepage": "http://davidstutz.github.io/jquery-pseudocode/", | ||
"version": "0.9", | ||
"keywords": [ | ||
"js", | ||
"css", | ||
"less", | ||
"jquery" | ||
], | ||
"main": [ | ||
"./dist/js/jquery-pseudocode.js", | ||
"./dist/css/jquery-pseudocode.css", | ||
"./dist/less/jquery-pseudocode.less" | ||
], | ||
"dependencies": { | ||
"jquery": ">= 1.11.0", | ||
"bootstrap": ">= 2.3.2" | ||
}, | ||
"ignore": [ | ||
"docs/.*", | ||
"tests/.*", | ||
"*.html", | ||
"*.git*", | ||
"*.md", | ||
"*.png", | ||
"*.php" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,139 @@ | ||
(function($) { | ||
$.fn.pseudocode = function(options) { | ||
|
||
/** | ||
* Escape the given stirng for regex usage. | ||
* | ||
* @param {type} string | ||
* @returns {unresolved} | ||
*/ | ||
function escape(string) { | ||
var chars = '/.*[]()+$^'; | ||
|
||
for (var i = 0; i < chars.length; i++) { | ||
string = string.replace(chars[i], '\\' + chars[i]); | ||
|
||
} | ||
|
||
return string; | ||
} | ||
|
||
/** | ||
* Wrap a span around the keyword in the line changing the text color. | ||
* | ||
* @param {type} line | ||
* @param {type} keyword | ||
* @param {type} color | ||
* @returns {unresolved} | ||
*/ | ||
function keywords(line, keyword, color) { | ||
|
||
var regex = new RegExp('(' + keyword + ')', 'g'); | ||
line = line.replace(regex, '<b style="color:' + color + '">$1</b>') | ||
|
||
return line; | ||
} | ||
|
||
/** | ||
* Wrap a line comment (beginning with the identifier in 'comment'). | ||
* | ||
* @param {type} line | ||
* @param {type} comment | ||
* @param {type} color | ||
* @returns {unresolved} | ||
*/ | ||
function comment(line, comment, color) { | ||
|
||
var regex = new RegExp('(' + comment + '.*)', 'g'); | ||
line = line.replace(regex, '<i style="color:' + color + '">$1</i>'); | ||
|
||
return line; | ||
} | ||
|
||
var settings = $.extend({ | ||
keywords: { | ||
'if': '#000066', | ||
'for': '#000066', | ||
'var': '#000066', | ||
'function': '#000066', | ||
'return': '#000066', | ||
'this': '#000066', | ||
'while': '#000066', | ||
'end': '#000066', | ||
'endif': '#000066', | ||
'endfor': '#000066', | ||
'endwhile': '#000066', | ||
}, | ||
comment: { | ||
'//': '#006600', | ||
'%': '#006600' | ||
}, | ||
tab: 4 | ||
}, options); | ||
|
||
var $this = $(this); | ||
$this.hide(); | ||
|
||
var code = $this.text().trim(); | ||
var lines = code.split("\n"); | ||
|
||
var depth = 0; | ||
var html = '<ul class="pseudocode">'; | ||
|
||
$.each(lines, function(i, line) { | ||
|
||
for (var i = 0; i < line.length; i++) { | ||
if (line[i] !== ' ') { | ||
break; | ||
} | ||
} | ||
|
||
// Check on which level we are. | ||
var indent = Math.floor((i + 1)/settings.tab); | ||
if (indent > depth) { | ||
html += '<ul>'; | ||
} | ||
else if (indent < depth) { | ||
for (var i = indent; i > 0; i--) { | ||
html += '</li></ul>'; | ||
} | ||
} | ||
else { | ||
html += '</li>'; | ||
} | ||
|
||
// Update current depth. | ||
depth = indent; | ||
|
||
// Scan for line comments. | ||
var commentLine = false; | ||
$.each(settings.comment, function(key, color) { | ||
if (line.indexOf(key) >= 0) { | ||
line = comment(line, escape(key), color); | ||
commentLine = true; | ||
} | ||
}); | ||
|
||
if (commentLine === false) { | ||
// Scan for keywords: | ||
$.each(settings.keywords, function(keyword, color) { | ||
if (line.indexOf(keyword) >= 0) { | ||
line = keywords(line, keyword, color); | ||
} | ||
}); | ||
} | ||
html += '<li>' + line.trim(); | ||
}); | ||
|
||
for (var i = depth; i > 0; i--) { | ||
html += '</li></ul>'; | ||
} | ||
|
||
html += '</ul>'; | ||
|
||
$ul = $(html); | ||
$this.after($ul); | ||
|
||
return this; | ||
}; | ||
}(jQuery)); |
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,11 @@ | ||
.pseudocode { | ||
list-style-type: none; | ||
padding-left: 0; | ||
|
||
font-family: Menlo,Monaco,Consolas,"Courier New",monospace; | ||
|
||
ul { | ||
list-style-type: none; | ||
padding-left: 24px; | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 @@ | ||
.com { color: #93a1a1; } | ||
.lit { color: #195f91; } | ||
.pun, .opn, .clo { color: #93a1a1; } | ||
.fun { color: #dc322f; } | ||
.str, .atv { color: #D14; } | ||
.kwd, .prettyprint .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: 20px; | ||
text-shadow: 0 1px 0 #fff; | ||
} |
Binary file not shown.
Oops, something went wrong.