Changes

Jump to navigation Jump to search
1,224 bytes added ,  22:40, 27 December 2021
m
→‎Defining your own set of colors: comment on mkii only setting
< [[Visuals]] | [[Verbatim with line breaks]] >
 
=Displayed text=
{{cmd|starttyping}},
=Inline text=
To typeset code inside the paragraph, you have the command <code>\type</code>. It can be configured with <code>\setuptype[type][...]</code>.
To have colored code, you need to use <code>\definetype[NAME][option=TEX]</code> and use it with the name you chose. Other values are: <code>mp lua xml parsed-xml nested tex context</code>.
And this is the way to have colored code: \inlineTEX{the \ConTeXt\ command},
</context>
 
 
You can also refer to a TeX command with: {{cmd|tex}}<tt>{a tex command}</tt>
<context source="yes">
\tex{a tex command}
</context>
[[Image:Verbatim-mkiv.png‎]]
 
= Verbatim with line breaks=
 
[[Verbatim with line breaks|Dedicated page]]
 
[[Line breaks marker]]
= Pretty printing =
of input and produces tex output. The details about this are discussed
at [[Custom_pretty_printer]].
 
== Improved pretty printing ==
 
Default ConTeXt comment handling can be shown in the following sample:
 
<context source="yes">
\starttext
\startbuffer[texcode]
This is text. % and this is a comment
\stopbuffer
 
\startbuffer[xmlcode]
<p>This is text.<!--and this is a comment--></p>
\stopbuffer
 
\startbuffer[luacode]
if code=="code" then --this is a comment
 
--[[
this is a
 
multiline comment
--]]
 
---[[
but this isn’t a
 
multiline comment
--]]
\stopbuffer
 
\typebuffer[texcode][option=TEX]
\typebuffer[xmlcode][option=XML]
\typebuffer[luacode][option=LUA]
\stoptext
</context>
 
If you want to improve Lua multiline comments and to color the whole comments (not only the comment marker), write <code>\usemodule[scite]</code> before <code>\starttext</code>. (I cannot show it here, since ConTeXt at the wiki seems to have a problem with that.)
= Tabbing =
% XML code will be typeset with the palette you just defined
\definepalet[XMLcolorpretty] [MYcolors] % the name is magic !- mkii only
\starttext
This results in:
:<context>
\setupbodyfont[8pt]
\definecolor[MYcolorone] [r=.8,g=.5,b=.5]
prettyfour=MYcolorfour]
% \definepalet[XMLcolorpretty] [MYcolors] % the name is magic !
\setupcolors[state=start]
\stoptext
</context>
 
== Syntax highlighting source code or configuration files ==
 
see [[Verbatim_with_LuaTeX]] with Python, Apache httpd.conf and zc.buildout config files examples.
= Colored background =
<texcode>
\setuplinenumbering[location=intexttext]
\startcode
This is the first line
after={\stopframedcode}]
\setuplinenumbering[location=intexttext]
\startcode
This is the first line
(-a- --> [[User:Andrea]])
 
 
[[Category:Basics]]
174

edits

Navigation menu