# A Textile Reference
Sections: Writing in Textile | Quick Block Modifiers | Quick Phrase Modifiers | Attributes | Lists | External References | Tables
Textile is a simple text markup. Simple symbols mark words’ emphasis. Blocks of text can be easily tagged as headers, quotes, or lists. A Textile document can then be converted to HTML for viewing on the web.
You can try Textile out on the Textile home page. Textile is also available as RedCloth for Ruby or PyTextile for Python.
Also refer to the Quick Reference for this guide. Note: This file was originally authored by _why, this version has been modified by codesponge(billychamp) to fix broken links. The examples that use github.com used to point to hobix.com The broken links in the image examples have not (yet) been replaced.
#### Reading the Examples
In each section below, examples are provided to clearly illustrate. In each example, the Textile example is followed by the raw HTML it is translated into, followed by how the HTML appears in the browser.
    Textile example
| → | Converted to HTML
| Browser-view
1. Writing 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. And none replied.</p>
| I spoke. And none replied.
Line breaks can be disabled in RedCloth by turning on `fold_lines`.
#### Entities
Single- and double-quotes around words or phrases are converted to curly quotations, 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: 2 x 2.
| → | <p>Observe: 2&#215; 2.</p>
| Observe: 2×2.
Conversion of trademark and copyright symbols.
    one(TM), two(R), three(C).
| → | <p>one&#8482;, two&#174;, three&#169;.</p>
| one™, two®, three©.
2. Quick Block Modifiers
Blocks of text default to being treated as paragraphs. But modifers can be affixed 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.
3. 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>. 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&#8217; 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 hypens.
    I'm -sure- not sure.
| → | <p>I&#8217; 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>
| a 2 + b 2 = c 2
To subscript, surround with tildes.
    log ~2~ x
| → | <p>log <sub>2</sub> x</p>
| log 2 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&#8217; 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&#8217; m <span style="color:red;">unaware</span> of most soft drinks.</p>
| I’m unaware of most soft drinks.
4. Attributes
Tailoring Textile to suit your needs is quite easy. Attributes allow you to provide CSS information about any phrase.
#### Block Attributes
A block can be tagged with a CSS class by circling the class 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 pound 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 angel 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 quickening the simple markups. For more complex formatting, you are encouraged to break out into HTML.
For example, long code blocks belong between `pre` and `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;">

    h3. Sidebar

    "GitHub":http://github.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;"> <h3>Sidebar</h3> <p><a href="http://hobix.com/">GitHub</a> <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 GitHub Ruby The main text of the page goes here and will stay to the left of the sidebar.
5. Lists
#### Numeric Lists
To make a numbered list, place each item in its own paragraph, preceded by ”#”.
    # A first item
    # A second item
    # A third
| → | <ol> <li>A first item</li> <li>A second item</li> <li>A third</li> </ol>
| A first item A second item A third
These lists may be nested by increasing the number of pound symbols preceding 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>
| Fuel could be: Coal Gasoline Electricity Humans need only: Water Protein
#### Bulleted Lists
Bulleted lists use an asterisk in place of the pound.
    * 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 be nested in like 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
6. External References
#### Hypertext Links
Basic links are comprised of a phrase which is linked to a URL. Place the descriptive phrase in quotation marks. 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.
Notice, 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 "GitHub":github
    and "it's":github "all":github I ever
    "link to":github!

    [github]http://github.com
| → | <p>I am crazy about <a href="http://github.com">GitHub</a> and <a href="http://github.com">it&#8217; s</a> <a href="http://github.com">all</a> I ever <a href="http://github.com">link to</a>!</p>
| I am crazy about GitHub 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="http://hobix.com/sample.jpg" alt="" /></p>
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>
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>
#### Image Alignments
Alignments can be applied as well to images.
    !>obake.gif!

    And others sat all round the small
    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>
| 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 CSS.
7. Tables
Simple tables can be built by separating fields with pipe characters
    | name | age | sex |
    | joan | 24 | f |
    | archie | 29 | m |
    | 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 |
    | joan | 24 | f |
    | archie | 29 | m |
    | 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 |
    |<. align left |
    |>. align right|
    |=. center |
    |<>. justify |
    |^. valign top |
    |~. 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 |
    | 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 |
    | b |
    | 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}.
    |This|is|a|row|
    |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|
    {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