The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Text::Amuse::Output

SYNOPSIS

The module is used internally by Text::Amuse, so everything here is pretty much internal only (and underdocumented).

Basic LaTeX preamble

  \documentclass[DIV=9,fontsize=10pt,oneside,paper=a5]{scrbook}
  \usepackage{graphicx}
  \usepackage{alltt}
  \usepackage{verbatim}
  \usepackage[hyperfootnotes=false,hidelinks,breaklinks=true]{hyperref}
  \usepackage{bookmark}
  \usepackage[stable]{footmisc}
  \usepackage{enumerate}
  \usepackage{longtable}
  \usepackage[normalem]{ulem}
  \usepackage{wrapfig}
  
  % avoid breakage on multiple <br><br> and avoid the next [] to be eaten
  \newcommand*{\forcelinebreak}{~\\\relax}
  % this also works
  % \newcommand*{\forcelinebreak}{\strut\\{}}

  \newcommand*{\hairline}{%
    \bigskip%
    \noindent \hrulefill%
    \bigskip%
  }
  
  % reverse indentation for biblio and play
  
  \newenvironment{amusebiblio}{
    \leftskip=\parindent
    \parindent=-\parindent
    \bigskip
    \indent
  }{\bigskip}
  
  \newenvironment{amuseplay}{
    \leftskip=\parindent
    \parindent=-\parindent
    \bigskip
    \indent
  }{\bigskip}
  
  \newcommand{\Slash}{\slash\hspace{0pt}}
  

METHODS

Text::Amuse::Output->new(document => $obj, format => "ltx")

Constructor. Format can be ltx or html, while document must be a Text::Amuse::Document object.

document

Accessor to the Text::Amuse::Document object (read-only, but you may call its method on that.

fmt

Accessor to the current format (read-only);

process

This method returns a array ref with the processed chunks. To get a sensible output you will have to join the pieces yourself.

We don't return a joined string to avoid copying large amounts of data.

  my $splat_pages = $obj->process(split => 1);
  foreach my $html (@$splat_pages) {
      # ...templating here...
  }

If the format is html, the option split may be passed. Instead of a arrayref of chuncks, an arrayref with html pages will be returned. Each page usually starts with an heading, and it's without <head> <body>. Footnotes are flushed and inserted at the end of each pages.

E.g.

  print @{$obj->process};

Return the formatted header as an hashref with key/value pairs.

INTERNAL METHODS

add_footnote($num)

Add the footnote to the internal list of found footnotes. Its existence is checked against the document object.

flush_footnotes

Return the list of footnotes found as a list of digits.

manage_html_footnote

blkstring

manage_regular($element_or_string)

Main routine to transform a string to the given format

inline_footnotes($string)

Inline the footnotes in the given string, accordingly to the current format.

safe($string)

Be sure that the strings passed are properly escaped for the current format, to avoid command injection.

escape_tex($string)

Escape the string for LaTeX output

escape_all_html($string)

Escape the string for HTML output

muse_inline_syntax_to_ltx

escape_html

remove_permitted_html

restore_permitted_html

muse_inline_syntax_to_tags

manage_paragraph

manage_header

add_to_table_of_contents

When we catch an header, we save it in the Output object, so we can emit the ToC. Level 5 is excluded as per doc.

It returns the numerical index (so you can inject the id).

reset_toc_stack

Clear out the list. This is called at the beginning of the main loop, so we don't collect duplicates over multiple runs.

table_of_contents

Emit the formatted toc (if any). Please note that this method works even for the LaTeX format, even if does not produce usable output.

This because we can test if we need to emit a table of contents looking at this without searching the whole output.

html_toc

The HTML formatted table of contents.

manage_verse

manage_comment

manage_table

manage_table_html

manage_table_ltx

_split_table_in_hash

manage_example

manage_hr

Put an horizontal rule

manage_newpage

If it's LaTeX, insert a newpage

linkify($link)

Here we see if it's a single one or a link/desc pair. Then dispatch

_url_safe_escape

HELPERS

Methods providing some fixed values

blk_table

image_re

Regular expression to match image links.

find_image($link)

Given the input string $link, return undef if it's not an image. If it is, return a Text::Amuse::Output::Image object.

url_re

footnote_re

br_hash

tag_hash

reverse_tag_hash

html_table_mapping