You are looking at historical revision 1338 of this page. It may differ significantly from its current revision.
- Converting from wiki to HTML
- Converting from wiki to LaTeX
- Converting from wiki to Plain Text
- Analyzing wiki files
- Version history
Streams-based code for converting from the relatively standard and easy to type wiki format to many useful formats.
It currently supports converting to the following formats:
- LaTeX (useful for generating PDF files)
- Text (useful for indexing contents without markup, for example for searching).
We are working on implementing support for Texi. OpenDocumentFormat may come after.
This egg provides the parsing functionality used by svnwiki. Using this egg other content management systems could allow its users to upload and modify contents in wiki format and display it in many different formats.
Converting from wiki format to HTML
The following code receives input from current-input-port in wiki format and converts it to HTML written to current-output-port:
(use stream-ext stream-wiki) (write-stream (wiki->html (port->stream (current-input-port))))
Note that the resulting page does not include the <html> and <body> tags (to make it easy to include it as part of a page with other stuff).
Converting from wiki format to LaTeX
The following code receives input from current-input-port in wiki format and converts it to LaTeX written to current-output-port.
(use stream-ext stream-wiki) (write-stream (latex-page "english" "article" (wiki->latex (port->stream (current-input-port)))))
Returning the links in a file
The following code reads information in wiki format from current-input-port and returns a stream with all the local links found. Note that links to absolute URLs are not considered local links and are thus not returned. Each entry in the stream has the form (dst name), where dst is the target of the link and name the text shown in the link.
(use stream-ext stream-wiki) (wiki-links (port->stream (current-input-port)))
Returning a list of tags in a file
It is possible to include "tags" (in the sense of tagging files with categories) in wiki pages as part of their contents. To do this, the page should include a stream of the form <nowiki>[[tags:tag0 ... tagn]]</nowiki>. This allows users of wiki systems to browse pages by categories (eg. list all pages having tag tag0).
The following code loads a file in wiki format from test.wiki and returns a stream of symbols, one for each tag found.
(use stream-ext stream-wiki) (wiki-tags (port->stream (open-input-file "test.wiki")))
This egg is made by Alejandro Forero Cuervo <email@example.com>.
The stream-wiki egg is available under the GNU General Public License.
This egg depends on the following:
Converting from wiki to HTML
(wiki->html input [tail] [name] [open] [include] [linktypes] [make-header] [data-output-func] [check-exists?] [redirect-unexistant] [extensions] [url-adjust])
Converts from a simple wiki format (which is relatively standard nowadays) into HTML.
input should be a stream of characters (built with the mechanisms provided by SRFI-40 or the stream-ext egg) with the contents in wiki-format; the function returns a stream of characters to be included as part of an HTML page.
Note that the returned stream will be built dynamically as it is read (and so will the input stream be read).
Converting from wiki to LaTeX
Converting from wiki to Plain Text
(wiki->text input [human-readable])
Remove all wiki markup from the stream of characters input and produce a corresponding stream of characters for its associated representation as a plain-text file. This is useful, for example, to register the file in a search database (see, for example, the estraier egg).
human-readable specifies whether the resulting file will be optimized to be read by a human (eg. a user reading it over a text-only interface) or a computer (eg. an indexer using the estraier egg).
Analyzing wiki files
Return a stream with all local (not external) links in the stream of characters input. Each element in the stream is a stream of characters with the destination of the link.
Obtaining a table of contents
- Added wiki->text, small fix in URL handling, adjust URLs in images (using check-exists? and url-adjust, don't strip HTML comments (since some users have reported they need to be able to include HTML comments in their wiki files, eg. for TOL).
- Added url-adjust parameter for local/relative URLs.
- Fixed a typo that was causing crashes during Texi/LaTeX output (again, the <=> string); made extensions see macros; more fixes in URL recognition; many fixes to the extension files.
- Improvements in the recognition of URLs, the generation of TexVC math image files, add support for external extensions, preliminary menus and navigation for texi-driver (by Graham Fawcett), fixed typos that were causing problems with <blockquote> and LaTeX output and with the string <=>.
- Improved the parsing of email addresses and URLs (which in some cases failed to recognized them as such). Parse the result of evaluating linktypes as wiki format recursively (detecting infinite recursion and failing gracefully).
- Lots of improvements, way too many to list here. :-/
- First public release