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

Break lines in wide code examples #18

Closed
digitalcraftsman opened this issue Mar 16, 2016 · 6 comments
Closed

Break lines in wide code examples #18

digitalcraftsman opened this issue Mar 16, 2016 · 6 comments

Comments

@digitalcraftsman
Copy link

Sometimes the lines code examples can be very long (e.g. due to indentation ). This creates horizontal scrollbars which isn't ideal for reading. Those could be avoided adding a CSS rule for breaking a line automatically if it doesn't fit.

@carlosperate
Copy link

Are these scrollbars in the entire window, or just the code area? If only in the code area I much prefer this view option as compared with automatic breaklines, so maybe an option could be included?

@digitalcraftsman
Copy link
Author

The horizontal scrollbar only appears in the code block, so the layout isn't broken. An option to enable/disable this behavior would be a good compromise.

@squidfunk
Copy link
Owner

Well, especially on mobile devices, many lines will break, and in my opinion the code will become unreadable. You can easily fix it with one line of extra css if you like it better, so adding an option for this would be overkill.

Reading all those specific features we could think about adding a recipes page to the documentation, where we show how to do this things with extra css.

@StefanZander
Copy link

I sometimes use a code environment (style) for discussing texts with students since code blocks offer line numbers that help in referring to specific lines/sentences/words/etc. in the text.

Since I haven't found the recipe yet, I would very much like the option of automatic line breaks since there are definitely use cases where this feature is helpful.

Just my 2cents...

@squidfunk
Copy link
Owner

squidfunk commented Jul 23, 2019

Since I haven't found the recipe yet, I would very much like the option of automatic line breaks since there are definitely use cases where this feature is helpful.

Unfortunately, within the HTML, line numbers are detached from the code – they are within a separate table cell, see:

Bildschirmfoto 2019-07-23 um 17 33 27

This means that it's impossible to break lines of code with CSS and have them still align with line numbers. The table is rendered by CodeHilite which is a Python Markdown extension. Material can only provide styles for the output it gets from MkDocs and by then it's too late.

@StefanZander
Copy link

Thanks for the helpful response Martin; that seems totally reasonable to me.

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

No branches or pull requests

4 participants