// // PerlPoint tutorial. An intro for users. // // This is the frame file. It might depend on included docs. // // Author: (c) J. Stenzel 2003-2005. // // document data $docAuthor=Jochen Stenzel $docAuthorMail=perl@jochen-stenzel.de $docDate=2005-04-30 $docVersion=0.02 // macro definitions +OREF:\REF{name="__n__" type=linked occasion=1}<__body__> +BCX:\B<\C<\X<__body__>>> +IX:\I<\X<__body__>> +CX:\C<\X<__body__>> +UB:\U<\B<__body__>> +CPAN:\C<\X<__body__>> +RED:\F{color=red}<__body__> +BLUE:\F{color=blue}<__body__> +GREEN:\F{color=green}<__body__> +ILLT:\LOCALTOC{type=linked depth=2} +FNR:\SUP<\F{size="-2"}<\REF{type=linked name="__n__"}>> +FN:\F{size="-2"}<\SEQ{type=footnotes name="__n__"}: __body__> +HR:\EMBED{lang=html}
\END_EMBED =Start .\I // TOC \ILLT // intro ==What is PerlPoint? When it comes to documentation, there are two base approaches: the WYSIWYG concept that allows to compose things an interactive way, and the description language concept which "describes" documents in a special format, which finally is transformed into the visual result. Think of office applications as examples for the first approach, and HTML, XML or LaTeX for the second one. For one or the other reason, people prefer one or the other approach. It depends on their needs (and preferences) which solution suits them most. PerlPoint is a "descriptive" toolset. To build a document, it is described in a text file in the PerlPoint format. As with all descriptive approaches, using a text format makes those sources very portable. But PerlPoint is portable in a second way, too: as it is written in pure Perl, the toolset runs on a wide range of platforms. Whereever Perl runs, PerlPoint runs as well. So well, but what will this toolset produce? Will the \I be portable, too? - This depends on what you produce, because there is no special PerlPoint output. Instead, PerlPoint can produce \I formats. So it is \I as well. Produce HTML if you want to publish via Web or make presentations. Produce PDF if you want to make brochures or handouts or presentations in this format, or if you are in need for a document that cannot be modified. Produce LaTeX if you want to print in superb quality, or to integrate your docs in some sort of LaTeX postprocessing. Or choose SDF as your intermediate format, to go for POD, PostScript or manpages. Or join the XML community. All these target formats are at hand right now. And if none of them suits your needs, you can write new converters. Besides portability and flexibility, PerlPoint is easy to start with. Basically, docs are very much like simple text documents, divided into paragraphs. We will see this in a minute. Nobody needs to be a programming expert to begin, people can start quickly. On the other hand, \I you are in need of more sophisticated solutions, PerlPoint will support you as well and offer tags, macros, embedded programming, filters, conditions and more. ==Basics of the document format ~ Format basics Writing a PerlPoint document is simple. Here is a first document: =Documents are simple text files Writing PerlPoint can be as easy as writing notes to a file. Just open a text editor and start. Of course there are more sophisticated features. But like Perl, PerlPoint allows you to do easy things with ease. These are two text paragraphs and a headline. The rules for text are simple: * Text paragraphs start at the left margin. * Optionally, they can be started with a \IX (with \C 0.40 and better). \RED<.>This is a text as well. * They can be wrapped in any way. * A line of whitespaces (or the end of the document) completes the paragraph. As for the headline, there is a special thing: the prefix \C<=> at the beginning. This prefix marks this paragraph as a headline. There can be more than one \C<=> characters: their number shows the headline level. Here is the outline of a document, in traditional form. 1. Formats 1.1. Input Formats 2.2. Output Formats 2.2.1. HTML 2.2.2. XML 3. Conclusion In PerlPoint, it would be written this way: =Formats ==Input Formats ==Output Formats ===HTML ===XML =Conclusion The \C<=> characters are just placeholders, the final numbering will be made when the document will be processed. Like paragraphs, headlines can be wrapped, and likewise they end with a line of whitespaces. =Usually headlines are short, but in case you need a very long headline, it is no problem to write it down in PerlPoint, wrapped to as many lines as you like to keep it readable \I All basic elements of a PerlPoint document are paragraphs. And as with the headline, \I. If you want to start quickly, this is almost all you need to know about the format. Here is the one thing that is missed: backslashes (\C<\X<\\>>) are special characters. To write a literal backslash, just write two of them: \C<\\\\>. Backslashes ("\\\\") are special. Now, if you are in a hurry, you can directly proceed with the \OREF{n="Produce a document"}. But if you have a few minutes more, the following sections of this chapter will teach you how to write lists, examples, tables and comments, and this isn't more difficult than what we had till. \ILLT ===Bullet lists Those lists are often used in presentations, or just to make a point. Here is how we write them in PerlPoint: Paragraphs seen that far: * texts, * headlines. And now we go for bullet lists. You note the prefix: \C<*>. Start a paragraph with that, and it becomes a list point. The list starts and ends instantly, there is no need to mark its beginning or end. Besides the prefix, the usual rules apply: wrap as you want, and complete with an empty line. * It does not matter how a list point is wrapped. ===Numbered lists Want to see numbers instead of bullets in your list? Well, that's easy, just use another prefix: the number placeholder (and paragraph prefix) is a \C<#>. Three paragraph parts: \RED<#> Prefix. \RED<#> Body. \RED<#> Empty line. As with bullet lists before, lists are instantly opened and closed. PerlPoint finds points of the same type and automatically combines them to a list. And there's yet another list type. ===Definition lists This list type is borrowed from HTML. A definition describes an item, and therefore consists of two parts: the item and the description. As an item can be more than just one word, we need more than a simple prefix here: we need to mark where the description part starts. A colon seems appropriate - that's what one would usually use in a written text: Computer\RED<:> a system to automate stupid jobs. In PerlPoint, it's the same, and to make things consistent the colon is used to \I a definition point as well: \RED<:>Computer\RED<:> a system to atomate stupid jobs. Isn't that easy? As with the other list types, the point can be wrapped in any way. Additionally, there can be any number of whitespaces between the item and the explanation part. This allows to structure the source for readability: :Writer: a creative person producing books. :Illustrator: an artist visualizing stories. ===Examples Sometimes things need to be illustrated by examples, which in PerlPoint are paragraphs starting with an indentation. So, for example: Business people could present statistical data in an example, emphasizing their point. Programmers like to show source code in examples. The number of whitespaces used as a paragraph prefix is up to you. It does not matter for the example to be recognized. All whitespace used \I an example block is preserved, which means it will be reproduced in the result, including the original wrapping. Examples are paragraphs as usual - they end with a line of whitespace. Nevertheless, as such lines might be part of the example text, PerlPoint automatically combines subsequent example paragraphs. As a result, \I. All intermediate newlines will be made part of the generated example block. In other words: everything between the start of an example block and the next non-example paragraph will become part of this example, including whitespace lines. A piece of code, including whitespace lines: # use an intermediate scope { # scopy my $value; # calculate $value=20*$start; # print result print "Result: $value.\n"; } Now we will analyze this code ... But you \I to separate subsequent examples? Ok, in this case, use the special "-" paragraph: The first example. With its second part. \RED<-> The second examples first line. Note: there's a second paragraph type for examples, in order to handle special cases. If you aren't a programmer, chances are that you will not need this second type. ===Tables At this point I think you are familiar with the paragraph concept, so it will not surprise you that even tables are paragraphs. And quickly you'll ask: what's the special prefix? Well, the special prefix for table paragraphs is a line describing the string that is used to delimit columns. This is done by starting with \C<@>, followed by the delimiter string. The most intuitive delimiter string is "|". So here's an example of a table using this delimiter: @\RED<|> given name \RED<|> name \RED<|> playing Peter \RED<|> Paul \RED<|> Guitar Paul \RED<|> Newby Mary Ann \RED<|> Shuttle \RED<|> Chess That's intuitive and suggested for all cases without \C<|> in the field entries, but one could use another (and longer) string as well: @\RED given name \RED name \RED playing Peter \RED Paul \RED Guitar Paul \RED Newby Mary Ann \RED Shuttle \RED Chess Please have a look at the whitespaces in the table fields - in order to make the source as readable as possible, you can add as many as you want. OK. Another point is that the rows in this example have different numbers of columns. Will this cause a problem? No - PerlPoint will add columns automatically, according to the headline row. This is the very first row in the table. // comments ===Comments Well, we are almost done with the basics. The final paragraph type in this collection is a \I. Comments are annotations made to your \I, they will not show up in the target format. The special prefix of comment paragraphs is a \IX. \RED this is a comment Although comments are paragraphs, they are treated a little bit different, just for reasons of convenience. As they should be placed near to what they remark, the usual whitespace line behind would be contra productive. So, each comment line is a paragraph by itself. Which in turn means that subsequent comment lines need their double slash prefix \I. // this is // a comment Here we go with the next text paragraph. ==Produce a document \ILLT ===Intro to converters The transformation from a PerlPoint source into a document is done by programs called "PerlPoint converters". A number of these scripts is available on CPAN and at the projects site at Sourceforge: * \BCX is the traditional main converter. It produces fancy HTML pages and is highly configurable. This converter is part of the CPAN distribution \CPAN. * \BCX produces LaTeX. This is claimed to be in alpha state but is fairly stable. It comes as part of \CPAN as well. * \BCX generates SDF, a document format superseeding POD, by Ian Clathworthy. SDF is out of development, but it's very stable. The SDF processor \CPAN can produce a \I of other formats, namely PDF, PostScript, POD and manpages. So SDF is typically used as an intermediate format. \C is part of \CPAN. As you can see, typically there is one converter for every target format. This was our approach up to \C 0.39, and these tools are furtherly provided and fully supported. Additionally, \C 0.40 introduced an extended design which makes it easy to have \I converter for \I target formats. In this design, format capabilities are added by \I, which from a users point of view come in the form of Perl module distributions. In the extended design, the all in one converter is called \BCX. Currently the following formatters are available: * \BCX, generating SDF. In fact the default converter for SDF reproduces all the capabilities of \C. It comes with \CPAN. * \BCX. The base XML formatter transformes the PerlPoint source document into XML according to an own DTD. Tag names can be adapted, and the resulting DTD can be produced as well. Part of \CPAN. * \BCX. Generates XML for the \CPAN presenter by Matt Seargeant. Part of \CPAN. * \BCX. Produces an XHTML document, supporting CSS. The document is written to a single page. Part of \CPAN. * \BCX. Produces XHTML documents supporting CSS, one page per chapter. Part of \CPAN. The list of formatters will hopefully grow. A formatter to the Open Office Presenter software ("Impress") may follow, as it uses XML as well. Please note that nobody is limited to the converters in this list. In both concepts, anyone in need of another converter can write it on his own, as there is an open framework provided. In the formatter concept, is is even possible to modify just a certain part of an existing converter, to get the behaviour you prefer. We will talk about that in the advanced sections. For now, we will have a look how to use these programs to get a document from our source. The following sections describe both the established and stable "one format, one converter" concept, and the new formatter concept which is still in beta state. Feel free to use the concept of your choice. ===Using target specific converters ~ Target specific converters As listed in the intro \OREF{n="Intro to converters"}, there are various converters of this type. First, find a converter for your target format. Let's assume HTML should be written. HTML can be produced from SDF, so one way could be to use \C and \C in a sequence. But this would require several steps and results in one (and possibly long) single page. Another converter is \C, the well featured and stable converter by Lorenz Domke, which writes multi paged HTML in one step. Let's focus on that. Now find out the calling conventions of the chosen converter. For \C, a basic call looks like this: pp2html source.pp This call produces one page per chapter, right where you are. The slides are named \C etc. Each page is reported by the run. The pages written are very straightforward in design, but well written and usable. A link filled contents page (\C) and an index (\C) are added automatically. Lots of options are available to adapt this design. Many aspects can be fine tuned, including the target directory. To write into \C, just add option \C<-targetdir>: pp2html \RED<-targetdir test> source.pp , and all the new files will be written to \C which is made if required. The filenames can be changed as well. Use the \C<-slide_prefix> and \C<-slide_suffix> options to do this: pp2html \RED<-slide_prefix page -slide_suffix html> source.pp With these changes, now the generated files are named \C<\RED0000.\RED> etc. Likewise, colors can be adapted. As a simple example let's change the background and example boxes: pp2html \RED<-bgcolor cyan -boxcolor magenta> source.pp .- and our pages are looking wild ;-) There are \I of color options. All of them take the values that are accepted by the color options of HTML tags, so one can use hexadecimal codes with a preceeding \C<#> as well: pp2html \RED<-bgcolor '#0e0000'> test source.pp Ok, but there are more things to tune. \C<-center_headers> centers headlines, while \C<-nonum_headers> switches off headline numbers: pp2html \RED<-center_headers -nonum_headers> test source.pp This is just an intro. Please refer to the docs of \C for a complete option list. The feature set is really rich. But you do not have to remember and retype all necessary options again and again. The quickest way of option reuse is to store them in a file and let \C process this file instead of direct options: \GREEN<# This could be your option file.> \GREEN<# target directory> -targetdir test \GREEN<# filenames> -slide_prefix page -slide_suffix html \GREEN<# color options> -bgcolor cyan -boxcolor magenta \GREEN<# header options> -center_headers -nonum_headers Now, with a file like this, a call would be reduced to pp2html @options source.pp The options collected in an option file define a certain layout style. As a further level of abstraction, \C supports option files stored in central places, which are called "styles". To make such a style, first collect all necessary options in an option file. Then, make a style directory, e.g. \C, to hold all your style setups. Store your option file under this path, in a subdirectory named as you wish to call your style, and name it \C<.cfg>. Here is an example: styles | -- \RED | -- \RED.cfg Now you can use this style by specifying its name and the base path: pp2html \RED<-style_dir styles -style YourStyle> source.pp Additional files like templates and bullet graphics can be stored in the (specific) style directory as well. \C will copy them to the target directory automatically. Note that while various options are shared by various converters, others can be different as each converter can define options of its own. Please refer to their documentations. ===Using formatter based converters ~ Generators With this approach, there is only one converter to know: \BCX. This converter is installed with \C. \C is kind of a launcher. It can handle various \C by loading related modules. Likewise, it \I the results in a specific way, using \I if requested. You just have to define the way your output should be built. The setup is performed by options. First, you have to choose the target language. At the time of this writing, these languages are available: * SDF, * XML. To get the most recent list, please have a look at \L{url="http://search.cpan.org"}. Language generators are implemented as Perl \I, so you can search for modules named \C>>. Capitals are used intentionally: all language modules are capitalized by convention. OK, let's say we want to produce XML, as this is cool and near to HTML. We use the \BCX<-target> option to let \C know of this decision. perlpoint \RED<-target XML> source.pp Similar to \REF{type=linked name="Using target specific converters"}, the source files are passed in as parameters. With this call, we get a list of copyright notes and an error message: perlpoint 0.01, (c) J. Stenzel (perl@jochen-stenzel.de), 2003-2005. This is a PerlPoint::Generator::XML::Default converter. PerlPoint::Generator::XML::Default 0.01 (c) J. Stenzel (perl@jochen-stenzel.de), 2003. PerlPoint::Generator::XML 0.01 (c) J. Stenzel (perl@jochen-stenzel.de), 2003-2004. PerlPoint::Generator 0.01 (c) J. Stenzel (perl@jochen-stenzel.de), 2003-2005. [Fatal] Missing mandatory option -doctitle. First, the program is reported to be a \I<\C> converter. Every language is written by a \I. Changing the formatter redefines your results. If no formatter is specified as in our call, \C falls back to the default converter. \I Then, you see all the modules that were loaded automatically. From a users point of view, these are just internals handled behind the scenes, but you can see that there's a hierarchy. Finally, we have that error message. Oops - \C requires a minimum of document and file data, including the title (\CX<-doctitle>), filename prefix (\CX<-prefix>) and filename suffix (\C<-suffix>) Different to \C, the \C<-suffix> option requires to specify the extension dot). perlpoint -target XML \RED<-doctitle Example -prefix example -suffix .xml> source.pp And with this call, the converter generates an XML file \C. As our option list grows quickly, we switch to an option file now. Option files allow to read options from a file, written exactly as on the command line, intermixed with comments and empty lines for readability. At this opportunity we add a target directory: \GREEN<# document title> -doctitle Example \GREEN<# filenames> -prefix example -suffix .xml \GREEN<# target directory> -targetdir example The call now changes to perlpoint \RED<@options.cfg> source.pp In the following we will assume that all necesary options are stored in the option file. On the command line, we will focus on the options we are talking about. Well! The XML produced is very general, but of course it follows a DTD. The DTD can be printed out by using \C<-writedtd> and \C<-xmldtd>. perlpoint @options.cfg \RED<-xmldtd example.dtd -writedtd> source.pp After this call, you not only have the required XML file but also \C which describes the general format and can be used to transform the results in whatever you want. For example, we could produce XHTML using XSLT. But fortunately, there's a formatter that emits XHTML directly. Formatters are plugins implemented by Perl modules. For a list of formatters available for your target language, again \L{url="http://search.cpan.org"} for modules named \C::\RED<>>. (The "Something" might include various module levels.) A search for the XML target currently replies these formatters: * PerlPoint::Generator::XML::\RED, * PerlPoint::Generator::XML::\RED, * PerlPoint::Generator::XML::\RED. By installing their distributions, these formats become available to \C. To invoke a formatter, use the \C<-formatter> option. perlpoint @options -target XML \RED<-formatter XHTML> \BLUE<-suffix .html> source.pp Note that the formatter name is specified in a short form. Only the module levels after \C> are required. Our latest call produced a single HTML page \C. The XHTML is basic but can be easily improved by using the various options of the new formatter. To find the available tuning tools, add \C<-help> to your call. perlpoint @options.cfg \RED<-help> source.pp This will display the online help, containing a section "Options". You'll find things like \C<-css>, \C<-favicon>, \C<-norobots> and more. These were not available before as we used the default formatter - check it by another help request: perlpoint @options.cfg \RED<-formatter Default> -help source.pp Indeed - now there are no XHTML specific sections. Instead we find XML specific stuff like \C<-writedtd>. \I Do we get even more options for the \C converter? Looking at the help it doesn't seem so at the moment (but this could change in the future, so always check the help after updates). \I we get with this formatter is a splitted output - each chapter is on its own page now. These pages are named \C<->, e.g. \C. perlpoint @options \RED<-formatter XHTML::Paged> source.pp The layout is still basic. There are two ways to beautify it. First, we can use the options provided by the language generator and the formatter, e.g. \C<-css>. Additionally, we can use the third component of the generator design: \IX. \C> means "template driven output", and all you need is typically a \I