283:, that are appropriate places in which to begin a new line. The actual line break positions are picked from among the break opportunities by the higher level software that calls the algorithm, not by the algorithm itself, because only the higher level software knows about the width of the display the text is displayed on and the width of the glyphs that make up the displayed text.
764:"The reflow algorithm tries to keep the lines the same length but also tries to break at punctuation, and avoid breaking within a proper name or after certain connectives ("a", "the", etc.). The result is a file with a more "ragged" right margin than is produced by fmt or Text::Wrap but it is easier to read since fewer phrases are broken across line breaks."
36:
114:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
102:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
327:
in it. When the word isn't wrapped (i.e., isn't broken across lines), the soft hyphen isn't visible. But if the word is wrapped across lines, this is done at the soft hyphen, at which point it is shown as a visible hyphen on the top line where the word is broken. (In the rare case of a word that
780:"The detailed description of the model and the algorithm can be found on the paper "Breaking Paragraphs into Lines" by Donald E. Knuth, published in the book "Digital Typography" (Stanford, California: Center for the Study of Language and Information, 1999), (CSLI Lecture Notes, no. 78.)"; part of
223:
Alternatively, "soft return" can mean an intentional, stored line break that is not a paragraph break. For example, it is common to print postal addresses in a multiple-line format, but the several lines are understood to be a single paragraph. Line breaks are needed to divide the words of the
210:
A soft return or soft wrap is the break resulting from line wrap or word wrap (whether automatic or manual), whereas a hard return or hard wrap is an intentional break, creating a new paragraph. With a hard return, paragraph-break formatting can (and should) be applied (either
438:
SpaceLeft := LineWidth for each Word in Text if (Width(Word) + SpaceWidth) > SpaceLeft insert line break before Word in Text SpaceLeft := LineWidth - Width(Word) else SpaceLeft := SpaceLeft - (Width(Word) + SpaceWidth)
246:) between each paragraph. Formatting settings, such as first-line indentation or spacing between paragraphs, take effect where the carriage return marks the break. A non-paragraph line break, which is a soft return, is inserted using
215:
or vertical whitespace). Soft wrapping allows line lengths to adjust automatically with adjustments to the width of the user's window or margin settings, and is a standard feature of all modern text editors, word processors, and
480:, minimizes the sum of the squares of the lengths of the spaces at the end of lines to produce a more aesthetically pleasing result than the greedy algorithm, which does not always minimize squared space.
431:
that puts as many words on a line as possible, then moving on to the next line to do the same until there are no more words left to place. This method is used by many modern word processors, such as
435:
and
Microsoft Word. This algorithm always uses the minimum possible number of lines but may lead to lines of widely varying lengths. The following pseudocode implements this algorithm:
814:... The *really* interesting thing is how Adobe's algorithm differs from the Knuth–Plass algorithm. It must differ, since Adobe has managed to patent its algorithm (6,510,441)."
496:. In the Western Union system, each line was broken at the first space character to appear after the 58th character, or at the 70th character if no space character was found.
308:
The soft returns are usually placed after the ends of complete words, or after the punctuation that follows complete words. However, word wrap may also occur following a
781:
175:
is continuing on a new line when a line is full, so that each line fits into the viewable window, allowing text to be read from top to bottom without any horizontal
618:
260:
or via the menus, and is provided for cases when the text should start on a new line but none of the other side effects of starting a new paragraph are desired.
286:
The
Unicode character set provides a line separator character as well as a paragraph separator to represent the semantics of the soft return and hard return.
404:
171:, is breaking a section of text into lines so that it will fit into the available width of a page, window or other display area. In text display,
492:. This system used relays rather than programmable digital computers, and therefore needed a simple algorithm that could be implemented without
103:
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
115:
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
767:
58:
471:
220:. Manual soft breaks are unnecessary when word wrap is done automatically, so hitting the "Enter" key usually produces a hard return.
805:
685:
601:
84:
758:
Reference: "Breaking
Paragraphs into Lines", D.E. Knuth and M.F. Plass, chapter 3 of _Digital Typography_, CSLI Lecture Notes #78.
503:
in an unpublished 1977 memo describing his TeX typesetting system and later published in more detail by Knuth & Plass (1981).
379:) by extension, meaning words can, and tend to be, broken without any explicit indication that a word continues on the next line.
786:
202:
delimiters within paragraphs, and allows the display of text to adapt flexibly and dynamically to displays of varying sizes.
799:
843:
853:
630:
339:
Sometimes word wrap is undesirable between adjacent words. In such cases, word wrap can usually be blocked by using a
858:
66:
62:
46:
389:
word wrapping might not be desired within any compound words (when the text is flush left but only in some styles).
212:
823:
228:
195:, of breaking lines between words rather than within words, where possible. Word wrap makes it unnecessary to
680:, CSLI Lecture Notes, vol. 78, Stanford, California: Center for the Study of Language and Information,
267:
there is a <br> tag that has the same purpose as the soft return in word processors described above.
403:
punctuation may or may not follow rules similar to the above-mentioned special circumstances. It is up to
518:
263:
In text-oriented markup languages, a soft return is typically offered as a markup tag. For example, in
416:
848:
313:
815:
811:
718:
512:
488:
A primitive line-breaking feature was used in 1955 in a "page printer control unit" developed by
432:
344:
236:
681:
597:
591:
521: – Setting of text flow or image placement relative to a page, column, table cell, or tab
360:
710:
524:
428:
356:
333:
499:
The greedy algorithm for line-breaking predates the dynamic programming method outlined by
827:
364:
188:
762:
Text::Reflow - Perl module for reflowing text files using Knuth's paragraphing algorithm.
787:"Bridging the Algorithm Gap: A Linear-time Functional Program for Paragraph Formatting"
750:
674:
400:
232:
777:
558:
837:
722:
489:
368:
669:
651:
530:
500:
371:, but certain punctuation characters are not allowed to begin a new line. Japanese
217:
382:
Under certain circumstances, however, word wrapping is not desired. For instance,
593:
CJKV Information
Processing: Chinese, Japanese, Korean & Vietnamese Computing
701:
Knuth, Donald Ervin; Plass, Michael F (1981), "Breaking
Paragraphs into Lines",
655:
536:
493:
394:
324:
317:
312:
inside of a word. This is sometimes not desired, and can be blocked by using a
196:
192:
184:
419:. Depending on what needs to be optimized for, different algorithms are used.
800:
the reverse problem -- picking columns just wide enough to fit (wrapped) text
808:
by Simon
Pepping 2006. Extends the Knuth model to handle a few enhancements.
756:"tex_wrap": "Implements TeX's algorithm for breaking paragraphs into lines."
256:
249:
242:
176:
761:
714:
755:
578:
WORD JOINER should be used if the intent is to merely prevent a line break
17:
738:
276:
199:
771:
309:
819:
65:
external links, and converting useful links where appropriate into
376:
372:
279:
Line
Breaking Algorithm determines a set of positions, known as
264:
477:
351:
Word wrapping in text containing
Chinese, Japanese, and Korean
29:
386:
word wrapping might not be desired within personal names, and
328:
is meant to be wrappable by breaking it across lines but
336:
is put at the permitted breaking point(s) in the word.)
150:
fugiat nulla pariatur. Excepteur sint occaecat cupidatat
127:
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
367:, word wrapping can usually occur before and after any
323:
A word without hyphens can be made wrappable by having
154:
non proident, sunt in culpa qui officia deserunt mollit
54:
49:
may not follow
Knowledge (XXG)'s policies or guidelines
27:
Feature of continuing on a new line when a line is full
822:
compares the algorithms of various time complexities (
397:
software cannot handle either of the above scenarios.
299:* may be used to represent this semantic unambiguously
293:* may be used to represent this semantic unambiguously
146:
reprehenderit in voluptate velit esse cillum dolore eu
450:
is the remaining width of space on the line to fill,
806:"Knuth linebreaking elements for Formatting Objects"
130:
sed do eiusmod tempor incididunt ut labore et dolore
134:
magna aliqua. Ut enim ad minim veniam, quis nostrud
673:
138:exercitation ullamco laboris nisi ut aliquip ex ea
568:. Annex #14 (Proposed Update Unicode Standard): 2
239:, users are expected to type a carriage return (
124:
111:
100:
347:between the words, instead of regular spaces.
224:address into lines of the appropriate length.
427:A simple way to do word wrapping is to use a
304:Word boundaries, hyphenation, and hard spaces
8:
527: – Special character in text processing
515: – Special character in text processing
375:are treated the same way as Han Characters (
751:"Knuth & Plass line-breaking Revisited"
142:commodo consequat. Duis aute irure dolor in
812:"a Knuth–Plass-like linebreaking algorithm
533: – Glyph that separates written words
454:is the width of a single space character,
85:Learn how and when to remove this message
254:
247:
240:
549:
458:is the input text to iterate over and
789:by Oege de Moor, Jeremy Gibbons, 1997
596:, O'Reilly Media, Inc., p. 352,
7:
539: – Character in text processing
472:Knuth-Plass line-breaking algorithm
617:Harris, Robert W. (January 1956),
557:Heninger, Andy, ed. (2013-01-25).
393:Most existing word processors and
183:is the additional feature of most
25:
703:Software: Practice and Experience
559:"Unicode Line Breaking Algorithm"
34:
739:Unicode Line Breaking Algorithm
476:A different algorithm, used in
332:making a hyphen ever appear, a
320:, instead of a regular hyphen.
623:Western Union Technical Review
1:
768:adjusting the Knuth algorithm
778:Knuth's breaking algorithm.
875:
782:Google Summer Of Code 2006
629:(1): 37–42, archived from
619:"Keyboard standardization"
469:
405:line breaking rules in CJK
296:0x2029 PARAGRAPH SEPARATOR
744:
462:is a word in this text.
446:is the width of a line,
423:Minimum number of lines
715:10.1002/spe.4380111102
161:
118:
105:
794:Other word-wrap links
519:Typographic alignment
290:0x2028 LINE SEPARATOR
206:Soft and hard returns
844:Text editor features
417:optimization problem
415:Word wrapping is an
227:In the contemporary
158:anim id est laborum.
55:improve this article
854:Dynamic programming
590:Lunde, Ken (1999),
314:non-breaking hyphen
281:break opportunities
122:Hard coded newlines
67:footnote references
859:Unicode algorithms
826:2024-08-01 at the
802:(Archived version)
676:Digital Typography
513:Non-breaking space
466:Minimum raggedness
433:Libreoffice Writer
345:non-breaking space
237:Libreoffice Writer
770:to recognize the
745:Knuth's algorithm
566:Technical Reports
109:Without word wrap
95:
94:
87:
16:(Redirected from
866:
726:
725:
698:
692:
690:
679:
666:
665:
664:
648:
642:
640:
639:
638:
614:
608:
606:
587:
581:
580:
575:
573:
563:
554:
525:Zero-width space
461:
457:
453:
449:
445:
429:greedy algorithm
334:zero-width space
231:word processors
167:, also known as
159:
155:
151:
147:
143:
139:
135:
131:
128:
116:
90:
83:
79:
76:
70:
38:
37:
30:
21:
874:
873:
869:
868:
867:
865:
864:
863:
834:
833:
828:Wayback Machine
820:"Line breaking"
796:
747:
735:
730:
729:
709:(11): 1119–84,
700:
699:
695:
688:
668:
667:. Reprinted in
662:
660:
650:
649:
645:
636:
634:
616:
615:
611:
604:
589:
588:
584:
571:
569:
561:
556:
555:
551:
546:
509:
486:
474:
468:
459:
455:
451:
447:
443:
440:
425:
413:
353:
306:
273:
259:
252:
245:
208:
189:word processors
162:
157:
156:
153:
152:
149:
148:
145:
144:
141:
140:
137:
136:
133:
132:
129:
126:
123:
119:
113:
110:
106:
99:
91:
80:
74:
71:
52:
43:This article's
39:
35:
28:
23:
22:
15:
12:
11:
5:
872:
870:
862:
861:
856:
851:
846:
836:
835:
832:
831:
817:
809:
803:
795:
792:
791:
790:
784:
775:
765:
759:
753:
746:
743:
742:
741:
734:
733:External links
731:
728:
727:
693:
686:
643:
609:
602:
582:
548:
547:
545:
542:
541:
540:
534:
528:
522:
516:
508:
505:
485:
482:
470:Main article:
467:
464:
437:
424:
421:
412:
409:
391:
390:
387:
352:
349:
305:
302:
301:
300:
297:
294:
291:
272:
269:
233:Microsoft Word
207:
204:
121:
120:
108:
107:
98:With word wrap
97:
96:
93:
92:
47:external links
42:
40:
33:
26:
24:
14:
13:
10:
9:
6:
4:
3:
2:
871:
860:
857:
855:
852:
850:
847:
845:
842:
841:
839:
829:
825:
821:
818:
816:
813:
810:
807:
804:
801:
798:
797:
793:
788:
785:
783:
779:
776:
773:
772:"soft hyphen"
769:
766:
763:
760:
757:
754:
752:
749:
748:
740:
737:
736:
732:
724:
720:
716:
712:
708:
704:
697:
694:
689:
687:1-57586-010-4
683:
678:
677:
671:
670:Knuth, Donald
659:
658:
653:
652:Knuth, Donald
647:
644:
633:on 2015-08-03
632:
628:
624:
620:
613:
610:
605:
603:9781565922242
599:
595:
594:
586:
583:
579:
567:
560:
553:
550:
543:
538:
535:
532:
529:
526:
523:
520:
517:
514:
511:
510:
506:
504:
502:
497:
495:
491:
490:Western Union
483:
481:
479:
473:
465:
463:
436:
434:
430:
422:
420:
418:
410:
408:
406:
402:
398:
396:
388:
385:
384:
383:
380:
378:
374:
370:
369:Han character
366:
362:
358:
350:
348:
346:
342:
337:
335:
331:
326:
321:
319:
315:
311:
303:
298:
295:
292:
289:
288:
287:
284:
282:
278:
270:
268:
266:
261:
258:
251:
244:
238:
234:
230:
225:
221:
219:
218:email clients
214:
205:
203:
201:
198:
194:
190:
186:
182:
178:
174:
170:
169:word wrapping
166:
165:Line breaking
160:
117:
104:
89:
86:
78:
68:
64:
63:inappropriate
60:
56:
50:
48:
41:
32:
31:
19:
706:
702:
696:
675:
661:, retrieved
656:
646:
635:, retrieved
631:the original
626:
622:
612:
592:
585:
577:
570:. Retrieved
565:
552:
531:Word divider
501:Donald Knuth
498:
494:data buffers
487:
475:
441:
426:
414:
399:
392:
381:
354:
340:
338:
329:
325:soft hyphens
322:
307:
285:
280:
274:
262:
226:
222:
209:
193:web browsers
185:text editors
180:
172:
168:
164:
163:
125:
112:
101:
81:
72:
57:by removing
44:
537:Word joiner
395:typesetting
318:hard hyphen
849:Typography
838:Categories
663:2013-04-07
637:2013-04-07
544:References
452:SpaceWidth
341:hard space
75:March 2015
723:206508107
657:TEXDR.AFT
448:SpaceLeft
444:LineWidth
411:Algorithm
229:graphical
213:indenting
197:hard-code
181:Word wrap
177:scrolling
173:line wrap
59:excessive
18:Word wrap
824:Archived
672:(1999),
654:(1977),
572:10 March
507:See also
361:Japanese
484:History
357:Chinese
330:without
277:Unicode
271:Unicode
200:newline
53:Please
45:use of
721:
684:
600:
442:Where
365:Korean
363:, and
310:hyphen
191:, and
719:S2CID
562:(PDF)
377:Kanji
316:, or
257:Enter
250:Shift
243:Enter
682:ISBN
598:ISBN
574:2015
460:Word
456:Text
373:kana
275:The
265:HTML
235:and
711:doi
478:TeX
401:CJK
355:In
343:or
61:or
840::
830:).
717:,
707:11
705:,
627:10
625:,
621:,
576:.
564:.
407:.
359:,
255:↵
248:⇧
241:↵
187:,
179:.
774:.
713::
691:.
641:.
607:.
253:+
88:)
82:(
77:)
73:(
69:.
51:.
20:)
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.