This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added shell prefix for pip install and also added custom js so the $ …
…won't be copied
- Loading branch information
1 parent
b10d39d
commit 5015877
Showing
3 changed files
with
24 additions
and
14 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
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 |
---|---|---|
@@ -1,22 +1,32 @@ | ||
// Terminal CSS | ||
// Iterate all the items with class: `language-terminal` | ||
var codehilites = document.getElementsByClassName("codehilite") | ||
for(var i = 0; i < codehilites.length; i++) { | ||
var codehilite = codehilites[i]; | ||
var pre_block = codehilite.getElementsByTagName("pre")[0]; | ||
// Modify the text to encapsulate ($,>,>>>) within one span tags | ||
// So its not selectable | ||
|
||
// Modify the text to encapsulate ($,>,>>>) within span tags | ||
var terminal_regex = "^(<span></span>)?\\$ "; | ||
// Iterate all the items with class: `highlight` | ||
var highlight_divs = document.getElementsByClassName("highlight") | ||
|
||
for(var i = 0; i < highlight_divs.length; i++) { | ||
var highlight = highlight_divs[i]; | ||
var pre_block = highlight.getElementsByTagName("code")[0]; | ||
|
||
|
||
// Valid regexes that will be replace | ||
var terminal_regex = "^(<span></span>)?(\")?\\$ "; | ||
var console_regex = '^(<span></span>)?<span class="gp">\\$</span> '; | ||
var r_console_regex = '^(<span></span>)?<span class="o">></span> '; | ||
var python_shell_regex = '^(<span></span>)?<span class="o">>>></span> '; | ||
regexs = [terminal_regex, r_console_regex, python_shell_regex] | ||
replacements = ["$", ">", ">>>"] | ||
regexs = [terminal_regex, console_regex, r_console_regex, python_shell_regex] | ||
|
||
// Replacements for each of the regex | ||
replacements = ["$", "$", ">", ">>>"] | ||
|
||
for (j in regexs) { | ||
var regex = regexs[j] | ||
var replacement = replacements[j] | ||
var re = new RegExp(regex, "gm"); | ||
var str = pre_block.innerHTML; | ||
str = str.replace(re, "<span class=\"code-noselect\">" + replacement + " </span>"); | ||
pre_block.innerHTML = str; | ||
|
||
} | ||
} | ||
} |
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