Skip to content
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

remove trailing space in codeblock lines #204

Merged
merged 4 commits into from
Dec 22, 2023

Conversation

recrwplay
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented Dec 11, 2023

Deploy Preview for neo4j-docs-ui ready!

Name Link
🔨 Latest commit 7d2542d
🔍 Latest deploy log https://app.netlify.com/sites/neo4j-docs-ui/deploys/6585968aedbee500082e5cd5
😎 Deploy Preview https://deploy-preview-204--neo4j-docs-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@stefano-ottolenghi stefano-ottolenghi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also hook to the copy event so that people doing ctrl-c don't get a broken behavior?

@@ -46,6 +46,8 @@ document.addEventListener('DOMContentLoaded', function () {
input = window.neo4jDocs.copyableCommand(input)
}

input = input.replace(/[ ]+\n/g, '\n').trimEnd()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input = input.replace(/[ ]+\n/g, '\n').trimEnd()
input = input.replace(/[\s]+?\n/g, '\n').trimEnd()

Might be worth testing with this, in case somebody decided to use TAB to space annotations from code. A ? might be needed to ensure \s doesn't eat the carriage return as well.

Copy link
Collaborator Author

@recrwplay recrwplay Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Edited to provide more context)

I think it's worth noting here that we know of only one code block where the space between the code and the callout causes an issue. It might not be only curl that errors, but in most cases I think if you copy and paste some lines of code and there are whitespace characters at the end of lines you are not going to have a problem.

If someone has used tab to space annotations from code we should change that in the asciidoc. We could also resolve this by not having a space in the source before the callout, and adding spacing by updating the css.

Another possible fix is to have guidance to not use callouts in code blocks where the language is curl. (Generally this shouldn't be much of an issue, because these code blocks are unlikely to be very long or require a large number of callouts).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I add some comments here?

  • I find this callout feature really nice to explain complex code or shell commands blocks!
  • right, it is not just curl what would cause errors, but at least all shell commands where a line break character ("") is used before the callout
  • The problem with shell commands and spaces at the end is the shell error message which doesn't help at all to understand the problem. And spaces are invisible 😄. This would lead to user frustration.
    I would like to use callouts so hope this will be fixed - Thx!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps get this out sooner, I would say we just focus on the copy button behavior and the use of a single space as that's the issue that has been identified in this specific case. Further work can be done in a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think [ |\t] will work for us here if we want to also catch tabs. @stefano-ottolenghi please let me know if that misses anything obvious.

I've also added a listener for the copy event when the button either isn't used or isn't available.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! There's only a commented-out line we should remember to remove, but otherwise good work! 🤸

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I've deleted the line now

@MarkWoulfeNeo4j MarkWoulfeNeo4j self-requested a review December 22, 2023 14:07
@recrwplay recrwplay merged commit 6db4a28 into neo4j-documentation:master Dec 22, 2023
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants