commit
02fe867dfb
14 changed files with 6804 additions and 0 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,230 @@ |
|||||||
|
@font-face |
||||||
|
{ |
||||||
|
font-family: Lato; |
||||||
|
font-style: normal; |
||||||
|
font-weight: normal; |
||||||
|
src: url(../fonts/Lato.woff); |
||||||
|
} |
||||||
|
|
||||||
|
@font-face |
||||||
|
{ |
||||||
|
font-family: Maths; |
||||||
|
font-style: italic; |
||||||
|
font-weight: normal; |
||||||
|
src: url(../fonts/cmunti.otf); |
||||||
|
} |
||||||
|
|
||||||
|
@font-face |
||||||
|
{ |
||||||
|
font-family: Maths; |
||||||
|
font-style: normal; |
||||||
|
font-weight: normal; |
||||||
|
src: url(../fonts/cmunui.otf); |
||||||
|
} |
||||||
|
|
||||||
|
@font-face |
||||||
|
{ |
||||||
|
font-family: latin-modern-maths; |
||||||
|
font-style: normal; |
||||||
|
font-weight: normal; |
||||||
|
src: url(../fonts/latinmodern-math.otf); |
||||||
|
} |
||||||
|
|
||||||
|
/*------------------------------------------------- |
||||||
|
Body and misc styles |
||||||
|
--------------------------------------------------*/ |
||||||
|
|
||||||
|
body |
||||||
|
{ |
||||||
|
display:block; |
||||||
|
background-size: 1800px 1197px; |
||||||
|
margin-left:20px; |
||||||
|
|
||||||
|
font-family: Lato, Helvetica, sans-serif; |
||||||
|
font-size : 18px; |
||||||
|
} |
||||||
|
|
||||||
|
a |
||||||
|
{ |
||||||
|
font-weight: bold; |
||||||
|
text-decoration: none; |
||||||
|
color: #555555; |
||||||
|
} |
||||||
|
|
||||||
|
a:hover |
||||||
|
{ |
||||||
|
font-weight : bold; |
||||||
|
color: #AAAAAA; |
||||||
|
} |
||||||
|
|
||||||
|
a img |
||||||
|
{ |
||||||
|
border: none; |
||||||
|
} |
||||||
|
|
||||||
|
img |
||||||
|
{ |
||||||
|
-ms-interpolation-mode: bicubic; |
||||||
|
} |
||||||
|
|
||||||
|
/*------------------------------------------------- |
||||||
|
Maths styles |
||||||
|
--------------------------------------------------*/ |
||||||
|
|
||||||
|
sup, sub { |
||||||
|
vertical-align: baseline; |
||||||
|
position: relative; |
||||||
|
top: -0.4em; |
||||||
|
} |
||||||
|
sub { |
||||||
|
top: 0.4em; |
||||||
|
} |
||||||
|
|
||||||
|
.regular |
||||||
|
{ |
||||||
|
font-style: normal; |
||||||
|
} |
||||||
|
|
||||||
|
.maths |
||||||
|
{ |
||||||
|
font-family: Maths; |
||||||
|
font-style: italic; |
||||||
|
font-size: 18px; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .sqrt-symbol |
||||||
|
{ |
||||||
|
font-family: Maths; |
||||||
|
font-style: normal; |
||||||
|
font-size:1.37em; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .sqrt-arg |
||||||
|
{ |
||||||
|
margin-left:-0.1em; |
||||||
|
border-top: 0.1em solid black; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .fraction |
||||||
|
{ |
||||||
|
display:inline-block; |
||||||
|
vertical-align:-0.8em; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .fraction .numerator |
||||||
|
{ |
||||||
|
display:block; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .fraction .denominator |
||||||
|
{ |
||||||
|
display:block; |
||||||
|
border-top: 1px solid; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .n-sum-product |
||||||
|
{ |
||||||
|
display:inline-block; |
||||||
|
vertical-align:-1.2em; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .range-min, .maths .range-max |
||||||
|
{ |
||||||
|
display:block; |
||||||
|
font-size:0.8em; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .range-max |
||||||
|
{ |
||||||
|
line-height: 0.7em; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .n-op-symbol |
||||||
|
{ |
||||||
|
font-family: latin-modern-maths; |
||||||
|
font-size:1.8em; |
||||||
|
font-style:normal; |
||||||
|
display:block; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .op, .maths .rel, .maths .symbol |
||||||
|
{ |
||||||
|
font-family: latin-modern-maths; |
||||||
|
font-style: normal; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .vector |
||||||
|
{ |
||||||
|
font-family: latin-modern-maths; |
||||||
|
font-style: italic; |
||||||
|
} |
||||||
|
|
||||||
|
.maths .digit, .maths .delim |
||||||
|
{ |
||||||
|
font-style: normal; |
||||||
|
} |
||||||
|
|
||||||
|
/*------------------------------------------------- |
||||||
|
Code styles |
||||||
|
--------------------------------------------------*/ |
||||||
|
|
||||||
|
.code |
||||||
|
{ |
||||||
|
font-family: Courier; |
||||||
|
white-space: pre; |
||||||
|
} |
||||||
|
|
||||||
|
div.code, p.code |
||||||
|
{ |
||||||
|
background-color: #CCCCCC; |
||||||
|
margin-top: 20px; |
||||||
|
margin-bottom: 20px; |
||||||
|
padding-top: 10px; |
||||||
|
padding-bottom: 10px; |
||||||
|
padding-left: 10px; |
||||||
|
padding-right: 10px; |
||||||
|
overflow: scroll; |
||||||
|
line-height: 125%; |
||||||
|
} |
||||||
|
|
||||||
|
.code .keyword |
||||||
|
{ |
||||||
|
color:#AA00AA; |
||||||
|
font-weight: bold; |
||||||
|
} |
||||||
|
|
||||||
|
.code .type |
||||||
|
{ |
||||||
|
color:#CC5500; |
||||||
|
/* font-weight: bold;*/ |
||||||
|
} |
||||||
|
|
||||||
|
.code .preproc |
||||||
|
{ |
||||||
|
color:#0055AA; |
||||||
|
font-weight: bold; |
||||||
|
} |
||||||
|
|
||||||
|
.code .function-name |
||||||
|
{ |
||||||
|
color:#2222FF; |
||||||
|
} |
||||||
|
|
||||||
|
.code .comment, .code .comment .keyword, .code .comment .type, .comment .code .preproc |
||||||
|
{ |
||||||
|
color:#007700; |
||||||
|
font-weight: normal; |
||||||
|
} |
||||||
|
|
||||||
|
.code .string |
||||||
|
{ |
||||||
|
color: #AA0000; |
||||||
|
}; |
||||||
|
|
||||||
|
.code .syntax-error |
||||||
|
{ |
||||||
|
color:#FF0000; |
||||||
|
font-style:italic; |
||||||
|
} |
||||||
@ -0,0 +1,319 @@ |
|||||||
|
[html] |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||||||
|
<link rel="stylesheet" href="css/styles.css"/> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
[/html] |
||||||
|
= Groucho = |
||||||
|
|
||||||
|
(A clunky tool I made to mar[m]\r\Chi\r[/m] up blog posts) |
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Intro == |
||||||
|
|
||||||
|
Groucho is a little tool to generate an HTML file from a text containing simplified and non-intrusive markup codes. |
||||||
|
|
||||||
|
It was written in order to ease writing blog posts for my website. Its goal is to allow to write content along with formatting instructions, aiming at the least friction, thus avoiding the need to do a second pass manually adding html tags or using a more complex editing tool, a process that is repetitive and tedious, and makes the source text less readable. |
||||||
|
|
||||||
|
As the content I'm writting on these posts is mainly technical, Groucho is built around three main goals\s: |
||||||
|
|
||||||
|
- Easy presentation of normal content, including sections titles, paragraphs, lists, images, links. |
||||||
|
- Formatting of basic maths or physics formulas, supporting maths symbols and notations. |
||||||
|
- Syntax highlighting of C source code. |
||||||
|
|
||||||
|
Some examples : |
||||||
|
|
||||||
|
[c]*this is some text*[/c] \twill print in bold : *this is some text*. |
||||||
|
[c]/this is some text/[/c] \twill print in italics : /this is some text/. |
||||||
|
[c]_this is some text_[/c] \twill print underlined : _this is some text_. |
||||||
|
|
||||||
|
[c][m]x_+ = \frac{{-b+\sqrt{b^2-4ac}}{2a}}[/m][/c] \twill print this well-known maths formula\s: |
||||||
|
|
||||||
|
[m]x_+ = \frac{{-b+\sqrt{b^2-4ac}}{2a}}[/m] |
||||||
|
|
||||||
|
|
||||||
|
=== Download and Usage === |
||||||
|
|
||||||
|
The source code of Groucho is available under a Public domain or MIT license (choose whichever you prefer). The fonts provided for the example document are covered by their own licenses (X11 license for CMU and the GUST font license for latin-modern-maths), which you can find in the font directory. |
||||||
|
|
||||||
|
You can download the sources [url=https://www.forkingpaths.garden/download.php?id=15]HERE[/url]. Please keep in mind though that this was written as a quick side-project for my personal use, and hence is far for production quality. It is made available online only in the interest of the reader's curiosity. It may or may not be updated in the future. |
||||||
|
|
||||||
|
After downloading and extracting the archive, you should be able to compile in the source directory with\s: |
||||||
|
|
||||||
|
[code=none]cc -o groucho *.cpp[/code] |
||||||
|
\ |
||||||
|
To use it you can run : |
||||||
|
|
||||||
|
[code=none]./groucho in out[/code] |
||||||
|
\ |
||||||
|
Where in and out are your input and output files. If no files are specified groucho will get its input from the standard input and output to the standard output. You can test groucho by running it on the sample [c]doc.groucho.txt[/c] file. It should output the present quick documentation. |
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Basic principles == |
||||||
|
|
||||||
|
If not otherwise mentioned, a character in the input will produce the same character on the output. Some special characters and sequences will be interpreted as symbols and insert html entities in the html output. Some others will be interpreted as markups and insert html tags in the output stream. These tags contain [c]class[/c] attributes that are used by the browser, along with a css stylesheet, to style their content. A sample stylesheet is available with groucho, but it should be customizable at will (well, with css, you never know). |
||||||
|
|
||||||
|
The symbols, the markups and their interpretations depends on the current mode of the interpreter which can be one of the four following modes\s: |
||||||
|
|
||||||
|
- Text mode which is the default and doesn't require a markup. |
||||||
|
- HTML mode, which is used to insert raw html. |
||||||
|
- Maths mode, which is used to present simple mathematical formulas. |
||||||
|
- Code mode, which is used to present syntax-highlighted C code. |
||||||
|
|
||||||
|
By default, groucho will operate in text mode. You can switch to one of the other modes by using block tags, like [c][maths]...[/maths][/c], and all text inserted between these two tags will be interpreted in this mode. |
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== HTML mode == |
||||||
|
|
||||||
|
All text placed between the tags [c][html][/c] and [c][/html][/c] will be interpreted as HTML and will be outputed as-is. |
||||||
|
To produce the basic tags needed for an HTML document, you should insert the following block at the beginning of your input file\s: |
||||||
|
|
||||||
|
[c] |
||||||
|
[html] |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||||||
|
<link rel="stylesheet" href="css/styles.css"/> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
[/html] |
||||||
|
[/c] |
||||||
|
|
||||||
|
Where you can also specify your CSS style sheet. To close those tags you should insert the following block at the end of your input file\s: |
||||||
|
|
||||||
|
[c] |
||||||
|
[html] |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
[/html] |
||||||
|
[/c] |
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Markups common to Text and Maths mode == |
||||||
|
|
||||||
|
Text is the default mode, which is used when the source content is not contained between a pair of matching block markups. |
||||||
|
|
||||||
|
Maths mode can be used by enclosing text between the markup tags [c][maths][/c] and [c][/maths][/c], which will interpret its content as maths, and also place the output between [c]<div class="maths"></div>[/c] html tags. Alternatively, if one whishes to insert maths into the same line as normal text, the markup tags [c][m][/c] and [c][/m][/c] can be used, which will place the output between [c]<span class="maths"></span>[/c] html tags. |
||||||
|
|
||||||
|
Text and maths mode share some of their markups, so we will present them together and then present their differences. |
||||||
|
|
||||||
|
=== HTML entities === |
||||||
|
|
||||||
|
Some characters used by html tags will be replaced by html entities : |
||||||
|
|
||||||
|
- [c]<[/c] will be replaced by [c]<[/c] in maths mode, and in text mode if it is not followed by an alphabetic character, by a [c]/[/c] or by a [c]![/c]. Otherwise, it will be interpreted as the beginning of an html tag and the following text until the next matching [c]>[/c] will be output as-is. |
||||||
|
- [c]>[/c] will be replaced by [c]>[/c]. |
||||||
|
- [c]&[/c] will be replaced by [c]&[/c]. |
||||||
|
|
||||||
|
=== Escape sequences === |
||||||
|
|
||||||
|
If a character is preceded by a [c]\[/c], it will be interpreted as follows : |
||||||
|
|
||||||
|
- A [c]\n[/c] will be interpreted as an intentional line break and produce a [c]<br>[/c] tag. |
||||||
|
- An end of line preceded by [c]\[/c] will be interpreted as a source-only line break and will be suppressed in the output. |
||||||
|
- A [c]\t[/c] will output two em spaces [c] &emsp[/c]. |
||||||
|
- A [c]\s[/c] will output a non breakable space [c] [/c]. |
||||||
|
|
||||||
|
In addition to that, there's a list of letters or words that will be interpreted as a special symbol or markup when preceded by [c]\[/c]\s: |
||||||
|
|
||||||
|
- Symbols and special letters. These symbols will likely be more useful in maths sections and not all fonts support them, but they're available in text mode as well\s: |
||||||
|
- [c]\star[/c] will output a [m]\star[/m] |
||||||
|
- [c]\lowstar[/c] will output a [m]\lowstar[/m] |
||||||
|
- [c]\div[/c] will output a [m]\div[/m] |
||||||
|
- [c]\minus[/c] will output a [m]\minus[/m] |
||||||
|
- [c]\cdot[/c] will output a [m]\cdot[/m] |
||||||
|
- [c]\times[/c] will output a [m]\times[/m] |
||||||
|
- [c]\otimes[/c] will output a [m]\otimes[/m] |
||||||
|
- [c]\leq[/c] will output a [m]\leq[/m] |
||||||
|
- [c]\geq[/c] will output a [m]\geq[/m] |
||||||
|
- [c]\larr[/c] will output a [m]\larr[/m] |
||||||
|
- [c]\rarr[/c] will output a [m]\rarr[/m] |
||||||
|
- [c]\inf[/c] will output the symbol [m]\inf[/m] |
||||||
|
|
||||||
|
- Greek letters: |
||||||
|
- [c]\alpha[/c], [c]\beta[/c], [c]\gamma[/c], [c]\delta[/c], etc. : [m]\r\alpha \beta \gamma \delta\r[/m] |
||||||
|
- [c]\Alpha[/c], [c]\Beta[/c], [c]\Gamma[/c], [c]\Delta[/c], etc. : [m]\r\Alpha \Beta \Gamma \Delta\r[/m] |
||||||
|
|
||||||
|
- Font style markups, availables in both modes, change the style of text enclosed between a matching pair of them\s: |
||||||
|
- [c]\b[/c] for \bbold\b. |
||||||
|
- [c]\i[/c] for \iitalics\i. |
||||||
|
- [c]\u[/c] for \uunderlined\u |
||||||
|
- [c]\r[/c] is used to render text in roman in a section that would otherwise be in italics. It can be useful for function in maths blocks, as in [m]a = \rlog\r(b)[/m] |
||||||
|
|
||||||
|
- A single letter not matched by one of the above escape sequences will be output as is and not be interpreted as part of a markup. |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Text mode == |
||||||
|
|
||||||
|
==== Additional markups ==== |
||||||
|
|
||||||
|
In text mode, a section title can be created by enclosing text in a matching pair of [c]=[/c] sequences. The section level corresponds to the number of [c]=[/c] signs\s: |
||||||
|
|
||||||
|
[c]===== Exemple title =====[/c] in the input will produce the html [c]<h5>Exemple title</h5>[/c], resulting in\s: |
||||||
|
===== Exemple title ===== |
||||||
|
|
||||||
|
A separating line can be created by a sequence of five or more hyphens : [c]-----[/c] will output the html tag [c]<hr/>[/c] resulting in\s: |
||||||
|
----- |
||||||
|
|
||||||
|
Paragraphs can be created by simply having two line breaks in a row. |
||||||
|
|
||||||
|
The use of \\b, \\i and \\u markups can alternatively replaced by (respectively) \*, \/, and \_. |
||||||
|
|
||||||
|
The following character sequences can be used to create symbols\s: |
||||||
|
|
||||||
|
- [c]--[/c] : two hyphens in a row will create a dash\s: -- |
||||||
|
- [c]-->[/c] : one or more hyphens followed by a right angled bracket will produce a right arrow\s: --> |
||||||
|
- [c]<--[/c] : a left angled bracket followed by one or more hyphens will produce a left arrow\s: <-- |
||||||
|
- [c]"[/c] : matching pairs of double quotes will be replaced by [c]“[/c] and [c]”[/c] as in "quoted". |
||||||
|
|
||||||
|
==== Lists ==== |
||||||
|
|
||||||
|
A number of tabs followed by an hyphen, followed by a space, will be interpreted as a list item. The number of leading tabs determine the list depth when creating nested lists\s: |
||||||
|
|
||||||
|
[c]- item 1 |
||||||
|
- item 2 |
||||||
|
- sub item 2.1 |
||||||
|
- sub item 2.2 |
||||||
|
- item 3 |
||||||
|
[/c] |
||||||
|
|
||||||
|
will produce the following list : |
||||||
|
|
||||||
|
- item 1 |
||||||
|
- item 2 |
||||||
|
- sub item 2.1 |
||||||
|
- sub item 2.2 |
||||||
|
- item 3 |
||||||
|
|
||||||
|
=== External content === |
||||||
|
|
||||||
|
==== Links ==== |
||||||
|
The markup tags [c][url=][/url][/c] can be used to create a link. You specifiy the URL of your link by adding it after the [c]=[/c] sign. The text of the link goes between the two markup tags. |
||||||
|
For instance, [c][url=https://www.forkingpaths.garden]Home page[/url][/c] will create the following link : [url=https://www.forkingpaths.garden]Home page[/url] that will land you on Forking Paths's website. |
||||||
|
|
||||||
|
|
||||||
|
==== Images ==== |
||||||
|
An image can be created with the tag [c][img=][/c]. Similarly to the URL tag, you specify the URL to you image after the [c]=[/c] sign. Hence, the following tag [c][img=https://www.forkingpaths.garden/img/logo_black.png][/c] will display Forking Paths' logo\s: |
||||||
|
|
||||||
|
[img=https://www.forkingpaths.garden/img/logo_black.png] |
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Maths mode == |
||||||
|
|
||||||
|
By default, operators and capital letters will be printed in roman with a math-specific font, while lower-case letters will be printed in italics. You can always reverse that by using \\r and \\i markups. |
||||||
|
|
||||||
|
=== Default symbol interpretation === |
||||||
|
|
||||||
|
In maths mode, the following (non-escaped) sequences are recognized as symbol equivalents\s: |
||||||
|
|
||||||
|
- [c]-[/c] is equivalent to [c]\minus[/c] |
||||||
|
- [c]*[/c] is equivalent to [c]\times[/c] |
||||||
|
- [c]/[/c] is equivalent to [c]\div[/c] |
||||||
|
- [c]<=[/c] is equivalent to [c]\leq[/c] |
||||||
|
- [c]>=[/c] is equivalent to [c]\geq[/c] |
||||||
|
|
||||||
|
=== Exponents and indices === |
||||||
|
|
||||||
|
A character preceded by a [c]_[/c] will be printed as an index, as in [m]u_k[/m]. You can use a pair of curled brackets after the underscode to have a longer index, ie. this code : [c]C_{(i,j)}[/c] will produce this result : [m]C_{(i,j)}[/m]. |
||||||
|
|
||||||
|
Similarly, the character [c]^[/c] is used for exponent, as in [m]\re\r^{\thin\rj(2\pi\rf\thint+\phi)}[/m]. |
||||||
|
|
||||||
|
=== Vectors === |
||||||
|
|
||||||
|
[c]\vec[/c] : the character following this escape markup will be rendered with a vector arrow above it, as in [m]\vecv[/m]. |
||||||
|
|
||||||
|
=== Square roots === |
||||||
|
|
||||||
|
[c]\sqrt[/c] : a single character, or a sequence of characters contained in curly brackets, following this escape markup, will be printed as the arguments of a square root. |
||||||
|
|
||||||
|
[m]\sqrt{a*(1-n)^2}[/m] |
||||||
|
|
||||||
|
More precisely, this markup outputs the following HTML\s: |
||||||
|
|
||||||
|
[c]<span class="sqrt-symbol">√</span> |
||||||
|
<span class="sqrt-arg"> YourExpressionHere; </span>[/c] |
||||||
|
|
||||||
|
The square root character is rendered as an HTML entity and the trailing top line of the square root is simulated by the top border of the [c]sqrt-arg[/c] span. Because HTML\/CSS layout is such a disaster zone, it is extremely likely that the square root and the top bar won't join and you will have to adjust the stylesheet to make it happen. There's not much we can do about it, until MathML is largely supported, except resorting to TeX generated images and the like... |
||||||
|
|
||||||
|
=== Fraction === |
||||||
|
|
||||||
|
You can use the markup [c]\frac{{numerator}{denominator}}[/c] to generate a fraction. For instance, |
||||||
|
|
||||||
|
[c]y = \frac{{x^2+1}{2}}[/c] |
||||||
|
|
||||||
|
will generate the following equation : |
||||||
|
|
||||||
|
[m]y = \frac{{x^2+1}{2}}[/m] |
||||||
|
|
||||||
|
As stated above, depending on your font, you might want to adjust the [c]text-alignment[/c] property of the [c]fraction[/c] class to align the fraction line with the equal sign. |
||||||
|
|
||||||
|
=== Sums and Products === |
||||||
|
|
||||||
|
\nsum and \nproduct can be used to create indexed sums or products. You need to specify the maximum index and the minimum index enclosed in curled brackets, like this\s: |
||||||
|
|
||||||
|
[c]x = \nsum{{p}{k=1}}u_k[/c] |
||||||
|
|
||||||
|
which produces this result : |
||||||
|
|
||||||
|
[m]x = \nsum{{p}{k=1}}u_k[/m] |
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Code mode == |
||||||
|
|
||||||
|
All text placed between the tags [c][html][/c] and [c][/html][/c] will be interpreted as C code, syntax highlighted and placed between the html tags [c]<div class="code"></div>[/c]. Alternatively, if one whishes to insert code into the same line as normal text, the markup tags [c][c][/c] and <span class="code">[\/c]</span> can be used, which will place the output between the html tags [c]<span class="code"></span>[/c]. Inline code won't be syntax highlighted though. |
||||||
|
|
||||||
|
You can specify that you don't want the syntax highlighter to be run on a code block by using the opening [c][code=none][/c] mark instead of [c][code][/c] |
||||||
|
|
||||||
|
The CSS styling of code section uses [c]white-space: pre;[/c] to preserve indentation and line breaks. It also uses a monospace font by default. The syntax highlighter performs a simplified syntactical analysis of the code and encloses elements in [c]<span></span>[/c] tags, with one of the following classes\s: |
||||||
|
|
||||||
|
- [c]keyword[/c] is used for C keywords, except for built-in types. |
||||||
|
- [c]type[/c] is used for built-in or user-defined types. |
||||||
|
- [c]function-name[/c] is used to highlight functions in declarations and expressions. |
||||||
|
- [c]comment[/c] is used to highlight comments. |
||||||
|
- [c]label[/c] is used for labels and [c]goto[/c] instructions. |
||||||
|
|
||||||
|
The syntax highlighter may fail on some cases, either because the syntax is in fact incorrect or because the code uses some unrecognized dialect, or because the parser stumbles upon a macro, or simply because it lacks context. As a matter of fact, C not being completely context free, and to avoid complicating the parser for such a simple task, the parser sometimes falls back to some (hopefully) reasonable assumption on what's going on. If it was a wrong guess, it will try to recover and continue to output non highlighted code until it can resynchronize, often after the next semicolon or at the begining of the next compound statement. |
||||||
|
|
||||||
|
Here is an exemple of a code snippet : |
||||||
|
|
||||||
|
[code]for(int i=0;i<count;i++) |
||||||
|
{ |
||||||
|
// Get all my items by name in the hash table and print their value |
||||||
|
|
||||||
|
int hash = HashFunction(names[i]); |
||||||
|
my_struct* a = GetItem(hash); |
||||||
|
printf("item %s = %i %s\n", names[i], a->value, a->unit); |
||||||
|
} |
||||||
|
[/code] |
||||||
|
|
||||||
|
------------------------------------------------\ |
||||||
|
== Planned features == |
||||||
|
|
||||||
|
This is a list of features that will eventually be added along the way, as I need them and\/or find time to implement them\s: |
||||||
|
|
||||||
|
- Output some useful info to stderr on errors. |
||||||
|
- Clean-up the scanner code and reduce redundancies between modes. |
||||||
|
- Add markups to control over font size, text justification, etc. |
||||||
|
- Automatic non breakable space before colons. |
||||||
|
- Tables |
||||||
|
- Big parentheses for enclosing fractions |
||||||
|
- Exponents that should work with those big parentheses |
||||||
|
- More maths and logic symbols |
||||||
|
- TeX mode for more involved equations. It would allow to insert TeX code that would generate an image and a corresponding [c]<img>[/c] tag. |
||||||
|
- Add cast-expressions to the C parser, recognize /some/ C++ features, etc... |
||||||
|
- Other langages for syntax highlighting : eg. bash scripts, Objective-C ? |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[html] |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
[/html] |
||||||