Forum How do I...?

Insert a code wrapping character

rachelandrew
I'm working on the CSS for ebooks that contain a lot of code. As sometimes the lines of code are longer than is available on a page we want to insert a character, in this case a small arrow, to indicate that the code has wrapped and the person copying should not insert a line break.

Is there already a recommended method for achieving this? I am using Prince 10.

Thanks in advance for any suggestions.
mikeday
Unfortunately I don't think it is possible to achieve this without manual oversight at the moment. :(
rachelandrew
If I could add this as a feature request for consideration at some point, it would be very useful for programming books. :)
dauwhe
Something like an nth-line() selector could be really useful for this, and lots of other things like line numbering code or poetry... are there concerns about layout cycles for this?

Dave
mikeday
I think ::nth-line() would be no better/worse than ::first-line, although arguably that's already bad enough, from an implementation perspective. :)

The wrapping arrow character is a bit more like a kind of hyphenation, and I don't think there are any CSS properties for this yet, although perhaps we could introduce some.
_savage
I second that something like :nth-char() would be very useful. For example, inserting a soft linebreak into an overly long title without having to carry markup, like so:
chapter#schnufte > title:nth-char(13):before {                                      
  content: "\n";                                                                 
}                                                                               
mikeday
JavaScript can do this, and more! :)
_savage
Does Prince callback Javascript functions and hands context and format information of sorts?
rachelandrew
Here is what I ended up doing if it is a starting point for anyone: https://gist.github.com/rachelandrew/942a27c93e0384e833d10bd2238b5f8e
mikeday
There is also "overflow-wrap: break-word" which can be helpful.