Open main menu

Changes

2,886 bytes added ,  21:31, 27 August 2005
Taco's example from the mailing list added
< [[Visuals]]| [[Verbatim with line breaks]] >
=Displayed text=
}
\stopC
</context>
 
== Defining your own set of colors ==
 
Sometimes you may be not quite satisfied with the defaut colors used in ConTeXt built-in text highlighting:
 
<texcode>
\setupcolors[state=start]
\setuptyping[option=color]
 
\starttext
\startXML
... your XML code ...
\stopXML
\stoptext
</texcode>
 
:<context>
\setupbodyfont[8pt]
\setupcolors[state=start]
\setuptyping[option=color]
 
\starttext
\startXML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XML Code Highlighting in ConTeXt</title>
 
<style type="text/css">
h1 {
text-align: center;
color: blue;
font-family: verdana,sans-serif;
}
</style>
</head>
 
<body>
<h1 style="font">XML Code Highlighting in ConTeXt</h1>
 
<!-- To be written ... -->
</body>
</html>
\stopXML
\stoptext
</context>
 
[[User:Taco|Taco]] posted this solution in the discussion on the [http://archive.contextgarden.net/message/20050825.112308.db696b94.en.html mailing list]:
 
<texcode>
\setupcolors[state=start]
\setuptyping[option=color]
 
% define the colors to fit your document style
\definecolor[MYcolorone] [r=.8,g=.5,b=.5]
\definecolor[MYcolortwo] [r=.8,g=.5,b=.2]
\definecolor[MYcolorthree][r=.8,g=.5,b=.8]
\definecolor[MYcolorfour] [r=.8,g=.2,b=.5]
 
% define a palete using these four colors
\definepalet[MYcolors]
[prettyone=MYcolorone,
prettytwo=MYcolortwo,
prettythree=MYcolorthree,
prettyfour=MYcolorfour]
 
% XML code will be typeset with the palette you just defined
\definepalet[XMLcolorpretty] [MYcolors] % the name is magic !
 
\starttext
\startXML
... your XML code ...
\stopXML
\stoptext
</texcode>
 
This results in:
 
:<context>
\setupbodyfont[8pt]
\definecolor[MYcolorone] [r=.8,g=.5,b=.5]
\definecolor[MYcolortwo] [r=.8,g=.5,b=.2]
\definecolor[MYcolorthree][r=.8,g=.5,b=.8]
\definecolor[MYcolorfour] [r=.8,g=.2,b=.5]
 
\definepalet[MYcolors]
[prettyone=MYcolorone,
prettytwo=MYcolortwo,
prettythree=MYcolorthree,
prettyfour=MYcolorfour]
 
\definepalet[XMLcolorpretty] [MYcolors] % the name is magic !
 
\setupcolors[state=start]
\setuptyping[option=color]
 
\starttext
\startXML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XML Code Highlighting in ConTeXt</title>
 
<style type="text/css">
h1 {
text-align: center;
color: blue;
font-family: verdana,sans-serif;
}
</style>
</head>
 
<body>
<h1 style="font">XML Code Highlighting in ConTeXt</h1>
 
<!-- To be written ... -->
</body>
</html>
\stopXML
\stoptext
</context>