knuthplass

package
v0.0.0-...-ae32867 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package knuthplass implements (in an early draft) a line breaking algorithm described by D.E. Knuth and M.F. Plass.

Definite source of information is of course

Computers & Typesetting, Vol. A & C.
http://www-cs-faculty.stanford.edu/~knuth/abcde.html

An approachable summary may be found in

http://defoe.sourceforge.net/folio/knuth-plass.html

BSD License

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreakParagraph

func BreakParagraph(cursor linebreak.Cursor, parshape linebreak.ParShape,
	params *linebreak.Parameters) ([]khipu.Mark, error)

BreakParagraph determines optimal linebreaks for a paragraph, depending on a given set of linebreaking parameters and the desired shape of the paragraph.

Paragraphs may be broken with different line counts. Only one of these will be optimal, and BreakParagraph will return that.

For a function to get solutions with different linecounts, see FindBreakpoints.

func FindBreakpoints

func FindBreakpoints(cursor linebreak.Cursor, parshape linebreak.ParShape, params *linebreak.Parameters,
	dotfile io.Writer) ([]int, map[int][]khipu.Mark, error)

FindBreakpoints finds all breakpoints for a paragraph for a given paragraph shape. Selecting the breakpoints is governed by a set of linebreak parameters. The paragraph's content is given as a khipu.Khipu, i.e. as a string of knots. Navigating the Khipu is done with a linebreak.Cursor, given as an argument.

If dotfile is given, the function outputs the intermediate breakpoint-graph in GraphViz DOT format (useful for debugging and illustrations).

Breaking a paragraph might be acceptable in more than one way, resulting in different counts of broken lines. This function returns all of the variants found. The first return value is a slice of integers, denoting the linecount variants, in decreasing order of linebreak quality. The second argument is a list of linebreaks for each linecount variant.

For a more convenient API, see BreakParagraph.

func NewKPDefaultParameters

func NewKPDefaultParameters() *linebreak.Parameters

NewKPDefaultParameters creates line-breaking parameters similar to (but not identical) to TeX's.

func T

func T() tracing.Trace

T traces to the core tracer.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL