Pasting source code
I just pasted the contents of a makefile in my blog. I used the html
tags to surround it. However, then I saw that all the tabs are missing. This will render the source code unreadable and unusable when pasted directly in a text editor. Do you know how can I preserve the source code-specific formatting?
Link to your blog?
What about hard coding the html version of a tab (does one exist??)?
And if people copy paste your makefile (nice job, btw, I’ve only started to dive into that stuff) will it keep the tabs even if they’re displayed (ie, will the tabs actually be pasted as spaces)? My understanding is that spaces won’t substitute for tabs in a makefile. Then again, I could be in left field. Like I said, I’m new to this and have never actually written my own makefile.
I don’t know what is the tab tag in html. And I don’t think it is very clever to place such tags every time I need to put a tab. What I want to do is just to paste the code as is – with the tab indentation in tact.
Makefiles are very sensitive to the tab symbol. It must be present so that make parses the file correctly.
Does this help? http://faq.wordpress.com/2007/09/03/how-do-i-post-source-code/
Sorry, I was posting in the middle of the night. I did’t mean html. I meant ASCII. And I’m too hazy at the moment to look it up. Sorry.
But my other concern stands. If you get it to display the tab correctly, when someone goes to paste the makefile into emacs (or heaven forbid vi) will it paste as a tab or will it paste as spaces regardless of how it’s coded?
... and got this: http://onyourshore.wordpress.com/2008/09/05/the-universal-makefile/#more-24 While it preserved the tabs, it made the font horrible. As I don't see makefile syntax in the proposed solution, can I use the css formatting for example?
I meant I used the ‘pre’ and then the ‘code’ tags.
Here’s how you can change the font and the size:
But since you used the “pre” tag, your code will still flow outside the main column. I suggest you switch to a theme with flexible width.
An altogether different solution would be to write the code in a text file and upload the file via the “Add Media” button, which will produce a link to the file in the post.
I managed to apply css code formatting. Now the text looks better. But the page is too narrow and there appears a horizontal scrollbar. What theme can I use to make it brighter?
Btw, Add Media does not work, because makefiles don’t have an extension and are not allowed to be uploaded. Why?
I don’t see why you mind about the scrollbar. Anyway, if you go to Design > Themes and apply the filter, you’ll see that there only nine flexible width themes. Excluding those with very wide sidebars and those of inappropriate style leaves you with Andreas 09, Rubric, Shocking Blue Green, Silver Is The New Black & WordPress Classic.
Why aren’t more file types allowed? To make you pay for the space upgrade… You can fool the uploader by using a false extension in the name of your file (but then you must warn your readers so they don’t try to open it with the wrong application – not very elegant).
The topic ‘Pasting source code’ is closed to new replies.