From 50158770dedaa323c61fdf2504b3f8a4aecfed31 Mon Sep 17 00:00:00 2001 From: AshleyHenry15 Date: Wed, 14 Jul 2021 16:37:52 -0400 Subject: [PATCH] Added shell prefix for pip install and also added custom js so the $ won't be copied --- docs/docs/index.md | 6 +++--- docs/docs/js/custom.js | 30 ++++++++++++++++++++---------- docs/docs/snippets/python_pkg.md | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/docs/docs/index.md b/docs/docs/index.md index 2308a44d..7fb59237 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -37,7 +37,7 @@ To install and use Jupyter within a virtual environment using - These commands create and activate a `virtualenv` at `/my/path`:
Terminal
```bash - pip install virtualenv + $ pip install virtualenv virtualenv /my/path source /my/path/bin/activate ``` @@ -48,10 +48,10 @@ To install and use Jupyter within a virtual environment using - Install Jupyter inside the `virtualenv`:
Terminal
```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" diff --git a/docs/docs/js/custom.js b/docs/docs/js/custom.js index 8c3191ee..d7e736dc 100644 --- a/docs/docs/js/custom.js +++ b/docs/docs/js/custom.js @@ -1,16 +1,25 @@ // 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 = "^()?\\$ "; +// 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 = "^()?(\")?\\$ "; + var console_regex = '^()?\\$ '; var r_console_regex = '^()?> '; var python_shell_regex = '^()?>>> '; - 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] @@ -18,5 +27,6 @@ for(var i = 0; i < codehilites.length; i++) { var str = pre_block.innerHTML; str = str.replace(re, "" + replacement + " "); pre_block.innerHTML = str; + } -} +} \ No newline at end of file diff --git a/docs/docs/snippets/python_pkg.md b/docs/docs/snippets/python_pkg.md index 0a5f7b47..38046119 100644 --- a/docs/docs/snippets/python_pkg.md +++ b/docs/docs/snippets/python_pkg.md @@ -3,7 +3,7 @@ - Install the `rsconnect-jupyter` package with the following command:
Terminal
```bash - pip install rsconnect_jupyter + $ pip install rsconnect_jupyter ``` - Enable the `rsconnect-jupyter` extension with the following commands: