This wasn't supposed to be my first post. I wanted to start my blogging existence writing about something else. It proved that being a blogger is not as easy as it should be, especially when trying to post some C++ code. The online editor allows to directly modify the HTML code but this is not the simplest or most enjoyable thing to do. Because I wanted C++ syntax highlighting so hard I decided to create a little tool to automate this task as much as possible and to allow me to focus on the real subject.
The result is cpptohtml.exe that takes a .cpp file as a command line argument and generates a .html file. If no file name is provided as argument, a standard "file open" dialog allows the user to specify the source .cpp file. The tool also accepts /C as command line arguments. When used the source code is taken from clipboard and the HTML result is put also in clipboard.
The result is cpptohtml.exe that takes a .cpp file as a command line argument and generates a .html file. If no file name is provided as argument, a standard "file open" dialog allows the user to specify the source .cpp file. The tool also accepts /C as command line arguments. When used the source code is taken from clipboard and the HTML result is put also in clipboard.
I found creating a windows shortcut to cpptohtml.exe very useful. This way I can launch the tool by pressing a shortcut key combination (CTR+ALT+T).
I'm gonna use this tool like this:
I'm gonna use this tool like this:
- open preferred IDE and copy the C++ source code into the clipboard.
- launch the tool using the shortcut key combination. The HTML result is in the clipboard.
- paste the formated HTML in the online blog editor.
Download:
You can find here the full source code and the executable. I used Visual C++ and LEX. The archive also contains a .js script to automate the shortcut creation. I am pretty happy with the final result and how C++, LEX and JScript combines to automate a boring repetitive task.
Beautiful the technology is!
You can find here the full source code and the executable. I used Visual C++ and LEX. The archive also contains a .js script to automate the shortcut creation. I am pretty happy with the final result and how C++, LEX and JScript combines to automate a boring repetitive task.
Beautiful the technology is!
12 comments:
hey, u have done a pretty useful utility. Thanks for it ...
but one nuisciance is that it purges all the new lines from the code. Can u please remedy it ...
Can you give me a short example of what is going wrong? Thanks!
Awesomo 5000. Very useful for C++ coders who post code on their blogs. (like me)
Thank you!!
You are welcome!
Please post the .y yacc file to the world
Unfortunately there is no .y yacc file to be posted. The program only uses Lex and not Yacc.
You have really great taste on catch article titles, even when you are not interested in this topic you push to read it
Well your article helped me altogether much in my college assignment. Hats off to you send, will look progressive in the direction of more cognate articles soon as its united of my choice topic to read.
thanks for an awesome program :) can i modify this?
Post a Comment