Line Breaking assignment |
||
![]() |
||
![]() |
![]() |
List of useful resources for Document Engineering and text encodingLine BreakingThis program should be done in a procedural language (Java, or another if you prefer). You need not deal with fonts and the system details of measurement, but your code will need to be abstracted away from these details. In particular, the input to your program will be a series of words to be formatted, separated by one of a small number of formatting codes. In order to simplify parsing, the syntax used will be an old-fashioned one -- the interested are encouraged to write a stylesheet to turn XML into this format. formatting examplewords, words, words, words, .p words in a new paragraphs more words in the same paragraph. Whitespace doesn't matter, it just counts as one space, just like in HTML. .p all command codes start with a period in the first line .br -500 a line break next to a .br item in the input has a penalty value specified on the break command. A negative penalty make a break likely. .br 1000 A break command like the one above makes a break very unlikely. a word beginning with a period anywhere but at the start of a line is not special, so that I can document the .ll command without it being formatted. .ll 1 20 says that line 1 of the following paragraph will be 20 units long. .ll 2 10 says that line 2 of the following paragraph will be 10 units long. .ll 66 sets the default length of paragraph lines to be 66. |