Relicense to GPLv3
[muse-el.git] / examples / QuickStart.muse
blob050f6fd2489a1890c0087a6a84ce4a69ef7ababf
1 #author John Wiegley and Michael Olson
2 #title The Emacs Muse
4 Emacs Muse is an authoring and publishing environment for Emacs.  It
5 simplifies the process of writings documents and publishing them to
6 various output formats.
8 Muse consists of two main parts: an enhanced text-mode for authoring
9 documents and navigating within Muse projects, and a set of publishing
10 styles for generating different kinds of output.
12 <contents>
14 * About this document
16 This document provides an example of Muse markup and also functions as
17 a quickstart for Muse.
19 To see what it looks like when published, type =make examples=.  You
20 will then get an Info document, an HTML document, and a PDF document
21 (provided you have an implementation of LaTeX installed with the
22 necessary fonts).
24 * Getting Started
26 To use Muse, add the directory containing its files to your
27 =load-path= variable, in your =.emacs= file.  Then, load in the
28 authoring mode, and the styles you wish to publish to.  For example:
30 <example>
31 (add-to-list 'load-path "<path to Muse>")
33 (require 'muse-mode)     ; load authoring mode
35 (require 'muse-html)     ; load publishing styles I use
36 (require 'muse-latex)
37 (require 'muse-texinfo)
38 (require 'muse-docbook)
40 (require 'muse-project)  ; publish files in projects
41 </example>
43 Once loaded, the command =M-x muse-publish-this-file= will publish an
44 input document to any available style.  If you enable =muse-mode=
45 within a buffer, by typing =M-x muse-mode=, this command will be bound
46 to =C-c C-t=.
48 * Creating a Muse project
50 Often you will want to publish all the files within a directory to a
51 particular set of output styles automatically.  To support, Muse
52 allows for the creations of "projects".  Here is a sample project, to
53 be defined in your =.emacs= file:
55 <example>
56 (setq muse-project-alist
57       '(("website" ("~/Pages" :default "index")
58          (:base "html" :path "~/public_html")
59          (:base "pdf" :path "~/public_html/pdf"))))
60 </example>
62 The above defines a project named "website", whose files are located
63 in the directory =~/Pages=.  The default page to visit is =index=.
64 When this project is published, each page will be output as HTML to
65 the directory =~/public_html=, and as PDF to the directory
66 =~/public_html/pdf=.  Within any project page, you may create a link
67 to other pages using the syntax =[[pagename]]=.
69 * Markup rules
71 A Muse document uses special, contextual markup rules to determine how
72 to format the output result.  For example, if a paragraph is indented,
73 Muse assumes it should be quoted.
75 There are not too many markup rules, and all of them strive to be as
76 simple as possible so that you can focus on document creation, rather
77 than formatting.
79 ** Paragraphs
81 Separate paragraphs in Muse must be separate by a blank line.
83 For example, the input text used for this section is:
85 <example>
86 Separate paragraphs in Muse must be separate by a blank line.
88 For example, the input text used for this section is:
89 </example>
91 ** Centered paragraphs and quotations
93 A line that begins with six or more columns of whitespace (either tabs
94 or spaces) indicates a centered paragraph.
96                            This is centered
98   But if a line begins with whitespace, though less than six columns,
99   it indicates a quoted paragraph.
101 ** Headings
103 A heading becomes a chapter or section in printed output -- depending
104 on the style.  To indicate a heading, start a new paragraph with one
105 to three asterices, followed by a space and the heading title.  Then
106 begin another paragraph to enter the text for that section.
108 <example>
109 * First level
111 ** Second level
113 *** Third level
114 </example>
116 ** Horizontal rules
118 Four or more dashes indicate a horizontal rule.  Be sure to put blank
119 lines around it, or it will be considered part of the proceeding or
120 following paragraph!
122 ----
124 The separator above was produced by typing:
126 <example>
127 ----
128 </example>
130 ** Emphasizing text
132 To emphasize text, surround it with certain specially recognized
133 characters:
135 <example>
136 *emphasis*
137 **strong emphasis**
138 ***very strong emphasis***
139 _underlined_
140 =verbatim and monospace=
141 </example>
143 The above list renders as:
145 <verse>
146 *emphasis*
147 **strong emphasis**
148 ***very strong emphasis***
149 _underlined_
150 =verbatim and monospace=
151 </verse>
153 ** Adding footnotes
155 A footnote reference is simply a number in square
156 brackets<verbatim>[1]</verbatim>.[1] To define the footnote, place
157 this definition at the bottom of your file.  =footnote-mode= can be
158 used to greatly facilitate the creation of these kinds of footnotes.
160 <example>
161  Footnotes:
162  [1]  Footnotes are defined by the same number in brackets
163       occurring at the beginning of a line.  Use footnote-mode's
164       C-c ! a command, to very easily insert footnotes while
165       typing.  Use C-x C-x to return to the point of insertion.
166 </example>
168 ** Verse
170 Poetry requires that whitespace be preserved, but without resorting to
171 monospace.  To indicate this, use the following markup, reminiscent of
172 e-mail quotations:
174 <example>
175 > A line of Emacs verse;
176 >   forgive its being so terse.
177 </example>
179 The above is rendered as:
181 > A line of Emacs verse;
182 >   forgive its being so terse.
184 You can also use the =<literal><verse></literal>= tag, if you prefer:
186 <example>
187 <verse>
188 A line of Emacs verse;
189   forgive its being so terse.
190 </verse>
191 </example>
193 ** Literal paragraphs
195 The =<literal><example></literal>= tag is used for examples, where
196 whitespace should be preserved, the text rendered in monospace, and
197 any characters special to the output style escaped.
199 There is also the =<literal><literal></literal>= tag, which causes a
200 marked block to be entirely left alone.  This can be used for
201 inserting a hand-coded HTML blocks into HTML output, for example.
203 If you want some text to only be inserted when publishing to a
204 particular format, use the =style= attribute for the
205 =<literal><literal></literal>= tag.  Some examples follow.
207 <example>
208 You are reading the
209 <literal style="html">HTML</literal>
210 <literal style="pdf">PDF</literal>
211 <literal style="info">Info</literal>
212 version of this document.
213 </example>
215 Produces:
217 You are reading the
218 <literal style="html">HTML</literal>
219 <literal style="pdf">PDF</literal>
220 <literal style="info">Info</literal>
221 version of this document.
223 <example>
224 <literal style="latex">
225 LaTeX was used in the publishing of this document.
226 </literal>
227 </example>
229 Produces:
231 <literal style="latex">
232 LaTeX was used in the publishing of this document.
233 </literal>
235 ** Lists
237 Lists are given using special characters at the beginning of a line.
238 Whitespace must occur before bullets or numbered items, to distinguish
239 from the possibility of those characters occurring in a real sentence.
241 The supported kinds of lists are:
243 <example>
244   - bullet item one
245   - bullet item two
247   1. Enumerated item one
248   2. Enumerated item two
250 Term1 :: A definition one
252 Term2 :: A definition two
253 </example>
255 These are rendered as a bullet list:
257   - bullet item one
258   - bullet item two
260 An enumerated list:
262   1. Enum item one
263   2. Enum item two
265 And a definition list:
267 Term1 ::
268   This is a first definition
269   And it has two lines;
270   no, make that three.
272 Term2 ::
273   This is a second definition
275 Lists may be nested inside of one another.  The level of nesting is
276 determined by the amount of leading whitespace.
278 <example>
279  - Level 1, bullet item one
280    1. Level 2, enum item one
281    2. Level 2, enum item two
282  - Level 1, bullet item two
283 </example>
285 This is rendered as:
287  - Level 1, bullet item one
288    1. Level 2, enum item one
289    2. Level 2, enum item two
290  - Level 1, bullet item two
292 ** Tables
294 Simple tables are supported.  The syntax is:
296 <example>
297   Double bars  || Separate header fields
299   Single bars   | Separate body fields
300   Here are more | body fields
302   Triple bars ||| Separate footer fields
303 </example>
305 The above is rendered as:
307 Double bars  || Separate header fields
309 Single bars   | Separate body fields
310 Here are more | body fields
312 Triple bars ||| Separate footer fields
314 <comment>
315 Double bars  || Separate header fields
317 Single bars   | Separate body fields
318 Here are more | body fields
320 Triple bars ||| Separate footer fields
321 </comment>
323 It is also possible to make tables that look like:
325 <example>
326 | Single bars   | Separate body fields |
327 | Here are more | body fields          |
328 </example>
330 This publishes as:
332 | Single bars   | Separate body fields |
333 | Here are more | body fields          |
335 If you are familiar with Org-mode style tables, simple variants (no
336 column groups or autogenerated formulas) will publish fine.  Also,
337 table.el style tables will be published, provided that the output
338 format is something that table.el supports.
340 ** Anchors and tagged links
342 #example If you begin a line with "#anchor" -- where "anchor" can be
343 any word that doesn't contain whitespace -- it defines an anchor at
344 that point into the document.  This point can be referenced using
345 "page#anchor" as the target in a Muse link (see below).
347 Click [[#example][here]] to go back to the previous paragraph.
349 ** URLs and E-mail addresses
351 A URL or e-mail address encountered in the input text is published as
352 a hyperlink if the output style supports it.  For example, the latest
353 Muse source can be downloaded at http://download.gna.org/muse-el and
354 mail may be sent to mwolson@gnu.org.
356 ** Images
358 If a URL has an extension of a known image format, it will be inlined
359 if possible.  To create a link to an image, rather than inlining it,
360 put the text "URL:" immediately in front of the link.
362 This is an inlined image example:
364 <example>
365 Made with [[muse-made-with.png]] Emacs Muse.
366 </example>
368 This publishes as:
370 Made with [[muse-made-with.png]] Emacs Muse.
372 Here is an example of a captioned image:
374 <example>
375 [[emacs-muse.png][Muse, the publishing choice of (a subset of) Great Thinkers]]
376 </example>
378 This publishes as:
380 [[emacs-muse.png][Emacs Muse, the publishing choice of (a subset of) Great Thinkers]]
382 The following will be published as a link only.
384 <example>
385 The Muse logo: [[URL:http://mwolson.org/static/logos/emacs-muse.png]].
386 </example>
388 The Muse logo: [[URL:http://mwolson.org/static/logos/emacs-muse.png]].
390 ** Links
392 A hyperlink can reference a URL, or another page within a Muse
393 project.  In addition, descriptive text can be specified, which should
394 be displayed rather than the link text in output styles that supports
395 link descriptions.  The syntax is:
397 <example>
398 [[link target][link description]]
399 [[link target without description]]
400 </example>
402 Thus, the text:
404 <example>
405 Muse can be downloaded [[http://download.gna.org/muse-el/][here]], or at
406 [[http://download.gna.org/muse-el/]].
407 </example>
409 Publishes as:
411 Muse can be downloaded [[http://download.gna.org/muse-el/][here]], or at
412 [[http://download.gna.org/muse-el/]].
414 ** Source code
416 If you have htmlize.el version 1.34 or later installed, you can
417 publish colorized HTML for source code in any major mode that Emacs
418 supports by using the =<literal><src></literal>= tag.  If not publishing
419 to HTML, the text between the tags will be treated like an
420 =<literal><example></literal>= tag.
422 Here is some example C code.  Muse takes the =lang= element and appends
423 ="-mode"= to it in order to determine which major mode to use when
424 colorizing the code.
426 <example>
427 <src lang="c">
428 #include <stdlib.h>
430 char *unused;
432 int main (int argc, char *argv[])
434     puts("Hello, world!\n");
436 </src>
437 </example>
439 Here is the colorized output.  This may look different if you have
440 customized some faces.  Also, it may look different depending on
441 whether you are publishing from Emacs on the console, or Emacs on X --
442 what you see when viewing (in this case) a C file is what you get.
444 <src lang="c">
445 #include <stdlib.h>
447 char *unused;
449 int main (int argc, char *argv[])
451     puts("Hello, world!\n");
453 </src>
455 ** Embedded Lisp, Perl, Ruby, Python, or Shell
457 Arbitrary kinds of markup can be achieved using the
458 =<literal><lisp></literal>= tag, which is the only Muse tag supported
459 in a style's header and footer text.  With the
460 =<literal><lisp></literal>= tag, you may generated whatever output
461 text you wish.  The inserted output will get marked up, if the
462 =<literal><lisp></literal>= tag appears within the main text of the
463 document.
465 <example>
466 <lisp>(concat "This form gets " "inserted")</lisp>
467 </example>
469 The above renders as: <lisp>(concat "This form gets " "inserted")</lisp>.
471 It is also possible to treat the output as if it were surrounded by
472 the =<literal><example></literal>=, =<literal><src></literal>=, or
473 =<literal><verse></literal>= tags, by specifying ="example"=, ="src"=, or
474 ="verse"= as the =markup= attribute of the tag.
476 For example:
478 <example>
479 <lisp markup="example">
480 (concat "Insert" " me")
481 </lisp>
482 </example>
484 The output is:
486 <lisp markup="example">
487 (concat "Insert" " me")
488 </lisp>
490 This =markup= attribute can also be passed to the
491 =<literal><perl></literal>=, =<literal><ruby></literal>=,
492 =<literal><python></literal>=, and =<literal><command></literal>= tags,
493 which interpret Perl, Ruby, Python, and Shell code, respectively.
495 * Publishing styles
497 One of the principle features of Muse is the ability to publish a
498 simple input text to a variety of different output styles.  Muse also
499 makes it easy to create new styles, or derive from an existing style.
501 ** Deriving from an existing style
503 To create a new style from an existing one, use =muse-derive-style=:
505 <example>
506 (muse-derive-style DERIVED-NAME BASE-NAME STYLE-PARAMETERS)
507 </example>
509 The derived name is a string defining the new style, such as
510 "my-html".  The base name must identify an existing style, such as
511 "html" -- if you have loaded =muse-html=.  The style parameters are the
512 same as those used to create a style, except that they override
513 whatever definitions exist in the base style.
515 Most often, this will come in handy for using a custom header, footer,
516 and/or stylesheet for a project.  Here is one such example.
518 <example>
519 (setq my-different-style-sheet
520       (concat "<link rel=\"stylesheet\" type=\"text/css\""
521               " charset=\"utf-8\" media=\"all\""
522               " href=\"/different.css\" />"))
524 (muse-derive-style "my-xhtml" "xhtml"
525                    :header "~/.emacs.d/muse/different-header.html"
526                    :footer "~/.emacs.d/muse/different-footer.html"
527                    :style-sheet my-different-style-sheet)
528 </example>
530 Many parameters support being partially overridden.  As an example:
531 with =:functions=, if a markup function is not found in the derived
532 style's function list, the base style's function list will be queried.
534 If a parameter takes the name of a function, then returning non-nil
535 from that function causes no further processing to be done.  If the
536 function returns nil, any other functions in the base style will be
537 called.
539 ** Creating a new style
541 To create a new style, use =muse-define-style=:
543 <example>
544 (muse-define-style NAME STYLE-PARAMETERS)
545 </example>
547 If you want to create a new style, it is best to examine the source
548 code for other styles first, to get an idea of what needs to be done.
549 Each output format should have its own file, containing all styles
550 based on it.  For example. the =latex=, =latex-slides=, and =pdf= styles are
551 all contained in =muse-latex.el=.
553 If you are willing to sign copyright papers for the Free Software
554 Foundation (we will help you with this step), the Muse authors may be
555 interested in including your work in future versions of Muse.
557 * License
559 This QuickStart document may be redistributed and/or modified under
560 the terms of the GNU General Public License as published by the Free
561 Software Foundation; either version 3, or (at your option) any later
562 version.
565 Footnotes: 
566 [1] This is a footnote.
568 [2] Another footnote, this one unreferenced.