This is only the definition. I'm working on the implementation.
Text Formatting Language (TFL, or Teflon).
The language uses several markup tags to provide facilities for line wrapping, justification, centering, and indentation.
Whitespace handling:
Whitespace at the beginning of a line is only modified by removing tabs according to the value of the <tab size> tag (see below). It is considered embedded indentation, and wrapped lines duplicate it.
Whitespace between words is left untouched. Only spacing is only added, never removed, except for spacing at the end of lines, which is always removed.
Tag expansion:
With two exceptions, no tag generates output. There's an exception where if a line consists solely of tags and no other whitespace (excluding the newline) or non-whitespace character is on the line, the line isn't outputted as a blank line, and is instead discarded.
Line wrapping tags:
<wrap:%>
Wraps text at the given column number. If not specified, the default is 79.
Justification tags:
<j></j>
Justifies text.
Only entire lines can be justified. Placing the opening tag in the middle of a line has the same effect as placing it at the beginning.
If used while a center block is open, the block is cancelled for the current line and closed, and the justification block is opened.
Centering tags:
<c></c>
Centers text.
Only entire lines can be centered. Placing the opening tag in the middle of a line has the same effect as placing it at the beginning.
If used while a justification block is open, the block is cancelled for the current line and closed, and the centering block is opened.
Indentation tags:
<tab size:%>
Sets the size of tabs. Tabs will be replaced in the output by no more than this many spaces (the exact number depends on the column where the tab is located, obviously).
Default is 8.
<indent size:%>
Sets the size that will be used by the <indent> and <+indent> tags.
Default is 4.
<+indent[:$]>
If the string parameter isn't provided, add one indentation level according to <indent size>.
If it is provided, add the string to the indentation stack.
<+bullet:$>
Same as <+indent>, but behaves differently with split lines:
<+indent:* >Only entire lines can be centered. Placing the opening tag in the middle of a line has the same effect as placing it at the beginning.
If used while a justification block is open, the block is cancelled for the current line and closed, and the centering block is opened. |
1 2 3 4
|
* Only entire lines can be centered. Placing the opening tag in the middle of a
* line has the same effect as placing it at the beginning.
* If used while a justification block is open, the block is cancelled for the
* current line and closed, and the centering block is opened.
|
<+bullet:* >Only entire lines can be centered. Placing the opening tag in the middle of a line has the same effect as placing it at the beginning.
If used while a justification block is open, the block is cancelled for the current line and closed, and the centering block is opened. |
1 2 3 4
|
* Only entire lines can be centered. Placing the opening tag in the middle of a
line has the same effect as placing it at the beginning.
* If used while a justification block is open, the block is cancelled for the
current line and closed, and the centering block is opened.
|
<-indent>
Pops one indentation level from the indentation stack if possible, otherwise print an error.
</indent>
Remove all indentation levels.
Other tags:
<<> <>>
Put a < or a > in the output, respectively.
<allcaps></allcaps>
The output is written in upper case only.
<end>
Stop processing. The rest of the input is directly copied to the output.
Example - Generating a BSD licence (must first be passed through m4):
define(COPYRIGHT,`2009')dnl
define(AUTHOR,`J. Random Hacker')dnl
define(PRODUCT,`void multiplier')dnl
<j><indent:* >
Copyright (c) COPYRIGHT, AUTHOR
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
<indent size:4>
<+indent><+bullet:* >
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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.
The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
<-indent><-indent>
<allcaps>
This software is provided by AUTHOR "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 AUTHOR 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.
</allcaps></j>
|