Friday, September 3, 2010

Test Post

Never having used Blogger or HTML before, I am still testing it out to see how easy or difficult it might be to post with source code examples. I have updated this post to reflect what I consider the easiest way to post source code with HTML. At first I was using <code> tags, but using <pre> tags is actually much easier. The latter doesn't require line breaks or leading spaces, the formatting is how you type it within the <pre> tags. One difference is that by default, <pre> tags do not wrap text, so you must define the following style to get wrapping to work properly (did this in the XML Template file):

<style type="text/css">
pre
{
white-space: pre-wrap;                 /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap;                /* Opera 4-6 */
white-space: -o-pre-wrap;              /* Opera 7 */
word-wrap: break-word;                 /* Internet Explorer 5.5+ */
background: #fbfcfe;
border: 1px solid #DADCE0;
padding: 0.75em 1.5em;
}
</style>

Here is an example of what source code would look like using the <pre> tags:

program main
  implicit none
end program main

The source code for the code block above looks like the following in html:

<pre>
program main
  implicit none
end program main
</pre>

The formatting to the smaller text is automatically handled by the browser when it sees the <pre> tags (pre = pre-formatted). For completeness sake, the html source code was displayed above by replacing the "<" character with &lt; and replacing the ">" character with &gt; when typing out the HTML formatting code.

I did not anticipate learning any HTML formatting, but Blogger's "Compose" leaves something to be desired when typing out source code, which I must do if I wish to provide any Fortran examples. It will probably be easier to post using Blogger's "Edit HTML" option, in order to get the formatting to look correct.

The following links are where I found information about html:
http://www.w3schools.com
http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=41954

No comments:

Post a Comment