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

✨Feature Request: Allow wrapping code block by some special syntax like :::js:wrap #2660

Open
4 tasks done
xsjcTony opened this issue Jul 20, 2023 · 5 comments
Open
4 tasks done
Labels
enhancement New feature or request stale theme Related to the theme

Comments

@xsjcTony
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Is that possible to add a special syntax to enable line wrapping in code block,
e.g. something like :::js:line-numbers syntax, maybe :::js:wrap?
Optionally provide a global configuration and :::js:nowrap, the same as lineNumbers?

For a single code block, I can wrap in a <div> and use inline style to force child <code> to wrap by !important, but there's no way I can do so for code-group. So I guess we have to have a built-in syntax by vitepress to handle such things.

And need to make sure it can be used together with :line-numebrs so it won't break anything

Describe the solution you'd like

inline:
to force wrap:

```js:wrap

to force no-wrap:

```js:nowrap

global (default to wrap or not):

export default {
  markdown: {
    wrapCodeBlock: true
  }
}

Describe alternatives you've considered

No response

Additional context

No response

Validations

@xsjcTony xsjcTony changed the title Allow wrapping code block by some special syntax like :::js:wrap [Feature Request]: Allow wrapping code block by some special syntax like :::js:wrap Jul 21, 2023
@xsjcTony xsjcTony changed the title [Feature Request]: Allow wrapping code block by some special syntax like :::js:wrap [✨Feature Request]: Allow wrapping code block by some special syntax like :::js:wrap Jul 21, 2023
@xsjcTony xsjcTony changed the title [✨Feature Request]: Allow wrapping code block by some special syntax like :::js:wrap ✨Feature Request: Allow wrapping code block by some special syntax like :::js:wrap Jul 21, 2023
@brc-dd
Copy link
Member

brc-dd commented Aug 3, 2023

And need to make sure it can be used together with :line-numebrs so it won't break anything

This will be difficult. Code wrapping doesn't work properly with current line number implementations. Refer #2567 (comment)

@brc-dd brc-dd added enhancement New feature or request theme Related to the theme labels Aug 3, 2023
@xsjcTony
Copy link
Contributor Author

xsjcTony commented Aug 3, 2023

@brc-dd I see, as I have read the related issue. Then is that reasonable to implement without compatibility with line-number? I think this is a common case, e.g. displaying long query string

@brc-dd
Copy link
Member

brc-dd commented Aug 3, 2023

Yeah we can add the wrap feature.

@you-hengh
Copy link
Contributor

Yeah we can add the wrap feature.

I read part of the source code, I found that the current vitepress code block does not seem to support automatic line wrapping, I will continue to pay attention to this issue Thank you developers!

@github-actions github-actions bot removed the stale label Mar 7, 2024
@github-actions github-actions bot added the stale label Apr 12, 2024
@tiagorangel1
Copy link

Any update? bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale theme Related to the theme
Projects
None yet
Development

No branches or pull requests

4 participants