summaryrefslogtreecommitdiff
path: root/docs/src/source-highlight/README
blob: 31d376d7f1ecf2f92fcb939883863c95971e716c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
source-highlighting EMC langues in HTML documents
=================================================

I've created GNU source-highlight language definitions for G-code and
halcmd to highlight .hal and .ngc files in asciidoc. .ini file
highlighting works out of the box. All three need a bit of trickery to
work cleanly for both html and pdf.

Highlighting is for HTML output only at this point in time.  To have
PDF's highlighted, the file
/usr/share/texmf-texlive/tex/latex/listings/lstlang1.sty needs to be
extended to deal with ngc, hal and ini formats, and put into the build
directory so dblatex can find it.

Highlighting halcmd, ini and ngc source in HTML is now integrated into
the documentation build process. tcl, python, sh etc keep working out
of the box.

NB: source-highlight's mechanisms to find .lang and .map files is
very inflexible which is why the complete source language definition
directoy (/usr/share/source-highlight) needs to be replicated under 'local',
and a new lang.map generated in there (all language definitions are
relative to this directory, and include each other).

Using ngc, hal and ini file snippets in your .txt files:
========================================================
Copy this to the top of your txt file:
----------------- snip ----------------
:ini: {basebackend@docbook:'':ini}
:hal: {basebackend@docbook:'':hal}
:ngc: {basebackend@docbook:'':ngc}

// begin a listing of ini/hal/ngc files like so:
//[source,{ini}]
//[source,{hal}]
//[source,{ngc}]
----------------- snip ----------------

Adding or changing a langauage definition (.lang) file
======================================================

New language: just drop <name>.lang into this directory. The
source-highlight configuration will be rebuilt to include this
language. <name> then can be used in [source,{named}] listings. You
might need a conditional like

:name: {basebackend@docbook:'':name}

to prevent pdflatex formatting errors.

Changing a language defintion: just edit the .lang file in this directory.

Overruling definitons in the source-highlight standard language definitions:

Copy the <language>.lang file from /usr/share/source-highlight into
this directory and edit as needed. The right things should happen on
build (including a massive initial rebuild ;-)


Building HTML examples in the this directory
============================================

To produce pdf and html samples, type 'make examples' .

This should produce {ini-demo,hal-demo,ngc-demo}.{pdf,html} files in
the current directory, with proper highlighing of HTML only. PDF files
come out properly but have no highlighting.

--------------------------------------------

I found this tool very helpful for writing GNU source-highlight .lang
definitions:

http://srchighliteide.sourceforge.net/

Michael Haberler 3/2011