HTML Templates
HTML Templates
Table of Contents
Overview .................................................................................................................................................... 3
What is an HTML template? ......................................................................................................... 4
Installing a custom HTML template ............................................................................................ 8
The helpers.php file ....................................................................................................................10
Possible values for text run arrays ...........................................................................................11
A text run array ........................................................................................................................... 14
The Clarify HTML template system provides a way to export content into a variety of custom
formats. The primary use for HTML templates is to create HTML content, but templates can
be customized to create any type of content that is text-based. For example, you might
create a custom template to export to XML, Markdown, MediaWiki or other formats.
1. config.xml: The configuration file provides instructions about how Clarify should prepare
your content prior to passing it off to the PHP engine.
2. ./Content folder: The Content folder contains all of the files necessary to export a template.
At a minimum it will contain an article folder. If you have supporting PHP files that are used
in your HTML template then you would place them in the Content folder.
3. ./Content/article folder: The article folder contains all of the files that will be exported
when exporting an article.
• article_structure: controls the nesting of steps in the PHP object. Default value is hierarchal
which nests substeps under steps. Set to flat to get a non-hierarchal list of steps with no
nesting.
• hi_res_images: specifies whether or not to export images taken on high-resolution monitors
with full resolution. The default behavior is true in which case all image data is exported but
the image dimensions in the PHP object are appropriate for the size that the image should
be displayed at. For example, a 600x600 retina image should be displayed at 300x300. Set in
false to discard the high-resolution image data.
• image_names: format used to name images. random or step_title. random can be useful if
you need to ensure that you never end up with duplicate image names when importing into
a 3rd party system.
• max_image_dimensions: The maximum image dimensions to use for width and height.
Entries are a comma delimited list of integers. You can provide just the width, width and
height, or just height. Examples:
600,
600,500
,500
• text_format: xhtml or runs. xhtml is appropriate for creating HTML content and you won't
need to do anything to the text that Clarify puts into the PHP objects. runs formats text in an
array that separates the actual text from the formatting applied to the text. This allows you
to more easily massage the text into other formats (e.g. markdown).
• web_safe: true or false.
• word_separator: character used to separate words in names.
The article folder is where you put all of the files that will be exported when exporting an article.
There are two files that are required:
1. @article: This is the template file that ScreenSteps will process with PHP. The filename must
start with @article. The extension you add is up to you.
2. @images: This is a placeholder file. ScreenSteps will store all article images in the same
location as this file. Notice that in this example the file is in an @article folder. The HTML
exporter will replace @article with the name of the article when exporting.
Any other files and folders in the article folder will be copied into the folder the article is being
exported to.
Note that you will need to restart Clarify in order for the template to be available.
To quickly access the Templates folder use the Help menu and select Reveal Custom
Template Folder option.
On Windows look in the ScreenSteps installation folder. You will find helpers.php in
./components/html_exporter/helpers.php.
The article lays out the structure and possible values for a text run array. Use this article as
a reference when writing PHP code that iterates over a text run array.
A text run array contains any number of paragraphs objects which are referred to by
PARAGRAPH_KEY below.
/* Unused
$para->style->align
*/
if (!empty($run->style->color))
{
$output .= '<span style="color: rgb(' . $run->style->color . ');">';
$closingRun = '</span>';
}
/* Unused
$run->style->font_family
$run->style->font_size
$run->style->text_shift
*/
$output .= $prefix;
$output .= $run->text;
$output .= $suffix;
$output .= $closingRun;
}
}
$output .= $closingPara;
return $output;
}
If an HTML template has the config.xml text_format parameter set to runs then text will
formatted using an array. This article provides a brief introduction to how the array is
structured and what some examples look like.
If you just plan on using xhtml as the setting for text_format then you don't need to worry
about the information in this article.
Below you will see some basic example text followed by the print_r output for the array in PHP.
Each paragraph in the text becomes a key in the array. The first paragraph starts at [0].
A paragraph can have properties. For example, meta->style can be code which means the
paragraph should be formatted as code. Or the style->list_style might be set to disc in which
case it is a bulleted list.
Each paragraph is then broken up into runs. A run is a run of text that shares the same
properties, such as color and style. Whenever a property of the text changes a new entry is
added to the runs array for the paragraph.
By organizing the text this way you can iterate through a text run array in a straightforward way
and format the according to the specification of the format you are exporting to.
Example text 1
This is some example text.
Array
(
[0] => stdClass Object
(
[metadata] => stdClass Object
(
[style] =>
)
[runs] => Array
(
Example text 2
This is some introductory text.
• List item
• List item
1. List item
1. List item
2. List item
2. List item
Array
(
[0] => stdClass Object
(
[metadata] => stdClass Object
(
[style] =>
)
[runs] => Array
(
The @article template file is processed by PHP and will generate the content for each article
that you are exporting.
An example
Here is the @article.html for the Black & White template that ships with Clarify. As you can see,
it is a mixture of HTML and PHP. The document content and user settings are all available as
PHP objects that can be used to generate the output. For example:
1. PHP is used to print the article title. If a meta title has been set then the meta title is used.
2. The article title is added to the document. This is the title the user sees on the browser page.
3. Article content is printed out using a function from helpers.php.
$userSettings object
stdClass Object
(
[footer_text] => The text the use wants to display in the footer.
[logo] => The path to the logo file the user selected.
)
This article contains links to sample templates that you can use as a starting point.
http://files.clarify-it.com/v2/templates/html/Black%20%26%20White.zip
Markdown Hi-Res
This template shows how to customize your own Markdown template. It includes a
markdown_process.php file with the template that includes the image width and height
parameters in the image reference. In addition, the template hi_res_images property is set to
true so that the full-size image is exported for screen captures taken on high-resolution
monitors.
http://files.clarify-it.com/v2/templates/html/Markdown%20Hi-Res.zip
Markdown Passthru
This template passes the text in the Clarify document directly through with only minor
modifications. The document and step titles have Markdown added but the description and
instructions pass through. This allows you to write your Clarify document in Markdown and
then use this HTML template to export it as-is.
http://files.clarify-it.com/v2/templates/html/Markdown%20Passthru.zip
Shadowbox
This template outputs HTML with images that are tagged for use with Shadowbox. The HTML is
appropriate for WordPress export. The template will create a full size version of any image over
540 pixels and if Shadowbox is available then clicking on the thumbnail version will display the
full-size image. You can change the maximum image dimensions in the config.xml file.
This template uses a copy of the printArticleHTML function from the helpers.php file so that the
output can be customized.
http://files.clarify-it.com/v2/templates/html/Shadowbox.zip