Fortran Module to Export Fortran code to HTML

As I posted the heart in Fortran last week, I saw how ugly the code snippet looked.

Did a quick search to see if there’s a WordPress plugin that can syntax highlight the code to make it much more legible just like the one in fortranwiki.org

Didn’t find any. As the search continued, I thought why not code it myself.

And so here’s the result. A small Fortran module that reads Fortran code and exports it to HTML.

Download it here

I have deliberately decided not to use style sheets as they could not be added to this blog, so the code exports and does the formatting the old way.

Finally my HTML skills came to some use although with some help from Fortran.

The code is developed as a module, so anyone can use it.

Here’s the main program showing how to use it.

program htmlexporter
use htmlexport
character(len=100) filename,file2

filename="C:\temp\stlreader.F"
file2="C:\TEMP\stlreader.html"

call readfile(filename)
call exportcode2html(file2)
end program

Yes two calls readfile reads the file and exportcode2html exports the Fortran source to html.

Posting Fortran code to this blog will be easy now 🙂

Download the code here

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s