hasciidoc/asciidoc.md

121 lines
3.7 KiB
Markdown
Raw Permalink Normal View History

2014-02-24 08:00:46 +00:00
---
title: AsciiDoc Parsing
...
# Document Structure
A *document* is a series of *block elements*.
The first element is optionally a *document header*.
The next element is optionally a *preamble*.
* Document
* Header (optional)
Must be separated from the remainder of the document by one or more
blank lines and cannot contain blank lines.
Can include comments.
Can include attribute entries, typically *doctype*, *lang*, *encoding*,
*icons*, *data-uri*, *toc*, *numbered*
Command-line attributes override header attributes.
* Title
* Info (optional)
* AuthorInfo
Format: firstname[ [middlename ]lastname][ <email>]
Multi-word names should be separated by underscores,
e.g. van_Gogh.
If the format isn't matched, the entire line becomes a
FirstName.
* FirstName
* OtherNames (optional)
* MiddleName (optional)
* LastName
* EmailAddress (optional)
* RevisionInfo (optional)
* Either
* RevisionNumber (optional)
* RevisionDate
* RevisionRemark (optional)
* Or
* RCS/CVS/SVN $Id$ marker.
The *revnumber*, *revdata*, and *author* attributes are
extracted and set and displayed in the header.
The header author line may be omitted.
* Preamble (optional)
* SectionBody
* Section (0 or more)
Up to 4 section levels (1-4) in addition to the document title (level 0)
Has attributes *level* and *sectnum* implcitly defined
* Title
* SectionBody (optional)
* One of (repeated 1 or more times)
* Either
* BlockTitle (optional)
Format: .<title>
* Block
* Or
* BlockMacro
* Section (0 or more)
* Block
Floating titles probably belong in here somewhere.
* One of
* Paragraph
* DelimitedBlock
* List
* One of
* BulletedList
* ListItem (1 or more)
* NumberedList
* ListItem (1 or more)
* CalloutList
* ListItem (1 or more)
* LabeledList
* ListEntry (1 or more)
* ListLabel
* ListTerm (1 or more)
* ListItem
* ItemText
* One of (repeated 0 or more times)
* List
* ListParagraph
A paragraph with *listelement* option set
* ListContinuation
* Table
* Or (these can appear almost anywhere)
* BlockId
Applies to the following *Title*, *Paragraph*, *List*,
*DelimitedBlock*, *Table*, or *BlockMacro*
Format: [[<id>]]
* AttributeEntry
* AttributeList
Applies to the following *Block*
Most blocks support *id*, *role*, and *reftext* attributes
Format: [<attr>(, <attr>)*]
Notes:
* Block elements are separated by line boundaries
* *Header*, *Title*, *Paragraph*, and *ItemText* cannot contain blank lines.
```.haskell
data Document = Doc
{ _docAttrs :: Attributes
, _header :: Maybe DocHeader
, _preamble :: Maybe SectionBody
, _sections :: Seq Section
}
data Section = Sec
{ _secAttrs :: Attributes
, _secTitle :: Text
, _secBody :: Maybe SectionBody
, _secChildren :: Seq Section
}
type SectionBody = Seq Block
```