# Saphirion / Development

## smarter | better | faster

make-doc-pro documentation

## make-doc-pro documentation

Author: Robert M. Münch
Date: 19-Jan-2012/13:21:17+1:00

make-doc-pro (MDP) uses an easy to learn markup language to specify various styles of text. This is quick and easy to use and it can be handled by scripts as well, making text processing a lot faster and simpler. The following sections explain the MDP markup language and show some special tips & tricks how to get the desired results.

## 1. General Information

MDP uses one or more plain text files as input and generates an output file. The format of the output file can be selected. Every output format can use its own method to specify the appearance of the MDP markup. For example, the HTML emitter uses a cascading-style-sheet (CSS) to specify the graphical appearance of the generated HTML file. The default CSS can be overwritten by an external CSS, so that you can change the look of the generated HTML files without big problems.

## 2. Source Document structure

A MDP source document can contain the following (optional) parts:

• The title line
• The boilerplate text
• The table-of-contents (TOC)
• Paragraphs of text
• Inline formatting like ~, _, etc.
• Escaped characters
• Structuring markup
• Special markup
• MDP commands like =include, etc.
• Directives for controlling the MDP engine like =debug, etc.
• End of document mark eventually followed by some text

### 2.1 Paragraphs of text

The main rule that you will need to follow is to separate all paragraphs with an empty line. Write a single paragraph either

1. using soft line wrapping in your editor (without pressing your RETURN key) as one long line of text or
2. press RETURN to include hard line breaks, if you want to keep a fixed source text layout.

Most text editors have a feature to word-wrap a text so that you can still see the complete paragraph if you go for option 1.

For example:

This is paragraph one.
This is paragraph two.

produce two paragraphs. If you fail to do this and write:

This is paragraph one.
This is paragraph two.

, your paragraphs will be merged together.

### 2.2 Title Line

The first line in the text file is used as the title line. The title line text is used both as the document title and as the HTML title of the generated document.

### 2.3 Boilerplate

If you follow the title line with a few indented lines, the lines are used as your boilerplate. The boilerplate uses a special style.

Example:

Author      : Robert M. Münch
Corrections : robert.muench@robertmuench.de

The table of contents (TOC) can be generated from section headings. It will contain a link to every section in the document. The TOC will indent and number all sections and subsections. The indentation level is the same as in the document text.

The TOC isn't included into your document by default. If you want to include the TOC, use the

=toc

directive at the place where you want the TOC to appear. The TOC is generated only for the document contents following the directive.

make-doc-pro supports four different sorts of headings. The headings are indented to give the document a structure. The structure is shown in the TOC too.

Major section headings are created by a line beginning with === that is followed by the text of the heading. Here is an example:

===This is a Major Section

Minor section headings are created by a line that begins with --- that is followed by the text of the heading. Here is an example:

---This is a Subsection

A simple method to remember that === is for sections and --- is for subsections is to note that === has more to it than ---. There are two more subsection levels you can use. The first is +++ and the second one is ... followed by the text of the heading. Different subsection levels use different text sizes and indentation levels to indicate the level of the subsection.

A summary of the available heading styles:

 === Major Section heading --- Subsection +++ Subsubsection ... Subsubsubsection

### 2.6 Inline Formatting

You can change text decoration inline. You can use bold text, italic text or underline text. The formatting is quite easy:

*bold*
~italic~
_underline_

The text you are going to decorate must have spaces in front of the starting- and following the ending inline decoration characters like:

This is a sentence containing an _underlined text_ part.

### 2.7 Escaped characters

If you want to insert a specific character to the output (especially if it has a special meaning for the MDP engine) you can precede it by the ^ character. For example,

^|

inserts the | character into the output even in case the unescaped | character would be understood as a table cell delimiter.

The ^ character itself has a special meaning for the MDP engine. That is why you need to write a pair

^^

of these into the input file to insert a single ^ character to the output.

Comments begin with a semicolon (;) and continue through the end of the paragraph. It is OK to have whitespaces between the semicolon and the first character of the text.

Here is an example comment:

;This is a comment. It continues until
a blank line is encountered. It is handy
for commenting out paragraphs.

### 2.9 End of Text Formatting

A line starting with ### will mark the end of text formatting. This is handy if you want to include some comments or notes to yourself at the end of the file, but you don't want them formatted into the document.

For example:

###

would end text formatting.

You can also embed a REBOL script to automatically format your text (as described above). To do so, follow the ### with a REBOL header. Here is an example:

###
[REBOL [] do/args %make-doc-pro.r %make-doc-pro.txt]

The ### marks the end of the formatting so the script portion will not be shown. The brackets around the script allow you to follow the line with notes or comments that are not evaluated. Otherwise the brackets are not required.

## 3. Structuring Markup

MDP supports structuring a document either by using bullet points or numbered lists.

### 3.1 Bullet Points

A handy way of creating a simple list of bullet points is done by beginning paragraphs with a * character. Remember to keep the text flush left, otherwise it will become a code example. The example:

*This is the first of a few bullet points.
*This is the second bullet point.
*This is another bullet point. It contains a lot more
text, so it will show how bullets are wrapped on in
the output.

will produce:

• This is the first of a few bullet points.
• This is the second bullet point.
• This is another bullet point. It contains a lot more text, so it will show how bullets are wrapped on in the output.

#### 3.1.1 Bullet Points Level

make-doc-pro supports three different levels of bullet points. To use them just use several bullet characters. Here is an example:

*First level
**Second level
***Third level
**Second level
***Third level

Will produce:

• First level
• Second level
• Third level
• Second level
• Third level

### 3.2 Numbered Points

Similar to bullet points, you can create numbered points. Start each numbered line with a # that is followed by the text of the line.

For example:

#This is the first numbered line.
#This is the second numbered line.
#This is another numbered point. It contains a lot more
text, so it will show how lines are wrapped on in
the output.

produces:

1. This is the first numbered line.
2. This is the second numbered line.
3. This is another numbered point. It contains a lot more text, so it will show how lines are wrapped on in the output.

## 4. Special Markup

This section describes some special markup rules you can use.

### 4.1 Code Examples

To create a code example, all you have to do is indent the text. Code examples are printed in a fixed-space bold font. For example:

foreach line paragraph [
print [
length? line
mold line
]
]

Notice that the example maintains its proper indentation. In REBOL indentation defaults to 4 spaces.

### 4.2 Definitions

A definition line starts with a leading : followed by the expression being defined. The <space>-<space> sequence starts the definition. The words in the expression being defined can contain - characters too as long as there is no single - character surrounded by spaces.

For example, the definitions:

:word - This is the first definition.
:example-with- - This defines a word containing the - character.
:two words - This defines an expression consisting of two words.

would appear as:

 word This is the first definition. example-with- This defines a word containing the - character. two words This defines an expression consisting of two words.

Simple types of URL links can be created with the =url command. This command provides a file or site reference, followed by the hyperlink text. For example, to provide a relative link:

=url work.html Where we work

=url http://www.rebol.com The Main REBOL Site

This will appear as follows

The Main REBOL Site.

You can also provide email links with:

=url mailto:robert.muench@robertmuench.de Send me an email.

Send me an email.

Sometimes it's necessary to use URL with spaces, especially if you want to link to a file on an intranet server. Use the following form then:

=url "//mycomputer/mydirectory with spaces/myfile.txt" URL with spaces

URL with spaces

### 4.4 Indented Sections

To increase the indentation level of a section of text you will need to use the \in mark. Use the /in mark to decrease the indentation level again. You can use several \in and /in for indentation control. Indentation level is increased/decreased by 1cm a time.

For example:

\in
This is a section of text.  It can contain most
of the other special formats. For example, here
are some bullet points:
*bullet 1
*bullet 2
/in

produces:

This is a section of indented text. It can contain most of the other special formats. For example, here are some bullet points:

• bullet 1
• bullet 2

### 4.5 Note Boxes

Special notes can be shown in a callout box. A note begins with \note and ends with /note. The \note line can contain the box heading that will be shown at the top of the box.

The example:

\note Example Note Box
This is a special note. It can contain most
of the other special formats. For example, here
are some numbered points:
#number one
#number two
/note

produces:

Example Note Box

This is a special note. It can contain most of the other special formats. For example, here are a few numbered points:

1. number one
2. number two

### 4.6 Tables

make-doc-pro adds support for tables. It's only a basic thing yet but more to come. You create tables like this:

\table
cell1 | cell2 ||
cell1 | cell2
/table

produces:

 cell1 cell2 cell1 cell2

### 4.7 Images

Images are placed in a document with the image tag.

The line:

=image center mdp-logo.png

Would include the image with the filename ms-word.gif from the same directory as the input text file centered in the document:

To left justify the image:

=image left mdp-logo.png

You can use right and float as well.

=image right mdp-logo.png

=image float mdp-logo.png

This is a text with an embedded image

to include text styling graphics.

### 4.8 Layouts

VID layouts can be automatically generated as images. The images will be stored in a graphics folder in the local directory.

To create a layout, follow an example with a =view command. The command does not need to immediately follow the example. It will always print the last example that appeared. This gives you space to explain the results before showing them.

Here is an example layout:

backdrop %nyc.jpg 40.40.150
banner "Example Layout"
text bold "Just an example...."
button "Ok"

This will normally appear as:

make-doc-pro

But, it can also be shown left justified as:

left make-doc-pro
Note:

In order to see the above examples, you must build a local copy of make-doc-pro.html. To do so, just run make-doc-pro and select makedocpro.txt from the file requestor.

The first is done with a:

=view

The second is done with a:

=view left

A graphics dir will be created within the working dir, containing the *.png generated file. It can be given a base file name with a line like:

=view example

All other =view commands that follow will use the same base name. If no base name is given, the word "image" will be used.

## 5. MDP controlling markup

This section describes the commands you can use to control MDP's translation process.

### 5.1 Language Support

I added support for different languages to make-doc-pro. At the moment only the specifier for the contents and copyright section can be customized. By default make-doc-pro uses the english language option.

Language support isn't hardcoded into make-doc-pro. Instead you specify a filename, which is then loaded and processed. From this point on the new definitions are used. Thus a good place to use this option is after the title/boilerplate block and before the TOC tag. In this case the TOC will have the correct description.

To specify another language use the following code:

=language DE

This will read the file DE.r and execute the definitions inside. Here you see sample contents of such a file:

contents: "Inhalt"
copyright: [
<HR>
<P id="end">
<BR>
"Formatiert mit Make-Doc-Pro Version:"
" am "
now/date
" um "
now/time
</P>
]

### 5.2 Include Files

While processing a file you can insert the contents of another file with the =include command. For example:

=include preface.txt

would include the file preface.txt.

The inserted file can use all of the same commands and body text as accepted by make-doc-pro. Any number of =include commands can be used, and included files can also contain =include commands.

Include files should be placed into the same directory as the sourcetext file.

### 5.3 Alternate Output Files

A single input file can create multiple output files. The new output file is specified with the =file command. For example:

=file directory.html

would cause all text and commands that follow it to be stored in the directory.html file. When using several output files, the TOC is kept in sync. This makes it possible to click in the TOC and branch to another file.

More than one =file command can be used. For example:

=file first.html

This is the text of the first file

=file second.html

This is the text of the second file.

=file third.html

This is the text of the third file.