Zim::Formats.3pm

Langue: en

Autres versions - même langue

Version: 2009-02-23 (debian - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Zim::Formats - Common routines for Zim formats

DESCRIPTION

TODO

METHODS

Registration

"register_format()"
TODO
"list_formats()"
TODO

Using templates

"lookup_template(FORMATE, NAME)"
Returns a file name or undef.
"list_templates(FORMAT)"
Returns a hash with name => filename pairs of available templates. Used for exporting.

TODO: also look in NOTEBOOK/_templates/

"bootstrap_template(TEMPLATE, PAGE)"
Setup TEMPLATE to export PAGE.
"save_tree(IO, TREE, PAGE)"
TODO

---

When a subclass has defined a %Tags this method will wrap the text context of each parse-tree node in this tag.

The hash %Tags uses the tag names as keys and has as values array refs consisting of a start string, a closing string and a boolean whether this tag can span multiple lines.

For all tags not found in this hash a method "dump_TAG()" is called, where TAG is the tag name.

"parse_page_properties(PAGE, TEXT)"
Parse a block with headers and add them to the properties hash.
"dump_page_properties(PAGE)"
Returns a header block containing page properties. All properties with lower case names are ignored and care is taken to have the Content-Type header et. al. on the first line.
"parse_rfc822_headers(TEXT)"
Parse a block with headers and return a hash. All headers will be upper-cased properly.
"dump_rfc822_headers(\%HEADERS)"
"dump_rfc822_headers(%HEADERS)"
Returns a header block from a hash. If the hash is passed as reference keys are sorted alphabetically, if passed as a list the order is preserved.
"header_date_string(TIME)"
Returns TIME as a string following the rfc822 format for date/time headers. TIME can be given in seconds or as a "localtime" array.

Parse-tree manipulation

"parse_link(LINK, PAGE, NO_RESOLVE)"
Returns the link type and link target for LINK. The type can be e.g. 'page', 'file', 'mail' or 'man' - for urls the protocol is used as type.

The link target is e.g. a fully specified page name, a fully specified path, or an url. For file:// urls the path is returned. For mail a 'mailto:' url is returned.

If NO_RESOLVE is set we only check the type, but do not try to fully specify the target.

"extract_refs(TYPE, TREE)"
Returns a list with references to nodes of type TYPE in the tree.
"delete_first(TYPE, TREE)"
Deletes and returns the first node of type TYPE from the tree.
"get_first_head(TREE, STRIP)"
Returns the level and the text content of the first head.

STRIP is a boolean, if set to TRUE the head is removed from the tree.

"update_heads(TREE, MIN, MAX)"
Given a parse tree this method updates the level of all headings. MIN is the minimum level, so all headings will be shifted down with this amount (default is 1). MAX is the max level, any heading below this level will be flattened to the maximum level (default is undefined).

It is assumed that heads can only occur toplevel in the parse tree. (They can not be nested indside paragraphs etc.)

"fix_file_ending(TREE)"
Make sure that the last piece of text in the tree ends with a newline. This increases the change of the file resulting from dumping the tree to end in a newline.

AUTHOR

Jaap Karssenberg (Pardus) <pardus@cpan.org>

Copyright (c) 2006 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Zim