Difference between revisions of "Advanced textile editing"

From Spiffy Stores Knowledge Base

Line 685: Line 685:
 
[http://www.spiffystores.com link to]!</p>
 
[http://www.spiffystores.com link to]!</p>
 
|}
 
|}
 
<tr><td class='example1' valign='top'><pre>I am crazy about "Hobix":hobix<br />and "it's":hobix "all":hobix I ever<br />"link to":hobix!<br /><br />[hobix]http://hobix.com<br /></pre></td><td>&rarr;</td><td class='example2'><p>&lt;p&gt;I am crazy about &lt;a href="http://hobix.com"&gt;Hobix&lt;/a&gt;<br />and &lt;a href="http://hobix.com"&gt;it&amp;#8217; s&lt;/a&gt; &lt;a href="http://hobix.com"&gt;all&lt;/a&gt; I ever<br />&lt;a href="http://hobix.com"&gt;link to&lt;/a&gt;!&lt;/p&gt;</p></td></tr><tr><td colspan='2'></td><td class='example3'><p>I am crazy about <a href="http://hobix.com">Hobix</a>
 
 
and <a href="http://hobix.com">it&#8217;s</a> <a href="http://hobix.com">all</a> I ever
 
<a href="http://hobix.com">link to</a>!</p></td></tr>
 
  
 
=== Embedded Images ===
 
=== Embedded Images ===

Revision as of 12:39, 17 February 2011

Textile is a simple text markup. Simple symbols mark a word's emphasis. Blocks of text can be easily tagged as headers, quotes, or lists. A Textile document can then be converted to HTML (Hypertext Markup Language) for viewing on the web.

Texile makes it easy to mark up text for a web page without needing to have any knowledge about HTML.

You can try out Textile on the Textile home page.

Reading the Examples

In each section below, examples are provided to help clearly illustrate how to use the markup. In each example, the Textile example is followed by the raw HTML that is generated. This is followed by an example of how the output will appear in a browser.

Textile example Converted to HTML
    Browser view

Writing in Textile

Paragraphs in Textile

Textile looks for paragraphs in your text. Paragraphs are separated by one blank line. Every paragraph is translated as an HTML paragraph.

A single paragraph.

Followed by another.
<p>A single paragraph.</p>

<p>Followed by another.</p>
   

A single paragraph.

Followed by another.

Using HTML in Textile

You can certainly use HTML tags inside your Textile documents. HTML will only be escaped if it's found in a pre or code block.


I am <b>very</b> serious.

<pre>
I am <b>very</b> serious.
</pre>
<p>I am <b>very</b> serious.</p>

<pre>
I am &lt;b&gt;very&lt;/b&gt; serious.
</pre>
   

I am very serious.

I am <b>very</b> serious.

Line Breaks

Line breaks are converted to HTML breaks.

I spoke.
And none replied.
<p>I spoke.<br />And none replied.</p>
   

I spoke.
And none replied.

Entities

Single-quotes and double-quotes around words or phrases are converted to curly quotations, which are much easier on the eye.

"Observe!" <p>&#8220;Observe!&#8221;</p>
   

“Observe!”

Double hyphens are replaced with an em-dash.

Observe -- very nice! <p>Observe &#8212; very nice!</p>
   

Observe — very nice!

Single hyphens are replaced with en-dashes.

Observe - tiny and brief. <p>Observe &#8211; tiny and brief.</p>
   

Observe – tiny and brief.

Triplets of periods become an ellipsis.

Observe... <p>Observe&#8230;</p>
   

Observe…

The letter ‘x’ becomes a dimension sign when used alone.

Observe: 2x2. <p>Observe: 2&#215;2.</p>
   

Observe: 2×2.

Conversion of trademark and copyright symbols.

a(TM), b(R), c(C). <p>a&#8482;, b&#174;, c&#169;.</p>
   

a™, b®, c©.

Quick Block Modifiers

Blocks of text are treated as paragraphs by default. However, modifers can be prefixed to the beginning of a block to change its treatment.

Headers

To make an entire paragraph into a Header, place "hn" at its beginning, where n is a number from 1-6.

h1. Header 1 <h1>Header 1</h1>
    Header 1
h2. Header 2 <h2>Header 2</h2>
    Header 2
h3. Header 3 <h3>Header 3</h3>
    Header 3

Block Quotes

To make an entire paragraph into a block quotation, place "bq." before it.

An old text

bq. A block quotation.

Any old text
<p>An old text</p>
<blockquote>
<p>A block quotation.</p>
</blockquote>
<p>Any old text</p>
   

An old text

A block quotation.

Any old text

Footnotes

Numeric references within text to footnotes appear between square brackets.

This is covered elsewhere[1]. <p>This is covered elsewhere<sup><a href="#fn1">1</a></sup>.</p>
   

This is covered elsewhere1.

To create the footnote that corresponds to its reference within the text, begin a new paragraph with fn and the footnote's number, followed by a dot and a space.

fn1. Down here, in fact. <p id="fn1"><sup>1</sup> Down here, in fact.</p>
   

1 Down here, in fact.

Quick Phrase Modifiers

Structural Emphasis

Emphasis to text is added by surrounding a phrase with underscores. In HTML, this often appears as italics.

I _believe_ every word. <p>I <em>believe</em> every word.</p>
   

I believe every word.

Strength can be give to text by surrounding with asterisks. In HTML, this strength appears as bold.

And then? She *fell*! <p>And then? She <strong>fell</strong>!</p>
   

And then? She fell!

Both italics and bold can be forced by doubling the underscores or asterisks.

I __know__.
I **really** __know__.
<p>I <i>know</i>.<br />
I <b>really</b> <i>know</i>.</p>
   

I know.
I really know.

Use double question marks to indicate citation. The title of a book, for instance,

??Cat's Cradle?? by Vonnegut <p><cite>Cat's Cradle</cite> by Vonnegut</p>
   

Cat's Cradle by Vonnegut

Code phrases can be surrounded by at-symbols.

Convert with @r.to_html@ <p>Convert with <code>r.to_html</code></p>
   

Convert with r.to_html

To indicate a passage which has been deleted, surround the passage with hyphens.

I'm -sure- not sure. <p>I'm <del>sure</del> not sure.</p>
   

I'm sure not sure.

Pluses around a passage indicate its insertion.

You are a +pleasant+ child. <p>You are a <ins>pleasant</ins> child.</p>
   

You are a pleasant child.

To superscript a phrase, surround with carets.

a^2^ + b^2^ = c^2^ <p>a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup></p>
   

a2 + b2 = c2

To subscript, surround with tildes.

log~2~ x <p>log<sub>2</sub> x</p>
   

log2 x

HTML-Specific

Lastly, if you find yourself needing to customize the style of a passage, use percent symbols to translate the passage as an HTML span.

I'm %unaware% of most soft drinks. <p>I'm <span>unaware</span> of most soft drinks.</p>
   

I'm unaware of most soft drinks.

This way, you can apply style settings, as described in the next section to arbitrary phrases.

I'm %{color:red}unaware% of most soft drinks. <p>I'm <span style="color:red;">unaware</span> of most soft drinks.</p>
   

I'm unaware of most soft drinks.

Attributes

Tailoring Textile to suit your needs is quite easy. Attributes allow you to provide Cascading Style Sheets (CSS) information about any phrase.

Block Attributes

A block can be tagged with a CSS class by enclosing the class name in parentheses and placing it just before the period which marks the block.

p(example1). An example <p class="example1">An example</p>
   

An example

An element ID can be given by prefixing the ID with a hash symbol (#) and using it in place of the class.

p(#big-red). Red here <p id="big-red">Red here</p>
   

Red here

Class and ID can be combined by placing the class first.

p(example1#big-red2). Red here <p class="example1" id="big-red2">Red here</p>
   

Red here

Style settings can be provided directly by surrounding them in curly braces.

p{color:blue;margin:30px}. Spacey blue <p style="color:blue; margin:30px;">Spacey blue</p>
   

Spacey blue

Language designations can be given between square brackets.

p[fr]. rouge <p lang="fr">rouge</p>
   

rouge

Phrase Attributes

All block attributes can be applied to phrases as well by placing them just inside the opening modifier.

I seriously *{color:red}blushed* when I _(big)sprouted_ that corn stalk from my %[es]cabeza%. <p>I seriously <strong style="color:red;">blushed</strong> when I <em class="big">sprouted</em> that corn stalk from my <span lang="es">cabeza</span>.</p>
   

I seriously blushed when I sprouted that corn stalk from my cabeza.

Block Alignments

Text inside blocks can be aligned in four basic ways.

p<. align left <p style="text-align:left;">align left</p>
   

align left

p>. align right <p style="text-align:right;">align right</p>
   

align right

p=. centered <p style="text-align:center;">centered</p>
   

centered

p<>. justified <p style="text-align:justify;">justified</p>
   

justified

Indentation can also be specified by provide a single left paren for every 1em to the left. A single right paren for every 1em to the right.

p(. left ident 1em <p style="padding-left:1em;">left ident 1em</p>
   

left ident 1em

p((. left ident 2em <p style="padding-left:2em;">left ident 2em</p>
   

left ident 2em

p))). right ident 3em <p style="padding-right:3em;">right ident 3em</p>
   

right ident 3em

Combining Alignments

Identation may be coupled with alignment.

h2()>. Bingo. <h2 style="padding-left:1em; padding-right:1em; text-align:right;">Bingo.</h2>
   
Bingo.

And, furthermore, coupled with language settings and CSS styles.

h3()>[no]{color:red}. Bingo <h3 style="color:red; padding-left:1em; padding-right:1em; text-align:right;" lang="no">Bingo</h3>
   
Bingo

HTML in Textile

Textile is designed for making simple markup quick and easy. For more complex formatting, you are encouraged to break out into HTML.

For example, long code blocks belong between <pre>…</pre> and <code>…</code> tags. Please also indent your code inside the tags to be sure that all Textile processors out there will ignore the contents.

<pre>
<code>
  a.gsub!( /</, '' )
</code>
</pre>
<pre>
<code>
  a.gsub!( /&lt;/, '' )
</code>
</pre>
    a.gsub!( /</, '' )

You may also choose to surround sections with <div> tags to separate your document into sections. Instiki uses this technique to float a sidebar to the right.

<div style="float:right;padding:5px;">

h3. Sidebar

"Spiffy":http://www.spiffystores.com/
"Ruby":http://ruby-lang.org/

</div>

The main text of the page goes here and will stay to the left of the sidebar.
<div style="float:right;padding:5px;">
<h3>Sidebar</h3>
<p>
<a href="http://www.spiffystores.com/">Spiffy</a><br />
<a href="http://ruby-lang.org/">Ruby</a>
</p>
</div>

<p>The main text of the page goes here and will stay to the left of the sidebar.</p>
   
Sidebar

Spiffy
Ruby

The main text of the page goes here and will stay to the left of the sidebar.

Lists

Numeric Lists

To make a numbered list, place each item in its own paragraph, preceded by a hash character ("#").

# A first item
# A second item
# A third
<ol>
<li>A first item</li>
<li>A second item</li>
<li>A third</li>
</ol>
   
  1. A first item
  2. A second item
  3. A third

These lists may be nested by increasing the number of hash characters ("#") that precede the child entries.

# Fuel could be:
## Coal
## Gasoline
## Electricity
# Humans need only:
## Water
## Protein
<ol>
<li>Fuel could be:
<ol>
<li>Coal</li>
<li>Gasoline</li>
<li>Electricity</li>
</ol>
</li>
<li>Humans need only:
<ol>
<li>Water</li>
<li>Protein</li>
</ol>
</li>
</ol>
   
  1. Fuel could be:
    1. Coal
    2. Gasoline
    3. Electricity
  2. Humans need only:
    1. Water
    2. Protein

Bulleted Lists

Bulleted lists use an asterisk character ("*") instead of the hash character ("#").

* A first item
* A second item
* A third
<ul>
<li>A first item</li>
<li>A second item</li>
<li>A third</li>
</ul>
   
  • A first item
  • A second item
  • A third

These lists may also be nested in a similar manner.

* Fuel could be:
** Coal
** Gasoline
** Electricity
* Humans need only:
** Water
** Protein
<ul>
<li>Fuel could be:
<ul>
<li>Coal</li>
<li>Gasoline</li>
<li>Electricity</li>
</ul>
</li>
<li>Humans need only:
<ul>
<li>Water</li>
<li>Protein</li>
</ul>
</li>
</ul>
   
  • Fuel could be:
    • Coal
    • Gasoline
    • Electricity
  • Humans need only:
    • Water
    • Protein

External References

Hypertext Links

Basic links are comprised of a phrase which is linked to a URL. Place the descriptive phrase in quotation marks, and follow it immediately by a colon and the URL.

I searched "Google":http://google.com. <p>I searched <a href="http://google.com">Google</a>.</p>
    I searched Google.

Note, the link won't include any trailing punctuation.

Link Aliases

If you are using the same link several times in your document, or you'd just like to be a tad more organized, you can use a link alias. Place the URL anywhere in your document, beginning with its alias in square brackets. Then, use the alias in place of the URL, using the link format above.

I am crazy about "Spiffy Stores":spiffy
and "it's":spiffy "all":spiffy I ever
"link to":spiffy!

[spiffy]http://www.spiffystores.com
<p>I am crazy about <a href="http://www.spiffystores.com">Spiffy Stores</a>
and <a href="http://www.spiffystores.com">it's</a> <a href="http://www.spiffystores.com">all</a> I ever
<a href="http://www.spiffystores.com">link to</a>!</p>
   

I am crazy about Spiffy Stores and it's all I ever link to!

Embedded Images

You can embed an image in your Textile document by surrounding its URL with exclamation marks.

!http://hobix.com/sample.jpg!

<p><img src="sample.jpg" alt="" /></p>

<img src="sample.jpg" alt="" />

URLs may be relative.

A title for the image can also be provided in parens, just before the closing exclamation.

!openwindow1.gif(Bunny.)!

<p><img src="openwindow1.gif" title="Bunny." alt="Bunny." /></p>

<img src="openwindow1.gif" title="Bunny." alt="Bunny." />

The title also acts as alt text should the image not be found.

Links can be attached to images with a colon.

!openwindow1.gif!:http://hobix.com/

<p><a href="http://hobix.com/"><img src="openwindow1.gif" alt="" /></a></p>

<a href="http://hobix.com/"><img src="openwindow1.gif" alt="" /></a>

Image Alignments

Alignments can be applied as well to images.

!>obake.gif!<br /><br />And others sat all round the small<br />machine and paid it to sing to them.

<p style="float:right"><img src="obake.gif" alt="" /></p>

<p>And others sat all round the small
machine and paid it to sing to them.</p>

<img src="obake.gif" alt="" />

And others sat all round the small machine and paid it to sing to them.

Acronyms

Definitions for acronyms can be provided by following an acronym with its definition in parens.

We use CSS(Cascading Style Sheets).

<p>We use <acronym title="Cascading Style Sheets">CSS</acronym>.</p>

We use <acronym title="Cascading Style Sheets">CSS</acronym>.

<a name='tables'>7.</a>
Tables

Simple tables can be built by separating fields with pipe characters

| name | age | sex |<br />| joan | 24 | f |<br />| archie | 29 | m |<br />| bella | 45 | f |

<table>
<tr>
<td> name </td>
<td> age </td>
<td> sex </td>
</tr>
<tr>
<td> joan </td>
<td> 24 </td>
<td> f </td>
</tr>
<tr>
<td> archie </td>
<td> 29 </td>
<td> m </td>
</tr>
<tr>
<td> bella </td>
<td> 45 </td>
<td> f </td>
</tr>
</table>

name age sex
joan 24 f
archie 29 m
bella 45 f

Specify header cells by marking them with an underscore and period.

|_. name |_. age |_. sex |<br />| joan | 24 | f |<br />| archie | 29 | m |<br />| bella | 45 | f |

<table>
<tr>
<th>name </th>
<th>age </th>
<th>sex </th>
</tr>
<tr>
<td> joan </td>
<td> 24 </td>
<td> f </td>
</tr>
<tr>
<td> archie </td>
<td> 29 </td>
<td> m </td>
</tr>
<tr>
<td> bella </td>
<td> 45 </td>
<td> f </td>
</tr>
</table>

name age sex
joan 24 f
archie 29 m
bella 45 f

Cell Attributes

The period used above marks the end of a cell’s attributes. Other attributes can be applied as well.

|_. attribute list |<br />|<. align left |<br />|>. align right|<br />|=. center |<br />|<>. justify |<br />|^. valign top |<br />|~. bottom |

<table>
<tr>
<th>attribute list </th>
</tr>
<tr>
<td style="text-align:left;">align left </td>
</tr>
<tr>
<td style="text-align:right;">align right</td>
</tr>
<tr>
<td style="text-align:center;">center </td>
</tr>
<tr>
<td style="text-align:justify;">justify </td>
</tr>
<tr>
<td style="vertical-align:top;">valign top </td>
</tr>
<tr>
<td style="vertical-align:bottom;">bottom </td>
</tr>
</table>

attribute list
align left
align right
center
justify
valign top
bottom

You can also specify colspans with a backslash, followed by the cell width.

|\2. spans two cols |<br />| col 1 | col 2 |

<table>
<tr>
<td colspan="2">spans two cols </td>
</tr>
<tr>
<td> col 1 </td>
<td> col 2 </td>
</tr>
</table>

spans two cols
col 1 col 2

Rowspan is specified by a forward slash, followed by the row height.

|/3. spans 3 rows | a |<br />| b |<br />| c |

<table>
<tr>
<td rowspan="3">spans 3 rows </td>
<td> a </td>
</tr>
<tr>
<td> b </td>
</tr>
<tr>
<td> c </td>
</tr>
</table>

spans 3 rows a
b
c

All block attributes can be applied to table cells as well.

|{background:#ddd}. Grey cell|

<table>
<tr>
<td style="background:#ddd;">Grey cell</td>
</tr>
</table>

Grey cell

Table and Row Attributes

Table-wide attributes can be applied before the first row of the table. On its own line, followed by a period.

table{border:1px solid black}.<br />|This|is|a|row|<br />|This|is|a|row|

<table style="border:1px solid black;">
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>row</td>
</tr>
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>row</td>
</tr>
</table>

This is a row
This is a row

Attributes can be applied to a single row by supplying the attribute before the row starts, using a table modifier and following it by a period.

|This|is|a|row|<br />{background:#ddd}. |This|is|grey|row|

<table>
<tr>
<td>This</td>
<td>is</td>
<td>a</td>
<td>row</td>
</tr>
<tr style="background:#ddd;">
<td>This</td>
<td>is</td>
<td>grey</td>
<td>row</td>
</tr>
</table>

This is a row
This is grey row