Skip to content

docs: add custom javascript to remove prompt and output - #78

Merged
amoeba merged 6 commits into
columnar-tech:mainfrom
amoeba:docs/smart-clipboard
Sep 25, 2025
Merged

amoeba merged 6 commits into
columnar-tech:mainfrom
amoeba:docs/smart-clipboard

Conversation

@amoeba

@amoeba amoeba commented Sep 23, 2025 •

Copy link
Copy Markdown
Member

Creates and enables an extra.js script adapted from uv's docs that cleans copied code blocks by removing any prompts or output. Also updates some areas in the docs where we weren't using prompt chars that we now can.

Any code blocks with prompt characters must be console not sh for this to work.

Closes #54

We have to use "console" to get the right classes for the clipboard script to work. If you use "sh" and add "$ " to the code block, it doesn't work
@ianmcook

ianmcook commented Sep 23, 2025 •

Copy link
Copy Markdown
Member

Very cool! It might be safer to use && instead of ;.

OTOH I think ; will generally work on Windows in cmd.exe and PowerShell but && won't.

@ianmcook

Copy link
Copy Markdown
Member

I clicked the button to copy the YAML at concepts/driver_manifest and it replaced the line breaks with semicolons.

@ianmcook

ianmcook commented Sep 23, 2025 •

Copy link
Copy Markdown
Member

Looks like this doesn't handle # comment characters properly (like in the blocks on the guides/driver_list page). But the solution might be to get rid of the # characters there.

@amoeba

amoeba commented Sep 24, 2025

Copy link
Copy Markdown
Member Author

Thanks for testing. I also notice that pycon blocks aren't perfect. Fixing these things now.

@amoeba

amoeba commented Sep 24, 2025

Copy link
Copy Markdown
Member Author

Re: ; vs &&, I went for ; for being as cross plat as possible since, as you note, not all shells support && (even fish didn't for a while). However, I think we can maybe get away with preserving the line breaks. So when a user copies a multi-command code block, they get,

first command
second command
third command

bash and zsh don't like this (though fish handles it gracefully) but I don't think it's an unreasonable choice on our part: The user sees multiple lines of commands and might be expecting their clipboard gets filled with similarly-structured output (i.e., we should preserve whitespace where we can and try to just remove prompt/comment chars).

@amoeba

amoeba commented Sep 24, 2025

Copy link
Copy Markdown
Member Author

I've done some manually testing and I think the only place this doesn't work great is pycon blocks (we don't preserve whitespace which python needs to parse). This could be hard to do without rewriting the code. Can we skip it?

@ianmcook ianmcook closed this Sep 25, 2025
@ianmcook ianmcook reopened this Sep 25, 2025
@ianmcook

Copy link
Copy Markdown
Member

With an assist from Claude Code, I fixed the leading whitespace issue and also made the script preserve blank lines. @amoeba please take a look.

@amoeba

amoeba commented Sep 25, 2025

Copy link
Copy Markdown
Member Author

Seems to work nicely, thanks @ianmcook.

@amoeba

amoeba commented Sep 25, 2025

Copy link
Copy Markdown
Member Author

Tested in Safari and Firefox.

@amoeba
amoeba merged commit 9c6f418 into columnar-tech:main Sep 25, 2025
zeroshade added a commit that referenced this pull request Apr 17, 2026
* feat(search): Add search cmd

* update verbose output

* update from comments

* fix test

* clean up output
zeroshade pushed a commit that referenced this pull request Apr 17, 2026
Creates and enables an extra.js script adapted from uv's docs that
cleans copied code blocks by removing any prompts or output. Also
updates some areas in the docs where we weren't using prompt chars that
we now can.

Any code blocks with prompt characters must be `console` not `sh` for
this to work.

Closes #54

---------

Co-authored-by: Ian Cook <[email protected]>
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.

docs: add js snippet to copy code blocks without prompt character

2 participants