What Happens Normally When You Have a Long Line of Code
Normally when you write a very long line of code, we automatically line-wrap the line of code, adding a backslask \ as a "continuation character" at the end of line, and then continuing the code on the next line.
Related Article Section: We Recommend Manually Wrapping Your Code
You Can't See the Automatic Line Wrapping if You Have Nested a Code Block in a Numbered List Item
You can nest code in numbered list items like this:
1. This is a numbered list item
```
hello world)
```
Now, if you have a long line of code, that will wrap automatically, when it is a normal code block (this example was created using ChatGPT:
Here is an ordinary code block with a long line of code in it:
```
import csv; print("Temperature Analyzer - One-Liner Style"); file_path = input("Enter the path to the CSV file: ");
```
Here's what that would look like in the PDF:
Note the "continuation character" our book generators have automatically inserted, to indicate that the line of code is longer than the page, and it is the same line of code continuing on the next line of the book:
Now, if you nested that long line of code in a numbered list item, like this:
1. Here's the same code in a list item
```
import csv; print("Temperature Analyzer - One-Liner Style"); file_path = input("Enter the path to the CSV file: ");
```
...here is what that would look like in the book:
Note that the line goes over the right-hand margin and some of it is missing, including the continuation character that indicates the line is being automatically wrapped.
The issue has been added to our queue, but we can't promise when it will get to the top of the stack, sorry about that.
So, for now you will have to manually wrap lines of code like this!
Questions or Feedback
If you have any questions or feedback for this article, please email the Leanpub Team at hello@leanpub.com.
To learn about amazing new books and authors, subscribe to our YouTube channel here: https://www.youtube.com/leanpub.
If you have any feedback or questions about this article, please email the Leanpub team about it at hello@leanpub.com!
If you have any questions or thoughts on writing and self-publishing with Leanpub, please join our global community of authors in our Authors Forum here!
Are you interested in self-publishing, and creating your first Leanpub book? Here are some quick tutorials for our most popular writing modes: http://help.leanpub.com/en/articles/3088382-quick-walkthroughs-for-getting-started-on-a-leanpub-book
Are you looking for great deals on Leanpub ebooks, ebook bundles, and courses? Sign up for our Weekly and Monthly newsletter sales here!
You can also follow Leanpub in lots of other places!