correctly flatten command with line continuation when copying
authorDan Allen <dan@opendevise.com>
Sat, 12 Dec 2020 03:33:01 +0000 (20:33 -0700)
committerDan Allen <dan@opendevise.com>
Sat, 12 Dec 2020 03:33:01 +0000 (20:33 -0700)
src/js/06-copy-to-clipboard.js

index 4f4b802..9562dfa 100644 (file)
@@ -44,7 +44,7 @@
 
   function extractCommands (text) {
     var cmdRx = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
-    var cleanupRx = /( )? *\\\n */g
+    var cleanupRx = /( ) *\\\n *|\\\n( ?) */g
     var cmds = []
     var m
     while ((m = cmdRx.exec(text))) cmds.push(m[1].replace(cleanupRx, '$1'))