Plugin.WordPress icon indicating copy to clipboard operation
Plugin.WordPress copied to clipboard

How to set the max line numbers?

Open Kampi opened this issue 3 years ago • 9 comments

I have several code snippets on my website which are quite long. Is there a way to tell Enlighter to show a specific number of lines and then add a vertical scrollbar?

(Sorry for that noobish question :) )

Kampi avatar May 13 '21 19:05 Kampi

short answer: no, use css as intended

AndiDittrich avatar May 14 '21 07:05 AndiDittrich

short answer: no, use css as intended

Hi,

thank you. How can I do it?

Kampi avatar May 14 '21 11:05 Kampi

see https://github.com/EnlighterJS/EnlighterJS/issues/87 you can copy the related css from the EnlighterJS sources

AndiDittrich avatar May 14 '21 11:05 AndiDittrich

Hi,

I have added the code block

.enlighter-collapse {
    &.@{VIEW_STANDARD} {
        overflow-y: auto;
        max-height: 50px;
    }
    &.@{VIEW_CODEGROUP} {
        .enlighter-codegroup-wrapper {
            overflow-y: auto;
            max-height: 50px;
        }
    }

    &.enlighter-collapse-full.@{VIEW_STANDARD} {
        max-height: none;
    }

    &.enlighter-collapse-full.@{VIEW_CODEGROUP} .enlighter-codegroup-wrapper {
        max-height: none;
    }
}

to my style.css of my theme (as you wrote), but it doesn´t change the visible lines of my code blocks.

Kampi avatar May 14 '21 11:05 Kampi

this is not css, it's the less code including the EnlighterJS framework functions - this won't work.

you have to create your own css rules based on the the example. the sourcecode above has a different purpose (toggle/expand button).

.enlighter-default{
      overflow-y: auto;
       max-height: 100px;
}

AndiDittrich avatar May 14 '21 11:05 AndiDittrich

It´s working now, but I don´t have a scrollbar. I thought overflow-y: auto enables the vertical scrollbar.

Kampi avatar May 14 '21 12:05 Kampi

it depends on the browser - you can also set it to scroll - https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y

AndiDittrich avatar May 14 '21 12:05 AndiDittrich

mmh both options doesn´t work.

Kampi avatar May 14 '21 12:05 Kampi

it's working fine within the dev env image

AndiDittrich avatar May 14 '21 12:05 AndiDittrich

this should be an option in Gutenberg

philippeflorent avatar Dec 11 '22 18:12 philippeflorent

the option is theme related and sets the absolute height (px) of the codeblock

AndiDittrich avatar Dec 12 '22 08:12 AndiDittrich