linebreak 1.1.2
Generates line breaking points based on Unicode® Standard Annex #14
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Unicode line breaking algorithm
This implements the Unicode line breaking algorithm from annex 14. The currently implemented version is based on the Unicode 7.0.0 standard and uses the table based approximate algorithm.
Citing from the standard:
Line breaking, also known as word wrapping, is the process of breaking a section of text into lines such that it will fit in the available width of a page, window or other display area. The Unicode Line Breaking Algorithm performs part of this process. Given an input text, it produces a set of positions called "break opportunities" that are appropriate points to begin a new line. The selection of actual line break positions from the set of break opportunities is not covered by the Unicode Line Breaking Algorithm, but is in the domain of higher level software with knowledge of the available width and the display size of the text.
This library has been ported from the CoffeeScript implementation by Devon Govett: linebreak
Example
import linebreak;
import std.algorithm : equal, map;
auto text = "Hello, world!\nThis is an (English) example.";
auto broken = text
.lineBreakRange
.map!(lb => lb.text);
assert(broken.equal([
"Hello, ", "world!\n", "This ", "is ", "an ", "(English) ", "example."
]));
- 1.1.2 released 3 years ago
- s-ludwig/linebreak
- MIT
- Copyright © 2014-2016 Devon Govett, Copyright © 2018 Sönke Ludwig
- Authors:
- Dependencies:
- none
- Versions:
-
1.1.2 2021-Jan-14 1.1.1 2020-Apr-16 1.1.0 2018-Apr-05 1.0.0 2018-Apr-04 ~master 2021-Jan-14 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
1 downloads this month
-
245 downloads total
-
- Score:
- 1.0
- Short URL:
- linebreak.dub.pm