You are in: Root/Articles Section. vURL: /articles/turkeycode.htm.
Introduction
TurkeyCode is the name I gave to the abbreviated page formatting markup I
designed for use with TurkeyPuncher/1.2. This page of my site will eventually end up
being the de facto guide to TurkeyCode, as well as providing some insight
into how the reference TurkeyCode -> HTML reformatter (as used by TurkeyPuncher/1.2)
works.
Table of Contents
TurkeyCode?TurkeyCodeTurkeyTagsTurkeyTag ParametersTurkeyTagsC{} TurkeyTagTurkeyTag List1{}-6{} - Page HeadingsA{} - AddressB{}, I{}, U{}, S{} - Text StylesC{} - Code BlockG{} - Base HTML PageL{} - HyperlinkP{} - ParagraphQ{} - QuoteY{} and Z{} - Indexed Position and Index Entry1.0: What Is TurkeyCode? [top]
TurkeyCode is a highly abbreviated page markup language I designed for the
purpose of quickly putting together long Web pages such as this one. We are
talking so abbreviated that it makes absolutely no sense to the average human
being. This is because TurkeyCode was never designed for legibility - it was
designed for brevity, ease of use, and simplicity of parsing.
2.0: Writing In TurkeyCode [top]
This section details the basics of writing TurkeyCode. It will explain the
anatomy of the average TurkeyCode file, and also give you a basic knowledge
of how the syntax works.
2.1: Page Anatomy [top]
Consider the following example of a page that was written in TurkeyCode:
C[
AUTHOR = John Doe I
MADE = 1258818851
TAG = TEST
TITLE = A Test Page
VIRTUAL_PATH = /TURKEYPUNCHER/
VIRTUAL_FILE = test.htm
DESCRIPTION = This is just a test page
KEYWORDS = Test, Page, It, Does, Nothing, Pointless
]C
G{
1{Hello World!}
P{Hello world!}
}
You can see that the page is effectively broken into two sections. You have a
section that's enclosed by "C[" and "]C", and then you have everything
else. The enclosed section is what I unimaginatively named the C[]C block.
Everything between the first "C[" and "]C" in the file is assumed by the
parser to contain page metadata - for example, its title and when it was
created. The C[]C block will eventually have its own section but, for now,
it's enough to realize that the first occurrence of this block in a
TurkeyCode file can pretty much contain anything at all, and is removed by
the parser during conversion of the page from TurkeyCode to HTML.
2.2: All About TurkeyTags [top]
TurkeyTags are the functional unit of TurkeyCode. Each is directly
mappable to either an existing HTML tag or a specific combination of HTML
tags. All TurkeyTags use exactly the same syntax, which is why
TurkeyCode is so easy to parse. Lets look at a TurkeyTag now from the
example file you saw previously.
P{Hello world!}
This TurkeyTag produces an HTML paragraph (<p>...</p>) in the final
HTMLified page. You can see that it consists of a single uppercase letter P,
followed by an opening curly brace, then some text. Finally, there's a closing
curly brace. The letter immediately preceding the curly brace is the tag's
identifier, and the text between the curly braces is the tag's value.
The vast majority of TurkeyTags simply wrap the value between their curly
braces with a certain piece of HTML. (For P, the HTML is <p>...</p>.)
The text between the curly braces can be straight text (such as the "Hello world!"
above), or it can be other TurkeyTags, or it can be nothing. There is an
interesting exception to this rule, and that's when there is at least one
"|" character in the text.
2.3: TurkeyTag Parameters [top]
Most TurkeyTags simply have one parameter, and that is whatever text or
other TurkeyTags are present between its curly braces. Some TurkeyTags,
however, accept more than one parameter. Strictly speaking, all
TurkeyTags accept an arbitrary number of parameters, although only a couple
currently make use of more than one. An example of a TurkeyTag that takes
more than one parameter is L{}, which can be used in two ways:
L{http://www.google.com/}
L{http://www.google.com/|Click me to Google!}
By adding a "|" character somewhere between its two curly braces, you tell
the TurkeyTag that it has more than one parameter. The parser determines
whether to either use the parameters or simply display them as straight text
by looking at the TurkeyTag's identifier.
TurkeyTags which use parameters currently are L{} (link) and Z{}
(Table of Contents definition). Others may eventually be implemented but,
for now, it's just those two.
2.4: Nesting TurkeyTags [top]
As mentioned previously, TurkeyTags can contain other TurkeyTags, just
as HTML elements can contain other HTML elements. The rules for nesting the
different types of TurkeyTags are mostly identical to HTML's own nesting
rules as a consequence of the final rendering of a TurkeyCode page being
HTML.
There is a hard limit for nesting TurkeyTags, and it's currently 255. If
you have 255 TurkeyTags in an arrangement where each one is contained by
the previous one, and you then try to nest #256 in the 255th one, your page
layout will break. But hey - who the hell would nest 255 deep anyway?
2.5: The C{} TurkeyTag [top]
I said before that all TurkeyTags basically work by the same rules. There
is one particular TurkeyTag that doesn't, and it's C{}. This TurkeyTag
acts to disable the parser's HTML reformatting functions for all text within
its curly braces. Simply put, if you wanted to include plain text or printed
HTML source in your page, you'd wrap the text in a C{}. This is how I
managed to print TurkeyCode above without the code being formatted like
this paragraph has been.
C{} is the only TurkeyTag that acts to disable the parser's HTML format
code in this way.
3.0: TurkeyTag List [top]
Now that the basic language of TurkeyCode has been defined, lets look
at the currently available tags.
1{} 2{} 3{} 4{} 5{} 6{}
A{} B{} C{} G{} I{} L{} P{} Q{} S{} U{} Y{} Z{}
b{} i{} l{} r{}
3.1: 1{}-6{} - Page Headings [top]
The tags 1{} through 6{} are your text heading levels. These map directly
to the HTML tags <h1>...</h1> through <h6>...</h6>.
1{Heading 1}
2{Heading 2}
3{Heading 3}
4{Heading 4}
5{Heading 5}
6{Heading 6}
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Levels 1 and 6 are reserved for page titles and sidebar boxes in %APP%, so have different CSS rules applied to them in TurkeyPuncher/1.2. Levels 2 through 5 share their rules, so are fine for use in pages.
3.2: A{} - Address [top]
The A{} tag maps directly onto HTML's <address>...</address> tag, and
is used in the same way - to provide address information.
A{%TURKEY% at %SERVER% Port %PORT%}
TurkeyPuncher/1.2 at m0rd3n.me.uk Port 80
3.3: B{}, I{}, U{}, S{} - Text Styles [top]
These four tags map to the four HTML quick style tags. B{} maps to
<b>...</b>, I{} maps to <i>...</i>, &c.
B{This text is bold.} b{}
I{This text is italicized.} b{}
U{This text is underlined.} b{}
S{This text is struck out.} b{}
b{}
I{Here is a multiline S{example} demo b{}
which shows B{mixU{ed} sty}les.}
This text is bold.
This text is italicized.
This text is underlined.
This text is struck out.
Here is a multilineexampledemo
which shows mixed styles.
3.4: C{} - Code Block [top]
The C{} tag was mentioned in § 2.5, so you already know what it
does, but I'd like to add a few extra notes about it.
An interesting consequence of the way C{} works is that, when you nest a
C{} within another C{}, only the outermost C{} acts to disable
the parser's HTML reformatting functions within its bounds - the inner C{}s
are inactive. This lets you can type crazy shit such as the following without
breaking anything...
C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{C{}}}}}}}}}}}}}}}}}}}}}}}}}}}
...although why you would want to do this is beyond me.
C{} actually produces two kinds of inline text, depending on whether or not
a linebreak is present in the text it encloses. If there is no linebreak, then
the HTML produced by C{} is a <code>...</code> block, which means you
can insert monospaced text segments directly into an existing paragraph. When
a linebreak is present, the more traditional <pre>...</pre> HTML is
produced, which puts the enclosed text onto a new line. You'd use the latter
for embedding sections of code in your page.
One final point about C{} - while it disables the parser's HTML reformatting
functions, it doesn't disable the parser's stack, which means the hard
nesting limit of 255 still applies to tags within C{}s.
3.5: G{} - Base HTML Page [top]
G{} wraps the text it encloses with a basic HTML page, such that the
enclosed text ends up within the page's <body>...</body> element. The
emitted page frame HTML may include a <title>...</title> element, and it
may include certain metatags, depending on the presence or absence of certain
lines in the TurkeyCode's C[]C block (refer to § 2.1). Lets
see some examples.
If a "TITLE = Blah" line is provided in the TurkeyCode's C[]C block,
the following is added into G{}'s output HTML:
<title>Blah</title>
If a "DESCRIPTION = Just a test" line is provided, the following is added
into G{}'s output HTML:
<meta name="Description" content="Just a test">
If a "KEYWORDS = 1, 2, 3, 4" line is provided, the following is added into
G{}'s output HTML:
<meta name="Keywords" content="1, 2, 3, 4">
So by adding certain lines to your page's C[]C block, you can to a degree
customize the HTML produced by G{}. Note that there is currently no way to
specify things like FavIcons or CSS stylesheets so, if you have specific
requirements for page layout, you may be better off not relying on G{} to
wrap your parsed-out TurkeyCode.
A final note about G{} - the DOCTYPE produced by it is always HTML 4.01
Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3.6: L{} - Hyperlink [top]
The L{} TurkeyTag generates a clickable hyperlink, as the following
examples demonstrate:
L{FRONTPAGE} b{}
L{99} b{}
L{http://www.google.com/|Google} b{}
L{FRONTPAGE|Click here} b{}
L{1|Front Page} b{}
L{#3.6|3.6}
Home Page
Gremlins
Google∗
Click here
Front Page
§ 3.6
There are two forma of L{} - labeled and unlabeled, with the former having
the "|" parameter separator that was mentioned in § 2.3. Also
note that L{} by default places a low asterisk ("∗") character to
the right of any link whose URL points to a non-local Web page. This is as an
aid for the reader.
Also note that the section symbol ("§") is placed to the left of the link
whose URL begins with a "#" character. URLs which begin with "#" point to
locations within the page itself, so I felt it was appropriate to make use of
the "§" symbol here. As with "§", this is an aid for the reader.
3.7: P{} - Paragraph [top]
P{} wraps its text in a standard, fairly boring HTML <p>...</p> element.
P{This is a fairly}P{redundant test}P{of paragraphs}
This is a fairly
redundant test
of paragraphs
While the nesting of P{}s is of course entirely possible, HTML tends to not
like it if this is done, so try not to nest P{}s.
3.8: Q{} - Quote [top]
Q{} wraps its text in HTML's <blockquote>...</blockquote> element. In
its standard form it functions as an indented paragraph:
P{Some text, possibly boring.}
Q{Someone once said that... nah.}
P{Some more text.}
Some text, possibly boring.
Someone once said that... nah.Some more text.
With the addition of some extra text followed by a "|" within its curly
braces, Q{} will provide an attributed quote:
P{Some text.}
Q{A Fool|No one of us is as stupid as all of us.}
P{Some more text.}
Some text.
"No one of us is as stupid as all of us."
—A FoolSome more text.
3.9: Y{} and Z{} - Indexed Position and Index Entry [top]
These two TurkeyTags are awesome, if I do say so myself. They enable the
easy insertion of a Table of Contents into your document. Lets look at an
example of using these puppies.
Z{3.9.1|2|A Heading}
Z{3.9.1.1|3|A Subheading}
Z{3.9.1.2|3|Another Subheading}
Z{3.9.2|2|Another Heading}
Z{3.9.2.1|3|A Subheading}
Z{3.9.2.2|3|Another Subheading}
Y{3.9.1}P{All about A Heading.}
Y{3.9.1.1}P{Some text about some text.}
Y{3.9.1.2}P{More text about some text about some text.}
Y{3.9.2}P{All about Another Heading.}
Y{3.9.2.1}P{Some text about some text.}
Y{3.9.2.2}P{More text about some text about some text.}
The TurkeyCode above produces the following output.
Section 1: A Heading Sec. 1.1: A Subheading Sec. 1.2: Another Subheading Section 2: Another Heading Sec. 2.1: A Subheading Sec. 2.2: Another Subheading Section 1: A Heading [top]
All about A Heading.
Sec. 1.1: A Subheading [top]
Some text about some text.
Sec. 1.2: Another Subheading [top]
More text about some text about some text.
Section 2: Another Heading [top]
All about Another Heading.
Sec. 2.1: A Subheading [top]
Some text about some text.
Sec. 2.2: Another Subheading [top]
More text about some text about some text.
![[RSS]](/cgi-bin/w3bl0g/feed.png)