You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:44:47 UTC

[47/50] brooklyn-docs git commit: Correctly strip prompt characters from bash snippets when copying to clipboard.

Correctly strip prompt characters from bash snippets when copying to clipboard.

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/commit/1a3633f6
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/tree/1a3633f6
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/diff/1a3633f6

Branch: refs/heads/0.6.0
Commit: 1a3633f6ae1e8520b25663e81ab0f66320eedf6e
Parents: 9a26ffb
Author: Alasdair Hodge <al...@cloudsoftcorp.com>
Authored: Mon Nov 18 11:46:17 2013 +0000
Committer: Alasdair Hodge <al...@cloudsoftcorp.com>
Committed: Mon Nov 18 11:46:17 2013 +0000

----------------------------------------------------------------------
 docs/_layouts/page.html | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/1a3633f6/docs/_layouts/page.html
----------------------------------------------------------------------
diff --git a/docs/_layouts/page.html b/docs/_layouts/page.html
index be1e1f4..00fc6a9 100644
--- a/docs/_layouts/page.html
+++ b/docs/_layouts/page.html
@@ -46,7 +46,10 @@ $(document).ready(function() {
     var target = $(this).next();
     var txt = target.text().trim();
     if (target.find('code.bash')) {
-      txt = txt.replace(/^[^%$]*[%$] /, "").replace(new RegExp('\n[^%$]*[%$] ','g'), "\n");
+      // Strip out bash prompts from the start of each line (i.e. '$' or '%' characters
+      // at the very start, or immediately following any newline). Note this may screw up if
+      // a continuation line (preceding line ends with '\') begins with one of those characters.
+      txt = txt.replace(/(^|\n)[$%] /g, "$1");
     }
     clipboard.setText(txt);
   });