Indentations getting removed on compilation

Hey,

I am making a book about learning to code, but every time I use an indentation (Tab), it disappears when I compile my eBook. Any help?

Thanks,
scarabcoder

E-books use HTML technology to display, and as you might know, HTML doesn’t really do much with a tab character all by itself, as tabs are usually just used to offset HTML code visually for the benefit of the web designer. Indents, using the ruler tool, will usually be a better tool for e-book publishing. There are some exceptions, such as code block ranges in HTML, which will respect tab characters—but at this time it isn’t possible to insert an HTML code block using Scrivener, so I’m not sure if that would be the easiest approach for you. You’d basically have to somehow mark these blocks and then use something like Sigil to do a global search and replace the placeholder with proper HTML/CSS.

Hmm… I understand, but is there a way to insert tabs, or something similar? Would this HTML code work for a space ( )?

With that code you’d have the same basic problem in that you can’t inject raw HTML straight into the output. We plan to make that possible in the future, but at this time it’s not possible. So you would end up with   in the output copy because it would escape the ampersand. That’s why you can’t just type the

 right into the editor.

So that’s why I suggest using a simple thing you can search for, like “– Start Code –” on its own line, and do a global search and replace in Sigil to wrap these blocks in proper HTML, then style it using CSS. That way the tabs will be preserved.

That’s how I would approach it, but I’m a geek. If messing with the internal HTML of the e-book isn’t your cup of tea, I think the other method I described, where you just visually indent your code with the ruler instead of tabs, will work best for you. You’ll have to run some tests to see what looks best.

Consider making the different indent levels you use set as individual formatting presets, so you can just switch to “indent 2” rather than having to mess with the ruler each and every time.