The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Text::Multi::Block::Code - Text::Multi processor for code blocks

SYNOPSIS

  {{{ Code lang=C<< <language> >> }}}

DESCRIPTION

This subclass of Text::Multi::Block implements a formatter for various types of source code using the Syntax::Highlight::Engine::Kate code coloring library.

PARAMETERS

These are parameters that can be set in the Text::Multi tag in your text document, to provide additional information to formatter modules, and potentially to influence how the content is rendered. Also see "PARAMETERS" in Text::Multi::Block for inherited parameters that can be used by this formatter.

language

Sets the language that the code should be rendered as. The language setting affects things like what words are considered to be keywords. See "PLUGINS" in Syntax::Highlight::Engine::Kate for a list of supported languages.

Use as a class method to set the default for all Text::Multi::Block::Code blocks.

  Text::Multi::Block::Code->language( 'Bash' );

The default value is 'Perl'.

lang

The 'language' parameter can also be abbreviated 'lang'.

starting_line_number( $number );

Set to a numeric value greater than 0 in order to include line numbers for the code listing. The value you set it to will be the number of the first line. When set to 0, line numbering will not be included. The default value 0.

Use as a class method to set the default for all Text::Multi::Block::Code blocks.

  Text::Multi::Block::Code->starting_line_number( 1 );

line( $number );

The 'starting_line_number' parameter can also be abbreviated 'line'.

tab_width( $number );

Set to an integer value to indicate how many spaces a tab should be replaced with (tabs are actually replaced with a series of '&nbsp;' entities, rather than actual spaces.)

The default value is 4. Use as a class method to set the default for all Text::Multi::Block::Code blocks.

  Text::Multi::Block::Code->tab_width( 8 );

tabwidth( $number );

The 'tab_width' parameter can also be abbreviated 'tabwidth'.

INTERNAL METHODS

as_html()

See "as_html" in Text::Multi::Block.

wrap_classes()

This method is overloaded to return a class including the language being rendered in addition to the values documented in "wrap_classes" in Text::Multi::Block. For example, when language=perl, the overloaded method adds 'text-multi-code-perl' to the list of classes returned.

SEE ALSO

Text::Multi

Text::Multi::Block

Syntax::Highlight::Engine::Kate

http://www.jasonkohles.com/software/Text-Multi/

AUTHOR

Jason Kohles <email@jasonkohles.com>.

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Jason Kohles

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.