Class TeX::Hyphen
In: lib//tex/hyphen.rb
lib//tex/hyphen/german.rb
lib//tex/hyphen/czech.rb
Parent: Object

Introduction

TeX::Hyphen -- hyphenate words using TeX's patterns

Usage

  require 'tex/hyphen'
  hyp = TeX::Hyphen.new(:file => 'hyphen.tex', :style => 'czech',
                        :leftmin => 2, :rightmin => 2)
  hyp = TeX::Hyphen.new

  word = "representation"
  points = hyp.hyphenate(word)  #=> [3, 5, 8, 10]
  puts hyp.visualize(word)      #=> rep-re-sen-ta-tion

Description

Constructor new() creates a new Hyphen object and loads the file with patterns into memory. Then you can ask it for hyphenation of a word by calling a method of this object. If no file is specified, the default Donald E. Knuth's hyphen.tex, that is included in this module, is used instead.

Copyright:Copyright (c) 2003 Martin DeMello and Austin Ziegler
Version:0.2
Based On:Perl's TeX::Hyphen [search.cpan.org/author/JANPAZ/TeX-Hyphen-0.140/lib/TeX/Hyphen.pm] Copyright (c) 1997--2002 Jan Pazdziora
Licence:Ruby's
Methods
hyphenate    hyphenate_to    new    visualise   
Attributes
:min_left  [RW] 

Allows modification of the minimal starting substring for hyphenation.

:min_right  [RW] 

Allows modification of the minimal ending substring for hyphenation.

Classes and Modules
Module TeX::Hyphen::Czech
Module TeX::Hyphen::German
Public Class methods
new(arg = nil, &block)

A TeX hyphenation object can be constructed using a few different calling methods. Any method may also take a constructor block, allowing direct access to @file, @style, @min_left, and @min_right.

arg may be one of Array, Hash, String, or nil:

Array
A four-element array in the form of: [file, style, min_left, min_right]
Hash
A hash with the following keys:

:file (or: 'file')

:style (or: 'style')

:min_left (or: :leftmin, 'min_left', 'leftmin')

:min_right (or: :rightmin, 'min_right', 'rightmin')

String
This corresponds to @file.

The parameters are:

Reference:"Object Construction and Blocks" <www.pragmaticprogrammer.com/ruby/articles/insteval.html>
Public Instance methods
hyphenate(word)

Returns a list of places where the word can be divided, as

  hyp.hyphenate('representation')

returns [3, 5, 8, 10].

visualise(word)

Returns a visualization of the hyphenation points, so:

  hyp.visualize('representation')

should return rep-re-sen-ta-tion, at elast for English patterns.

hyphenate_to(word, size)

This function will hyphenate a word