Click here to Skip to main content
Licence CPOL
First Posted 5 Nov 2007
Views 13,596
Downloads 294
Bookmarked 11 times

CPP to HTML converter

By | 6 Nov 2007 | Article
C++ syntax highlighting in HTML format.

Introduction

Sometimes I need to post C++ code on forums or blogs that don't offer direct support for that. On these sites, the online editor allows you 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.

Using the code

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 a command line argument that specifies the source code is taken from the clipboard and the HTML result is also put in clipboard.

  • Open your preferred IDE and copy the C++ source code into the clipboard.
  • Launch the tool using the shortcut key combination. The HTML result is available in the clipboard.
  • Paste the formatted HTML in the online blog editor.

Points of interest

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 is combined to automate a boring repetitive task.

Download

External download link: http://codecentrix.blogspot.com/2007/05/blogs-and-c-syntax-highlighting.html.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Adrian Dorache

Software Developer (Senior)
Codecentrix Software
Romania Romania

Member

Software consultant in Bucharest Romania writing Windows programs and browsers plug-ins since 1998 with Visual C++.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionCan you post the .y yacc file too please Pinmemberv_srinu_26_f4:15 21 Apr '09  
AnswerRe: Can you post the .y yacc file too please PinmemberAdrian Dorache6:38 21 Apr '09  
GeneralYet another Source to HTML Tool PinmemberMSLeuchtturm1:15 6 Nov '07  
GeneralRe: Yet another Source to HTML Tool PinmemberAdrian Dorache2:20 6 Nov '07  
GeneralVery nice tool PinmemberPaulius Maruka1:08 6 Nov '07  
GeneralRe: Very nice tool PinmemberAdrian Dorache7:07 6 Nov '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 6 Nov 2007
Article Copyright 2007 by Adrian Dorache
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid