SourceFormatX

CodeToHtml

軟體簡介

主要功能

原始碼轉換

輸出風格

界面預覽

常見問題

升級歷史

許可協議

程式碼轉換成HTML網頁代碼

現在購買
免費下載

CodeToHtml 程式碼轉換HTML工具 是一款專為程式設計師和網頁設計師設計的程式碼轉換成HTML網頁代碼工具軟體,它能方便快捷地將程式碼轉換成彩色語法高亮的 HTML 程式碼、XHTML 程式碼、BBCode 程式碼 (BB代碼)、RTF 程式碼、TeX 程式碼。

CodeToHtml程式碼轉換HTML工具能夠精確控制 HTML 的特殊字符如 <, >, &, 等等。因此轉換輸出的 HTML 和 XHTML 程式碼能被直接放到 <pre></pre> 符號內以保持程式碼檔案的原版面風格樣式。

  源程式碼檔案

   /* 程式碼轉換成HTML */

   int foo(int x)
   {
     if (x == 1)
       printf("hello!\n");
     else
       printf("good bye!\n");
   }

  程式碼轉換成 HTML

<pre> <code><span style="font: 10pt Courier New"><font color="#000000"> </font><font color="#008000">/* 程式碼轉換成HTML */</font><font color="#000000"> </font><font color="#0000FF">int</font><font color="#000000"> foo</font><font color="#000080">(</font><font color="#0000FF">int</font><font color="#000000"> x</font><font color="#000080">) </font><font color="#000000"> </font><font color="#000080">{ </font><font color="#000000"> </font><font color="#0000FF">if</font><font color="#000000"> </font><font color="#000080">(</font><font color="#000000">x </font><font color="#000080">==</font><font color="#000000"> </font><font color="#800080">1</font><font color="#000080">) </font><font color="#000000"> printf</font><font color="#000080">(</font><font color="#800000">&quot;hello!\n&quot;</font><font color="#000080">); </font><font color="#000000"> </font><font color="#0000FF">else </font><font color="#000000"> printf</font><font color="#000080">(</font><font color="#800000">&quot;good bye!\n&quot;</font><font color="#000080">); </font><font color="#000000"> </font><font color="#000080">}</font></span></code> </pre>

  程式碼轉換成 XHTML

<pre><code><span style="font: 10pt Courier New;"><span class="cpp1-whitespace"> </span><span class="cpp1-comment">/* 程式碼轉換成HTML */ </span><span class="cpp1-whitespace"> </span><span class="cpp1-keyword">int</span><span class="cpp1-whitespace"> foo</span><span class="cpp1-symbol">(</span><span class="cpp1-keyword">int</span><span class="cpp1-whitespace"> x</span><span class="cpp1-symbol">) </span><span class="cpp1-whitespace"> </span><span class="cpp1-symbol">{ </span><span class="cpp1-whitespace"> </span><span class="cpp1-keyword">if</span><span class="cpp1-whitespace"> </span><span class="cpp1-symbol">(</span><span class="cpp1-identifier">x </span><span class="cpp1-symbol">==</span><span class="cpp1-whitespace"> </span><span class="cpp1-number">1</span><span class="cpp1-symbol">) </span><span class="cpp1-whitespace"> printf</span><span class="cpp1-symbol">(</span><span class="cpp1-string">&quot;hello!\n&quot;</span><span class="cpp1-symbol">); </span><span class="cpp1-whitespace"> </span><span class="cpp1-keyword">else </span><span class="cpp1-whitespace"> printf</span><span class="cpp1-symbol">(</span><span class="cpp1-string">&quot;good bye!\n&quot;</span><span class="cpp1-symbol">); </span><span class="cpp1-whitespace"> </span><span class="cpp1-symbol">}</span></span></code></pre>

  程式碼轉換成 BBCode

[color=#008000]/* 程式碼轉換成HTML */[/color][color=#0000FF]int[/color][color=#000000] foo[/color][color=#000080]([/color][color=#0000FF]int[/color][color=#000000] x[/color][color=#000080]) {[/color][color=#000000] [/color][color=#0000FF]if[/color][color=#000000] [/color][color=#000080]([/color][color=#000000]x [/color][color=#000080]==[/color][color=#000000] [/color][color=#800080]1[/color][color=#000080]) [/color][color=#000000] printf[/color][color=#000080]([/color][color=#800000]"hello!\n"[/color][color=#000080]);[/color][color=#000000] [/color][color=#0000FF]else [/color][color=#000000] printf[/color][color=#000080]([/color][color=#800000]"good bye!\n"[/color][color=#000080]);}[/color]

  程式碼轉換成 RTF

{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fmodern Courier New;}} {\colortbl\red0\green128\blue0;\red0\green0\blue255;\red0\green0\blue0;\red0\green0\blue128;\red128\green0\blue128;\red128\green0\blue0;} {\info{\comment generated by the SourceFormatX RTF Generator} {\title c.c}} \deflang1033\pard\plain\f0\fs20 \cf0 /* 程式碼轉換成HTML */ \par \par \cf1 int\cf2 foo\cf3 (\cf1 int\cf2 x\cf3 ) \par \{ \par \cf2 \cf1 if\cf2 \cf3 (\cf2 x \cf3 ==\cf2 \cf4 1\cf3 ) \par \cf2 printf\cf3 (\cf5 "hello!\\n"\cf3 ); \par \cf2 \cf1 else \par \cf2 printf\cf3 (\cf5 "good bye!\\n"\cf3 ); \par \} \par }

  程式碼轉換成 TeX

\documentclass[a4paper, 10pt]{article} \usepackage[a4paper, margin=2cm]{geometry} \usepackage[T1]{fontenc} \usepackage{color} \usepackage{alltt} \usepackage{times} \usepackage{ulem} \usepackage[ansinew]{inputenc} % Special Characters \newcommand\SPC{\hspace*{0.6em}} \newcommand\TAB{\hspace*{1.2em}} \newcommand\BS{\mbox{\char 92}} \newcommand\TLD{\mbox{\char 126}} \newcommand\CIR{\mbox{\char 94}} \newcommand\HYP{\mbox{\char 45}} \newcommand\QOT{\mbox{\char 34}} \newcommand{\uln}[1]{\bgroup \markoverwith{\hbox{\_}}\ULon{{#1}}} % Highlighter Attributes \newcommand{\CppAAssembler}[1]{\textcolor[rgb]{0,0.31,0.75}{#1}} \newcommand{\CppACharacter}[1]{\textcolor[rgb]{0.63,0,0}{#1}} \newcommand{\CppAComment}[1]{\textcolor[rgb]{0,0.5,0}{#1}} \newcommand{\CppADoxygen}[1]{\textcolor[rgb]{0,0.5,0.5}{#1}} \newcommand{\CppADoxygenKeyword}[1]{\textcolor[rgb]{0,0.31,0.75}{#1}} \newcommand{\CppAFloat}[1]{\textcolor[rgb]{0,0.4,0.6}{#1}} \newcommand{\CppAHexadecimal}[1]{\textcolor[rgb]{0,0,0.63}{#1}} \newcommand{\CppAIdentifier}[1]{\textcolor[rgb]{0,0,0}{#1}} \newcommand{\CppAIllegalChar}[1]{\textcolor[rgb]{1,0,0}{#1}} \newcommand{\CppAKeyword}[1]{\textcolor[rgb]{0,0,1}{#1}} \newcommand{\CppANumber}[1]{\textcolor[rgb]{0.5,0,0.5}{#1}} \newcommand{\CppAOctal}[1]{\textcolor[rgb]{0,0.4,0.4}{#1}} \newcommand{\CppAOpenGL}[1]{\textcolor[rgb]{0.5,0,1}{#1}} \newcommand{\CppAPreprocessor}[1]{\textcolor[rgb]{0,0,1}{#1}} \newcommand{\CppASourceFormatXTag}[1]{\textcolor[rgb]{0.5,0.5,0.5}{#1}} \newcommand{\CppAString}[1]{\textcolor[rgb]{0.5,0,0}{#1}} \newcommand{\CppASymbol}[1]{\textcolor[rgb]{0,0,0.5}{#1}} \newcommand{\CppAWhitespace}[1]{#1} \title{c.c} % Generated by CodeToHtml TeX Generator \begin{document} \begin{ttfamily} \noindent \CppAComment{/*\SPC Convert\SPC Code\SPC To\SPC HTML\SPC */}\\ \\ \CppAKeyword{int}\CppAWhitespace{\SPC }\CppAIdentifier{foo}\CppASymbol{(}\CppAKeyword{int}\CppAWhitespace{\SPC }\CppAIdentifier{x}\CppASymbol{)}\\ \CppASymbol{\{}\\ \CppAWhitespace{\SPC }\CppAKeyword{if}\CppAWhitespace{\SPC }\CppASymbol{(}\CppAIdentifier{x}\CppAWhitespace{\SPC }\CppASymbol{==}\CppAWhitespace{\SPC }\CppANumber{1}\CppASymbol{)}\\ \CppAWhitespace{\SPC \SPC \SPC }\CppAIdentifier{printf}\CppASymbol{(}\CppAString{\QOT hello!\BS n\QOT }\CppASymbol{)}\CppASymbol{;}\\ \CppAWhitespace{\SPC }\CppAKeyword{else}\\ \CppAWhitespace{\SPC \SPC \SPC }\CppAIdentifier{printf}\CppASymbol{(}\CppAString{\QOT good\SPC bye!\BS n\QOT }\CppASymbol{)}\CppASymbol{;}\\ \CppASymbol{\}}\\ \end{ttfamily} \end{document}