Applications

RightFields 1.21

Spam Prevention

TinyTuring 1.02

Template Tags

CheckLinks 1.2

Collect 1.2

Columnize 1.11

Compare 1.1

DateTags 2.3

DaylightOrStandard 1.1

DropCap 1.1

FilterCategories 1.1

FirstNWords 1.3

GetXML 1.1

Glue 1.1

IfModified 1.4

Loop 1.1

TextWrap 1.1



Support staggernation.com's plugin development

TextWrap Plugin for Movable Type

Current version: 1.1 (7/12/04)

About the TextWrap Plugin

This Movable Type plugin implements template tags and a global tag attribute for displaying text wrapped into lines of a specified length.

Installation

To install the TextWrap plugin, upload the file TextWrap.pl to the plugins directory within your Movable Type directory. If you do not already have a plugins directory, create one before uploading the file. For more information about Movable Type plugins, see the documentation.

The TextWrap plugin requires the Perl module Text::Wrap, which is a standard module that should be included in any Perl installation.

Support

Please use the support forums for all support requests, bug reports, feature requests, questions, and comments regarding this plugin.

MTTextWrap

MTTextFill

These two container tags display their contents broken into lines of the specified length, with the breaks placed between words.

The difference between the two is that MTTextWrap leaves whitespace within the text alone, treating the whole block of text as a single paragraph, while MTTextFill divides the text into paragraphs, which it identifies as a line break followed by whitespace (a tab, a space, or another line break).

The tags take the following attributes:

  • columns="N"
    The length, in characters, to which the lines should be wrapped. The default is 72.
  • initial_tab="string"
    If you pass this attribute, the tag will place string before the first line of each paragraph.
  • subsequent_tab="string"
    If you pass this attribute, the tag will place string before each line after the first line of each paragraph.

Since web browsers ignore whitespace, simply wrapping the text won't alter the display of your page (unless the text is within a <pre> tag). If you want something to appear wrapped on a web page, you can include HTML for line breaks or paragraph breaks in the _tab attributes. You must use &lt; and &gt; instead of angle brackets in any HTML tags you pass. The following code will display your entry, wrapped to 40 characters, with line breaks:

<MTTextWrap initial_tab="&lt;br&gt;" subsequent_tab="&lt;br&gt;" columns="40">
 <$MTEntryBody$>
 <$MTEntryMore$>
</MTTextWrap>

wrap

This global tag attribute lets you apply text wrapping to any tag. It is provided as a simpler alternative to the MTTextWrap container tag, as long as you don't need the _tab functionality. Simply pass wrap="N" to any tag to wrap the output of the tag to N characters.

The TextWrap plugin can be used in conjunction with the Loop plugin to display wrapped text with line numbers, as in the following example:

<MTEntries category="Code">
 <code><MTLoop values="[MTEntryBody convert_breaks='0' wrap='80']" delimiter="\n">
  <$MTLoopN$>: <$MTLoopValue$><br>
 </MTLoop></code>
</MTEntries>

Version History

1/27/04 - version 1.0 released


The End As I Know It: A Novel of Millennial Anxiety, by staggernation.com proprietor Kevin Shay, is now available in paperback.

Please visit kshay.com for more information.