Author Options:

How do I include code in my instructable and not have it autoformatted? Answered

I have included code in my instructables before using the Trac wiki markup.  Now when I revisit those pages my code is unreadable as either a block of text or just one line that scrolls out to infinity.  How do I fix this so that my included code actually looks good.



Best Answer 8 years ago

Since you have a paid ("PRO") account, you can do this with the <PRE> HTML tag. Click the Source button and paste your code in between <PRE> and </PRE>. Here's an example:

  The text seen here is in fixed format, sort of like source code. 

Hit the Source button again to go back to WYSIWYG text entry. Make sure, though, that you leave your cursor outside the PRE block! Otherwise you'll have some weird and unexpected behaviour.

That is interesting, and is definitely a bug!

I had put the preformatted text above on three separate lines, with carriage returns.  The "preview" and the "WYSIWIG" version of the text-entry box correctly showed three lines.  However, the processing and storage of the comment stripped those carriage returns, leaving the single line you see above.

None of your instructables look corrupted to me (today). If it was right and the site stuffed-it-up that's a site bug and not something you should have to fix yourself.



Are you using the triple curly brackets?

test code 1 2 3 

perhaps with the new version of the text editor they broke it... :(

Those curly brackets were part of the old "pseudo-Wiki" formatting markup, and are no longer valid.  It's not "broken," its an entirely different back-end software package.

I also assumed it was the curly brackets.  However, my curly brackets seem to have been replaced by the <pre> tag and it doesn't respect the formatting.  It could indeed be the new editor.