Skip to content

Commit fa78320

Browse files
authored
merge PR #19
resolves #36 allow to copy multiple commands and command with line continuation
2 parents 90128aa + 0726e25 commit fa78320

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

preview-src/index.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ vfs
7070
<2> Wrap each streaming file in a buffer so the files can be processed by uglify.
7171
Uglify can only work with buffers, not streams.
7272

73+
Execute these commands to validate and build your site:
74+
75+
$ podman run -v $PWD:/antora:Z --rm -t antora/antora \
76+
version
77+
3.0.0
78+
$ podman run -v $PWD:/antora:Z --rm -it antora/antora \
79+
--clean \
80+
antora-playbook.yml
81+
7382
Cum dicat #putant# ne.
7483
Est in <<inline,reque>> homero principes, meis deleniti mediocrem ad has.
7584
Altera atomorum his ex, has cu elitr melius propriae.

src/js/07-copy-to-clipboard.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,18 @@
4949
copy.addEventListener('click', writeToClipboard.bind(copy, code))
5050
})
5151

52+
function extractCommands (text) {
53+
var cmdRx = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
54+
var cleanupRx = /( )? *\\\n */g
55+
var cmds = []
56+
var m
57+
while ((m = cmdRx.exec(text))) cmds.push(m[1].replace(cleanupRx, '$1'))
58+
return cmds.join(' && ')
59+
}
60+
5261
function writeToClipboard (code) {
5362
var text = code.innerText
54-
if (code.dataset.lang === 'console' && text.startsWith('$ ')) text = text.split('\n')[0].slice(2)
63+
if (code.dataset.lang === 'console' && text.startsWith('$ ')) text = extractCommands(text)
5564
window.navigator.clipboard.writeText(text).then(
5665
function () {
5766
this.classList.add('clicked')

0 commit comments

Comments
 (0)