controlling line breaks in code

10 views
Skip to first unread message

Gojko Adzic

unread,
Feb 18, 2019, 4:07:04 PM2/18/19
to leanpub
Hi,

Does anyone know how to control line breaks or continuation in code samples? I have a bunch of YAML listings with long lines in code samples (can't do anything about the length, or break into multiple lines, because that's messing up with the validity of the data in YAML formatting.

Leanpub is inserting a backslash and printing a different line number in the continuation. Is there any way this can be configured, so that the content isn't modified and that the line numbers only print for actual lines?
Screenshot 2019-02-18 at 22.05.22.png

Peter Armstrong

unread,
Feb 19, 2019, 10:50:23 AM2/19/19
to lea...@googlegroups.com
Hi Gojko,

If you have a really long YAML string you could try the multiline
support for YAML here
https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines
so that you can wrap the code manually.

In terms of Leanpub, our position is that code should be wrapped
manually for PDF. You can also try increasing your page size if it's
not wide enough, if you haven't already done so. That may reduce the
number of lines you need to manually wrap. Looking at your screenshot
I can't tell if this is at the largest size already or not...

Thanks
Peter
> --
> You received this message because you are subscribed to the Google Groups "leanpub" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to leanpub+u...@googlegroups.com.
> To post to this group, send email to lea...@googlegroups.com.
> Visit this group at https://groups.google.com/group/leanpub.
> To view this discussion on the web visit https://groups.google.com/d/msgid/leanpub/CAN%3D9KnYSkKunT2U8vd_282BaRnG3oxu39yQKcCJ9EtHZoH2KEA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Peter Armstrong
Co-founder & CEO, Ruboss

Gojko Adzic

unread,
Feb 19, 2019, 10:53:20 AM2/19/19
to leanpub
thanks, I guess I'll have to convert this to images outside leanpub then and include as a picture

Peter Armstrong

unread,
Feb 19, 2019, 1:06:34 PM2/19/19
to lea...@googlegroups.com
Then no one will be able to copy and paste the code, or zoom in,
change font sizes, etc. Manually wrapping or even the occasional
Leanpub-inserted backslash is presumably preferable to that, no?
> To view this discussion on the web visit https://groups.google.com/d/msgid/leanpub/CAN%3D9Kna1L0X52RStvjiZX77wiHEvLVnWBLZXcj7kU8XZT1m8rA%40mail.gmail.com.

Gojko Adzic

unread,
Feb 19, 2019, 5:08:12 PM2/19/19
to leanpub
not in this case unfortunately, line breaks in YAML don't mix well with AWS CloudFormation function calls :( but in general I agree

Peter Armstrong

unread,
Feb 19, 2019, 6:31:46 PM2/19/19
to lea...@googlegroups.com
Ah. Well, then just a note like this before or after the first YAML file...

W> Sometimes this book breaks long lines in YAML files with a
backslash at the end of the line, so if you are copying and pasting,
please remove the backslashes.

...is probably also preferable to images :)

Thanks
Peter
> To view this discussion on the web visit https://groups.google.com/d/msgid/leanpub/CAN%3D9Knb8MdmDRH-91QR%3Dd%2BM3Jcdfr2LEB6N%3D1%2BxuvmvG30ng0g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages