highlightjs-android icon indicating copy to clipboard operation
highlightjs-android copied to clipboard

Feature request: Word-wrap text

Open jscappini opened this issue 7 years ago • 8 comments

Hi!

I'm currently displaying a HighlightJsView inside a tabbed pane, and facing an issue of undesired interaction while side-scrolling long text: Swiping just go to the next tab. In spite of this, I would like to control how long text is displayed, being it word-wrapped or not.

Reading the WebView documentation, I found that I can control this behavior setting the LayoutAlgorithm flag to TEXT_AUTOSIZING, but applying that setting just change nothing in the final result. Intercepting the resulting HTML and then manually adding the word-wrap and white-space styles to the <pre> tag, I got what I want. My question is, can this be controlled with a setting or configuration flag of HighlightJsView?

Thanx!

jscappini avatar Mar 26 '17 17:03 jscappini

Hi @jscappini, Thanks for pointing this out - I'll take a look at it and see whether I can include it as a config field. I'm currently working on a rewrite of the library to allow more customization in general, if there's anything else you would like to see, let me know.

PDDStudio avatar Mar 30 '17 12:03 PDDStudio

Hi @PDDStudio Thanks for your response. By now this issue is holding me back to (more intensively) use your lib, but knowing that you're working on a rewrite is great. I'll try to squeeze it these days so I may give you better feedback. 😃 Keep the great work btw.

jscappini avatar Mar 30 '17 17:03 jscappini

Thanks @jscappini ! Whenever there's something that could improve the library's quality or feature-set feel free to either contribute by opening a pr or an issue for it 😉

PDDStudio avatar Mar 30 '17 17:03 PDDStudio

@PDDStudio you could achieve that without breaking the line number with style:

 td.hljs-ln-code {
   word-wrap: break-word;
   word-break: break-all;
   white-space: pre-wrap;
 }

k0shk0sh avatar Jun 19 '17 04:06 k0shk0sh

@k0shk0sh thanks for pointing out! I'll give this a try once I have finished rewriting the current library module.

PDDStudio avatar Jun 19 '17 11:06 PDDStudio

Np mate, I changed to highlight.js in 3.0.0 for FastHub and realized that wrapping pre isn't the same for that lib so The only way was above mentioned without breaking the line number.b

Sent from my Htc m8 using FastHub

k0shk0sh avatar Jun 19 '17 11:06 k0shk0sh

Is this applied? How to use it now?

mayankneeds avatar Apr 08 '20 10:04 mayankneeds

Is this applied? How to use it now?

pre {
  white-space: pre-wrap;
}

Just add these lines to your CSS file and it will work fine.

uiuxarghya avatar May 10 '22 19:05 uiuxarghya