Difference between revisions of "Help:Context"
(update page with new info) |
|||
Line 1: | Line 1: | ||
The <code><nowiki><context> ... </context></nowiki></code> tags process their ConTeXt contents on the fly and include the result on the page as an image. Whitespace is cropped out. The following attributes may be set: | The <code><nowiki><context> ... </context></nowiki></code> tags process their ConTeXt contents on the fly and include the result on the page as an image. Whitespace is cropped out. The following attributes may be set: | ||
− | * <code>source=yes</code> displays the source before the output. | + | * <code>source="yes"</code> displays the source before the output. |
* <code>text="some text"</code> places 'some text' between the source and the output. | * <code>text="some text"</code> places 'some text' between the source and the output. | ||
− | * <code>mode= | + | * <code>mode="mkii"</code> forces [[Mark II]] instead of the default Mark IV. But please don't use [[Mark II]] unless absolutely necessary. |
+ | * <code>force="yes"</code> forces regeneration of the PNG image each time the page is loaded. This is expensive, so please only use it on special occasions (like in the example below where we are showing the {{cmd|contextversionnumber}}. | ||
Quotation marks around attribute strings are only required if the attribute contains non-alphabetic characters. | Quotation marks around attribute strings are only required if the attribute contains non-alphabetic characters. | ||
− | + | The extension wraps your code with a bit of extra ConTeXt code to get a compilable file. There are two different | |
− | + | cases, depending on whether your code contains {{cmd|starttext}} ... {{cmd|stoptext}} or not. | |
+ | With a starttext/stoptext block, the wrapping uses: | ||
+ | |||
+ | <texcode> | ||
+ | \setuppapersize[A5][A5] | ||
+ | \setupbodyfont[8pt] | ||
+ | \setupcolors[state=start] | ||
+ | .. your input here .. | ||
+ | </texcode> | ||
+ | |||
+ | and without starttext/stoptext, the extension uses: | ||
+ | |||
+ | <texcode> | ||
+ | \setuppapersize[A5][A5] | ||
+ | \setupbodyfont[8pt] | ||
+ | \setupcolors[state=start] | ||
+ | \starttext | ||
+ | \startTEXpage | ||
+ | .. your input here .. | ||
+ | \stopTEXpage | ||
+ | \stoptext | ||
+ | </texcode> | ||
+ | |||
== Examples == | == Examples == | ||
Line 56: | Line 79: | ||
|} | |} | ||
− | === mode= | + | === mode=mkiv and mode=mkii === |
− | By default, the wiki compiles examples using | + | By default, the wiki compiles examples using MkIV. You can specify that you want to use MkIV by adding the option <tt>mode=mkii</tt> to the tag. Because MkII examples are visually indistinguishable from MkIV examples, it is good practice to start MkII examples with a comment <code>% mode=mkii</code>. |
{| class=wikitable | {| class=wikitable | ||
Line 64: | Line 87: | ||
|- style="vertical-align: top" | |- style="vertical-align: top" | ||
| <xmlcode> | | <xmlcode> | ||
− | <context source=yes> | + | <context source=yes force=yes> |
− | |||
Version: \contextversionnumber | Version: \contextversionnumber | ||
</context> | </context> | ||
</xmlcode> | </xmlcode> | ||
− | | <context source=yes> | + | | <context source=yes force=yes> |
− | Version: \contextversionnumber | + | Version: \contextversionnumber |
</context> | </context> | ||
|- style="vertical-align: top" | |- style="vertical-align: top" | ||
| <xmlcode> | | <xmlcode> | ||
− | <context mode= | + | <context mode=mkii source=yes force=yes> |
− | |||
Version: \contextversionnumber | Version: \contextversionnumber | ||
</context> | </context> | ||
</xmlcode> | </xmlcode> | ||
− | |<context mode= | + | |<context mode=mkii source=yes force=yes> |
− | % mode= | + | % mode=mkii |
Version is: \contextversionnumber | Version is: \contextversionnumber | ||
</context> | </context> |
Revision as of 13:52, 28 May 2020
The <context> ... </context>
tags process their ConTeXt contents on the fly and include the result on the page as an image. Whitespace is cropped out. The following attributes may be set:
source="yes"
displays the source before the output.text="some text"
places 'some text' between the source and the output.mode="mkii"
forces Mark II instead of the default Mark IV. But please don't use Mark II unless absolutely necessary.force="yes"
forces regeneration of the PNG image each time the page is loaded. This is expensive, so please only use it on special occasions (like in the example below where we are showing the \contextversionnumber.
Quotation marks around attribute strings are only required if the attribute contains non-alphabetic characters.
The extension wraps your code with a bit of extra ConTeXt code to get a compilable file. There are two different cases, depending on whether your code contains \starttext ... \stoptext or not.
With a starttext/stoptext block, the wrapping uses:
\setuppapersize[A5][A5] \setupbodyfont[8pt] \setupcolors[state=start] .. your input here ..
and without starttext/stoptext, the extension uses:
\setuppapersize[A5][A5] \setupbodyfont[8pt] \setupcolors[state=start] \starttext \startTEXpage .. your input here .. \stopTEXpage \stoptext
Contents
Examples
Plain example
Wiki markup | Wiki display |
---|---|
<context> \setupcolors [state=start] \framed [background=color, backgroundcolor=gray, offset=0.5cm ]{hello world!} </context> |
source=yes
Wiki markup | Wiki display |
---|---|
<context source="yes" text="produces"> \setupcolors [state=start] \framed [background=color, backgroundcolor=gray, offset=0,5cm ]{hello world!} </context> |
\setupcolors [state=start] \framed [background=color, backgroundcolor=gray, offset=0.5cm ]{hello world!} produces
|
mode=mkiv and mode=mkii
By default, the wiki compiles examples using MkIV. You can specify that you want to use MkIV by adding the option mode=mkii to the tag. Because MkII examples are visually indistinguishable from MkIV examples, it is good practice to start MkII examples with a comment % mode=mkii
.
Wiki markup | Wiki display |
---|---|
<context source=yes force=yes> Version: \contextversionnumber </context> |
Version: \contextversionnumber
internal error: copy error /var/www/contextgarden.net/wiki/htdocs/wikiteximage/d955ce230f938712a3b4f76209da8f0b.png
|
<context mode=mkii source=yes force=yes> Version: \contextversionnumber </context> |
% mode=mkii Version is: \contextversionnumberinternal error: copy error Zg3Jk2/cropped.pdf |
Displaying multiple pages
\setuppapersize[A10, landscape][A8, landscape] \setuppaper[nx=2, ny=2] % arrange pages 2 by 2 (must come before \setuparranging[XY]) \setuparranging[XY] % arrange pages n by n (across, then down) \setuppagenumbering[location=footer] % page numbers are always useful \showframe[edge] % Draw line around each page. Prevents overzealous cropping one \page[yes] two \page[yes] three \page[yes] four
|
/context>