Reputation: 3
I'm using prettify for color coding but my code is still flat and not indented correctly, how do I format it so it looks similar to github gist or pastebin? (I'm aware you can embed from these sites but it doesn't look very professional).
Upvotes: 0
Views: 240
Reputation: 7254
Here is what I would do, your welcome to go about it differently:
<pre>
tag. If I were using prettify I would type in <pre class="prettyprint"></pre>
<pre>
tags I just created.Upvotes: 0
Reputation: 664538
If your code is flat, you will need to rewrite it - as in github. Maybe you could even find an autoformatter, but it will be as language-dependent as the highlighter.
If your code is only displayed flat, you might need a <pre>
tag around it or set the css property white-space:pre
to the surrounding element.
Upvotes: 1
Reputation: 22125
Depending on your needs, CodeMirror's automatic formatting might suit.
With their formatting extension, you can just do:
editor.autoFormatRange(from, to);
Here's a demo of it in action.
You'd also get the ability to edit your code snippets - and if you don't want that, you can turn it off with the editor.readOnly()
function.
Upvotes: 0