Skip to content

Commit

Permalink
Added shell prefix for pip install and also added custom js so the $ …
Browse files Browse the repository at this point in the history
…won't be copied
  • Loading branch information
AshleyHenry15 committed Jul 14, 2021
1 parent b10d39d commit 5015877
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To install and use Jupyter within a virtual environment using
- These commands create and activate a `virtualenv` at `/my/path`:
<div class="code-title">Terminal</div>
```bash
pip install virtualenv
$ pip install virtualenv
virtualenv /my/path
source /my/path/bin/activate
```
Expand All @@ -48,10 +48,10 @@ To install and use Jupyter within a virtual environment using
- Install Jupyter inside the `virtualenv`:
<div class="code-title">Terminal</div>
```bash
pip install jupyter
$ pip install jupyter
```
- Install rsconnect-python with your virtual environment active to install and activate the plugin for that copy of Jupyter:
- Install rsconnect-jupyter with your virtual environment active to install and activate the plugin for that copy of Jupyter:
--8<-- "snippets/python_pkg.md"
Expand Down
30 changes: 20 additions & 10 deletions docs/docs/js/custom.js
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">&gt;</span> ';
var python_shell_regex = '^(<span></span>)?<span class="o">&gt;&gt;&gt;</span> ';
regexs = [terminal_regex, r_console_regex, python_shell_regex]
replacements = ["$", "&gt;", "&gt;&gt;&gt;"]
regexs = [terminal_regex, console_regex, r_console_regex, python_shell_regex]

// Replacements for each of the regex
replacements = ["$", "$", "&gt;", "&gt;&gt;&gt;"]

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;

}
}
}
2 changes: 1 addition & 1 deletion docs/docs/snippets/python_pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- Install the `rsconnect-jupyter` package with the following command:
<div class="code-title">Terminal</div>
```bash
pip install rsconnect_jupyter
$ pip install rsconnect_jupyter
```

- Enable the `rsconnect-jupyter` extension with the following commands:
Expand Down

0 comments on commit 5015877

Please sign in to comment.