Forum
Code formatting/indenting/line-endings on this Forum
I realise updating features on this Forum isn't a high priority, but I wanted to mention it anyway, because it helps users help other users.
I find there are 2 small issues:
1) When we paste code in-between the ~~~
and clicking save, all the indentation is lost, making the code structure slightly harder to decipher.
2) When copying someones code from the Forum to try to help modify their code, pasting into a code editor looses all line endings too, so you get:
<perch:before> <ul class="hfeed listing"></perch:before> <li class="hentry"> <div class="container"> <div class="row"> <div class="col-sm-4"> <h2><a href="<perch:blog id=" postURL" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" /></a></h2> <perch:if exists="image"><img src="<perch:blog id=" image" type="image" width="50" height="50" crop="true" />" alt="<perch:blog id="postTitle" />" /></perch:if> <p class="entry-published date"><perch:blog id="postDateTime" format="%d %B %Y" /></p> <div class="description entry-summary"> <perch:blog id="excerpt" type="textarea" textile="true" /> <p>Comments: <perch:blog id="postCommentCount" /></p> </div> </div> </div> </div> </li> <perch:after> </ul> <perch:if exists="paging"> <div class="paging"> Page <perch:blog id="current_page" /> of <perch:blog id="number_of_pages" /> <perch:blog id="page_links" encode="false" /> <perch:if exists="not_first_page"> <a href="<perch:blog id="prev_url" encode="false" />">Previous</a> </perch:if> <perch:if exists="not_last_page"> <a href="<perch:blog id="next_url" encode="false" />">Next</a> </perch:if> </div> </perch:if> </perch:after>
If there was a way to maintain the indentation and line endings for code in this Forum it would be helpful to those trying to help other users.
Hi Simon
I find if I copy and paste straight into a code editor (Coda in my case) it does as above without the indents, but if I copy and paste into something like TextEdit or Pages (both Mac) and then copy and paste from there into Coda it retains to the formatting/indents. I used your code from this post as a test.
I agree with (1).
Regarding (2), I haven't run into this, but if you are pasting the code into a code editor, you might as well let the editor format it for you if it has a built-in feature (if it doesn't there's probably a plugin available).
When someone includes a long block of code, I paste it into Visual Studio Code, right-click and select 'Format Document'.
Alternatively, you can use CodePen (if the code is not PHP): right corner arrow -> Tidy HTML.
I've just checked Coda plugins and there was one to reformat html, so this now saves me a step copying and pasting in another programme.
Also, I didn't get an email notification that this thread was updated... should I?
It looks like the notifications aren't going out since we moved the servers. I'll look into it.
Thanks for the 'Formatting' advice chaps. I use Espresso. I'll check it out.