// -- macro declarations: start reading with first headline +BC:\B<\C<__body__>> // -- end of "preface" =0.36 This is a major update - in the sense that it modifies a lot of internals, especially stream handling. Nevertheless, it's almost completely compatible with earlier versions of the package (and the few \REF{name="Summary: Incompatible changes" type=linked} most likely do \I affect existing converters). So \I While working on this version, I began to make use of the modified internals myself. As a result, there are various new \I features as well. See section "\REF{name="Visible Changes" type=linked}" below for all details. Internals are described in chapter "\REF{name=Internals type=linked}". \I> (included in CPAN package \C - do \I install the still available standalone distribution of \C). You may have to update \C as well. ==Bugfixes * Several very slight fixes in calls of \C (these bugs caused no errors). * \C embedded native SDF incorrectly into the produced result. Thanks to Lorenz for the bug report. * \C: unintended SDF recognitions caused by ">" characters are now avoided by generating ">" as "{{CHAR:gt}}" (outside verbatim blocks). * If the only contents of a table cell was a \C<0>, this number was removed. Fixed. * If a macro overwrote a tag with the same name and a (parsing) hook, the tag hook was invoked when the macro had been used. * Tag parsing hooks received tag options instead of the tag body. * Helmut Steinbach found that the closing sequences of verbatim blocks made by Active Content were not recognized correctly. This could be fixed. * Investigating the previous point I found that is was also impossible to dynamically make a usual example block or a paragraph that starts with a tag or macro. This is now fixed as well. * Internal bugfix in macro body reparsing. The bug could cause infinite parsing loops. ==Internals This chapter can be safely skipped by "pure" PerlPoint users which might like to continue with chapter "\REF{name="0.36 | Visible Changes" type=linked}". This chapter describes these news: \LOCALTOC{type=linked} ===PerlPoint::Backend, stream format \B<\I> I do not know of any direct stream access in a converter, but \I anyone did access the stream directly, he will need to adapt his code. Code using \C does \I need to be adapted. The stream is still a stream basically, but with additional structural hints stored in parallel, which are currently a stream of headline index numbers. This way I hope to stay with the performance advantages of a stream while enabling things like chapter inspection and arbitrary chapter navigation. For example, \C 0.11 in fact needs to process the stream twice because it needs the whole picture of the headline structure when building slides. Now it would be possible to inspect headlines in the first pass \I, and to process \I tokens in the 2nd pass then. This is a common task - \C might be modified or not, but future converters can definitely make use of this. (And there's an even better and faster way now to grab the TOC, see below.) To make use of the new structure, \C provides several new methods: * \C now works in \I. By default, it processes all tokens as usual. This is called the "token mode". In \I, it processes \I. Switch modes by \BC - even from within a callback! * Navigate within the stream: \BC goes back to the very beginning, while \BC allows you to jump to a certain chapter. * Get the number of all headlines by \BC, and the number of the current chapter by \BC. * The stream data structure is now bound to a backend object while \C is running. If navigation methods, \C or \C shall be called outside \C - which means outside a callback - \BC can be used to perform this binding manually. * Instead of using \C, converter authors may prefer to process the stream step by step having full control (e.g. to use the stream while presenting instead of in format translation). This is possible by using \C, sequential calls of \BC and finally \BC. The new backend method \BC uses the new features to provide a table of contents. If called for a certain chapter, all subchapters are listed. The reported depth can be limited. # get the complete \I $toc=$backend->\B; # get a list of all \I $subchapters=$backend->toc($backend->currentChapterNr); # get a list of the subchapters \I (do not list the complete tree, if there # are more levels) $subchapters=$backend->toc($backend->currentChapterNr, \B<1>); All backend extensions are documented both in \C's POD and in the converter tutorial. Hopefully. ===More stream enhancements * Headline start directives provide the full headline title (plained, which means without possibly used tags) as new data. * Unordered and description list directives now reserve a parameter at the position where \I directives traditionally pass a list startup level. This parameter is currently unused. * All list directives provide four new additional parameters to give converter authors a hint about subsequent or preceeding \I. For reasons of stream construction, hints about \I level shifts are provided in list \I directives \I, while hints about \I level shifts are provided in list \I directives \I. (But these are exactly the places where these informations can help, so symmetry is the only thing lost here.) This feature is intended to help a converter to build really \I lists. (In PerlPoint, a list level shift implicitly closes a previous list, but this is different in various target languages.) * Parser and backend now interact via directive hints. This is an internal interface. For example, it is used to flag that a tag and / or its contents should be skipped (see below). ===New finish hook to complete tags With the new tag declarations by module introduced by version \REF{name="0.34" type=linked}, it became possible to hook into tag parsing. Now there's another hook to \I a tag \I parsing - this means, when all input informations are available. The new \C<\\REF> macro makes use of this feature to verify links and to complete itself by linked content. The new hook interface is quite similar to parsing hooks except that it does not provide informations only available at parsing time (like the tag body). See \C for a detailed doc. ===New hook return codes PARSING_IGNORE and PARSING_ERASE Tag \I hooks can return two new codes: * \BC causes the parser to ignore the tag. The result is just the body. * \BC removes the tag \I which means together with all its content. See the new basic tag \\HIDE for an example. Finish hooks can return these codes as well, with exactly the same effect. (The tag remains streamed (as well as its body), but will be bypassed by the backend.) See \C for a detailed doc. ===Hooks can now be interchanged It is now possible to use hooks of a "foreign" tag (declared by another tag module) in your own tag hooks. This helps to emulate other tags, for example if an \I (tag and option names) shall be preserved but the \I shall be used. To invoke a foreign hook, call \C anywhere in your own hook, passing tag name, hook type and parameters, like so: $rc=PerlPoint::Tags::call('TAG', 'hook', @_); If the tag is not registered, or has no hook of the specified type, an undefined value is supplied, otherwise the return code of the invoked function. ===New anchor management The parser can relieve converters from anchor management partially now. This is an \I. * A new minimal class \BC provides basic anchor collection services. Addresses and related values can be added and queried. * The parser maintains a \C object. * On request, headline titles (stripped off of tags) are automatically added to the parsers anchor collection. (This is inspired by the automatic headline anchors idea by Lorenz, built into \C for versions and already imitated by \C. Why not make it a general feature?) To activate this feature call \C with \C set to a true value. * The parsers anchor collection object is passed to all tag hooks (both parsing and finishing ones), where the collection can be extended (most probably by parsing hooks) or queried (supposedly by finish hooks). This is the complete management for now. The parsers collection is \I made part of the stream. It's just a help to verify links at parsing time, and to insert named values into the stream. The new \C<\\REF> macro uses the parsers anchor collection to resolve values not available at parsing time, like sequence numbers generated by the new \C<\\SEQ> tag. Again: with this feature (and tag finish hooks), it becomes easy to reference strings defined \I than the reference. ===Summary: Incompatible changes Various incompatible modifications might have been mentioned before, but it might be useful to have a check list: * The stream format was \I extended, both in structur and semantics. \C manages this for you. (And you already used it, didn't you? ;-) * List shift paragraphs are no longer streamed by opening \I closing directives. There's only an \I directive from now on. * Tag (parsing) hooks have a modified interface: the tag body is now passed by reference, no longer as a list. This was necessary to add new parameters to the interface. * Tag completion directives in the stream no longer provide exactly the same informations as corresponding start directives, because the new finish hooks are only invoked for startup directives. So, if a tag finish hook modifies tag options, this will affect the startup directive only. (Let me know if this causes problems.) * Likewise, headline start directives in the stream now provide more informations than related completion directives: the full (plained) headline title is only provided with the startup hint. * \C<\\TABLE> tags are streamed with additional informations about the separators used (options \C and options \C). If they were made from a table \I, there's an additional option \C<_paragraph_> set to 1. These informations are intended to be used when a paragraph is retranslated for a \REF{name="New type of active contents: paragraph filters" type=linked}. ==Visible Changes While the modified internals are especially of converter authors interest and do not affect existing documents, there are already \I features in this version implemented on base of the new internals which \I find your interest and help you in writing documents. These new features include: \LOCALTOC{type=linked} Please see the \REF{name="0.36 | Misc" type=linked}<"Misc"> section below for more visible changes which are not based on the modified internals. ===More active content: tags and macros can be made optional If a tag or macro has an option \BC<_cnd_>, the parser treats this option as a \I to activate the tag/macro or not. The condition is evaluated as Active Content. If Active Content is disabled, the condition defaults to "false". \\IMAGE{_cnd_="$illustrate" src="piegraph.gif"} Unfortunately, because it is done via option, only tags and macros \I options can be made conditional. So, \\I{_cnd_="$italics"} cannot be written because of a parsing error. That's bad. If anyone has an idea for a well fitting general solution, please let me know. (Hint for converter authors: the condition option is stripped off of the options hash if the condition (and therefore the tag) turns out to be valid. You cannot evaluate it yourself again.) ===New basic tag \\LOCALTOC \BC<\\LOCALTOC> inserts all subsections of the current chapter (in requested depth). Simply say: =Parent chapter In this chapter: \B<\\LOCALTOC> ==Subchapter 1 ===Subchapter 1.1 ==Subchapter 2 , and a converter will produce results according to \I source: =Parent chapter In this chapter: \B<* Subchapter 1> \B<* Subchapter 1.1> \B<* Subchapter 2> ==Subchapter 1 ==Subchapter 2 I missed something like this tag for a long time, indeed. Think of all the empty pages produced by headlines which just collect various subchapters, but without own text. It is possible to limit the subhierarchy depth taken into account (suppress the display of subchapter 1.1 in the example above by setting \C to 1), to format the produced list in various ways (ordered, unordered, with chapter numbers) and even to make the chapter titles hyperlinks to their related chapters (if supported by the target format). The transformation has to be done \I. As I know, the tag shall be supported by \C<\PP::Converters> 0.12. For now, you may get an impression by using \C which as a reference implementation is already supporting \C<\\LOCALTOC>. ===New basic tag \\SEQ Generates the next value of a certain sequence "type" which is declared by option: \\SEQ{type=example}, \\SEQ{type=example}, \\SEQ{type=example} will produce \C<1, 2, 3>, while \\SEQ{type=example}, \\SEQ{type=image}, \\SEQ{type=table} results in \C<1, 1, 1> (provided no sequence was started before). It is possible to name the generated number, which makes it easy to reference it. Naming is done by option \BC. \SEQ{type=image name="Blue water"} (Note: Converter authors have to deal with this tag a special way because the number is passed by a generated tag \I