NAME
Org::Export::HTML - Export Org document to HTML
VERSION
version 0.03
SYNOPSIS
use Org::Export::HTML qw(export_org_to_html);
# non-OO interface
my $res = export_org_to_html(
source_file => 'todo.org', # or source_str
#target_file => 'todo.html', # defaults return the HTML in $res->[2]
#html_title => 'My Todo List', # defaults to file name
#include_tags => [...], # default exports all tags.
#exclude_tags => [...], # behavior mimics emacs's include/exclude rule
#css_url => '/path/to/my/style.css', # default none
#naked => 0, # if set to 1, no HTML/HEAD/BODY will be output.
);
die "Failed" unless $res->[0] == 200;
# OO interface
my $oeh = Org::Export::HTML->new();
my $html = $oeh->export($doc); # $doc is Org::Document object
DESCRIPTION
Export Org format to HTML. Currently very barebones; this module is more of a proof-of-concept for Org::Parser. For any serious exporting, currently you're better-off using Emacs' org-mode HTML export facility.
This module uses Log::Any logging framework.
This module uses Moo for object system.
This module's functions have Sub::Spec specs.
ATTRIBUTES
naked => BOOL
If set to true, export_document() will not output HTML/HEAD/BODY wrapping element. Default is false.
include_tags => ARRAYREF
Works like Org's 'org-export-select-tags' variable. See export_org_to_html() for more details.
exclude_tags => ARRAYREF
After 'include_tags' is evaluated, all subtrees that are marked by any of the exclude tags will be removed from export.
html_title => STR
Title to use in TITLE element. If unset, defaults to "(no title)" when exporting.
css_url => STR
If set, export_document() will output a LINK element pointing to this CSS.
METHODS
$oeh->export($doc)
Export an Org document into HTML. $org is Org::Document object. Returns $html, which is the HTML string. Dies on error.
$oeh->export_document($doc) => $html
Given an Org::Element::Block element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_block($elem) => $html
Given an Org::Element::Block element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_short_example($elem) => $html
Given an Org::Element::ShortExample element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_comment($elem) => $html
Given an Org::Element::Comment element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_drawer($elem) => $html
Given an Org::Element::Drawer element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_footnote($elem) => $html
Given an Org::Element::Footnote element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_headline($elem) => $html
Given an Org::Element::Headline element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_list($elem) => $html
Given an Org::Element::List element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_list_item($elem) => $html
Given an Org::Element::ListItem element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_radio_target($elem) => $html
Given an Org::Element::RadioTarget element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_setting($elem) => $html
Given an Org::Element::Setting element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_table($elem) => $html
Given an Org::Element::Table element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_table_row($elem) => $html
Given an Org::Element::TableRow element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_table_cell($elem) => $html
Given an Org::Element::TableCell element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_table_vline($elem) => $html
Given an Org::Element::TableVLine element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_target($elem) => $html
Given an Org::Element::Target element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_text($elem) => $html
Given an Org::Element::Text element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_time_range($elem) => $html
Given an Org::Element::TimeRange element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_timestamp($elem) => $html
Given an Org::Element::Timestamp element, export it to HTML. Override this in subclass to provide custom behavior.
$oeh->export_link($elem) => $html
Given an Org::Element::Link element, export it to HTML. Override this in subclass to provide custom behavior.
FUNCTIONS
None is exported by default, but they can be.
export_org_to_html(%args) -> [STATUS_CODE, ERR_MSG, RESULT]
Export Org document to HTML.
This is the non-OO interface. For more customization, consider subclassing Org::Export::HTML.
Returns a 3-element arrayref. STATUS_CODE is 200 on success, or an error code between 3xx-5xx (just like in HTTP). ERR_MSG is a string containing error message, RESULT is the actual result.
Arguments (*
denotes required arguments):
css_url => str
Add a link to CSS document.
exclude_tags => array
Exclude trees that carry one of these tags.
After 'include_tags' is evaluated, all subtrees that are marked by any of the exclude tags will be removed from export.
html_title => str
HTML document title, defaults to source_file.
include_tags => array
Include trees that carry one of these tags.
Works like Org's 'org-export-select-tags' variable. If the whole document doesn't have any of these tags, then the whole document will be exported. Otherwise, trees that do not carry one of these tags will be excluded. If a selected tree is a subtree, the heading hierarchy above it will also be selected for export, but not the text below those headings.
naked => bool
Don't wrap exported HTML with HTML/HEAD/BODY elements.
source_file => str
Source Org file to export.
source_str => str
Alternatively you can specify Org string directly.
target_file => str
HTML file to write to.
If not specified, HTML string will be returned.
SEE ALSO
AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.