-
Notifications
You must be signed in to change notification settings - Fork 28
resolves #36 allow to copy multiple commands and command with line continuation #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think this can be reduced to a single rx. (even simpler if we had matchAll, but c'est la vie) if (code.dataset.lang === 'console' && text.startsWith('$ ')) {
var cmdRx = /^\$ \S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*(?=\n|$)/gm
var cleanupRx = /( )? *\\\n */g
var cmds = []
var m
while ((m = cmdRx.exec(text))) cmds.push(m[0].substr(2).replace(cleanupRx, '$1'))
text = cmds.join('\n')
} I don't think the commands need to be separated by a semi-colon. And endline does the same thing and is easier for the user to go back to. We could keep the line continuations but in this code I decided to flatten them. |
Not yet. It's still a problem we need to solve in Antora. |
I'm fine using a rx. I can copy and paste your code or you can directly push a commit on my branch I don't mind.
Yes but it will actually run the command on paste. I don't expect the command to run on paste and when it does I'm always a bit shocked/scared (because I like to read the command one last time before pressing "Enter") but it might be just me 😅
I think it's fine 👍
I'm looking forward to it 😉 |
About testing, should I add something to unit test this logic? |
I pushed an update. I like your point about the deferred execution. That makes sense. |
I don't think adding testing for this function is really necessary. It's adding too much complexity to the build for something that is rarely going to change once we get it working. And there are far more important things to test, so I'd rather look at the testing problem as a whole rather than to patch something in. I do like your idea about how to test these pure functions and it's something we should consider for an Antora UI test harness. Though I'm really not 100% comfortable until we are testing in the browser since that's where most of the problems originate. |
Perhaps we should join on |
1a8b675
to
0726e25
Compare
I agree 👍 |
I'm using the same code on the Neo4j documentation UI.
Since this is a pure function, I wrote unit tests (see: https://github.com/neo4j-documentation/docs-ui/blob/master/src/specs/test.code.js) but I'm not sure how to automate them in the Gulp build.
Have you already thought about testing in the docs UI?