markdown-preview-enhanced icon indicating copy to clipboard operation
markdown-preview-enhanced copied to clipboard

customize the code block long line wrap.

Open getufkka opened this issue 6 years ago • 6 comments

I always use this fabulous package. I like to use code block most. I want code block fold long sentences at its right ends, not scroll. I mean, I want to see all words in right side pane even in long sentences. I tried to tweak style.less file in .mume.

.markdown-preview.markdown-preview { pre[data-role="codeBlock"] {

Like, white-space, overflow-x, white-space, word-wrap, overflow-wrap several properties.

But it didn't work well for me.

How can I customeze long line wrap setting in the code blocks?

Thanks in advance.

getufkka avatar Oct 16 '19 19:10 getufkka

Hello,

You almost got it. Anyone else looking for a solution:

F1 => Markdown Preview Enhanced : Customize CSS

Then, in the style.less:

.markdown-preview.markdown-preview {
       pre, code {
            white-space: pre-wrap;
       }
}

should enable wrapping for code blocks.

Before:

image

After:

image

basaran avatar Aug 31 '20 07:08 basaran

to basaran

It works well! Thank you so much!

getufkka avatar Aug 31 '20 18:08 getufkka

Thanks @basaran !!

Do you have any idea for long line wrap with line-number? The line number and the program code are out of alignment.

Example:

$ for i in $(seq 1 10); do
    echo "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
done

Result: screenshot

mumeiyamibito avatar Sep 14 '20 16:09 mumeiyamibito

That is expected to happen when you are soft-wrapping. If you need to keep line numbers consistent, then you need to hard-wrap. You can use one of the vscode extensions for that. You can try reflow-markdown and can customize the hard-wrap length.

I usually keep it at around 60 for markdown files and manually invoke it where I want the folding.

"reflowMarkdown.preferredLineLength": 60,

image

basaran avatar Sep 14 '20 21:09 basaran

@basaran Thank you for the advice.

But it did not work for me. Can you reproduce with the following markdown?

'''sh{.line-numbers}
$ for i in $(seq 1 10); do
    echo "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
done
'''

Note: replace ''' with "```".

mumeiyamibito avatar Sep 15 '20 02:09 mumeiyamibito

is it possible to add a backslash at the end of each broken line? So if it's a linux command I can simply ctr + c -> ctrl + v. I wouldnt need to format it later

danielnegreiros avatar Jan 19 '22 14:01 danielnegreiros