Dario Teixeira wrote:
Hi,
I am using the Source-highlight library to perform a fairly straightforward
syntax highlighting task: given a string containing the source-code, and
another with the language definition, I want to return a string with the
highlighted version of source-code expressed in a custom "foobar" outlang.
In pseudo-C++, something like the code below: (forget optimisations for now)
string highlight (string src, string langdef)
{
istringstream in (src);
ostringstream out;
SourceHighlight hiliter ("foobar.outlang");
hiliter.highlight (in, out, langdef);
return out.str ();
}
In rough terms, this works. There is however one big problem: any use of
escaping directives within the "src" (like "\n") is being processed, instead
of being written verbatim into the output string. Is there any way to turn
off this behaviour?
Thanks in advance!
Best regards,
Dario Teixeira
Dear Dario
I'm not sure I understand what the final result should be, but in the
outlang file you can specify some regular expression based translations.
For instance, in latex.outlang you have
translations
"_" "$\\_$"
"{" "\\{"
"}" "\\}"
"<" "\\textless{}"
">" "\\textgreater{}"
"&" "\\&"
"\\" "\\textbackslash{}"
"^" "\\textasciicircum{}"
"~" "\\textasciitilde{}"
"\n" " \\\\\n"
" " "\\ "
"\t" "\\ \\ \\ \\ \\ \\ \\ \\ "
"%" "\\%"
"#" "\\#"
"$" "\\$"
"|" "$|$"
"---" "-\\/-\\/-"
"--" "-\\/-"
"\"" "\"{}" # avoids problems with some inputenc
end
in html_notfixed.outlang
translations
"\n" "<br>\n"
" " " "
'^ ' " " # a space at the beginning of a line
"\t" " "
end
so probably you should be able to achieve your goal in your
foobar.outlang file.
Please, let me know whether this solves this issue
cheers
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
_______________________________________________
Help-source-highlight mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-source-highlight