2017 © Pedro Peláez
 

library rtf-token

Rich Text Format (RTF) tokens

image

jstewmc/rtf-token

Rich Text Format (RTF) tokens

  • Saturday, December 10, 2016
  • by Jstewmc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 33 % Grown

The README.md

rtf-token

Rich Text Format (RTF) tokens., (*1)

namespace Jstewmc\RtfToken;

$open    = new Group\Open();
$control = new Control\Word('foo');
$text    = new Text('bar');
$close   = new Group\Close();

echo $open . $control . $text . $close;

The example above would output the following:, (*2)

{\foo bar}

Tokens

This library includes tokens for the Rich Text Format (RTF) language including:, (*3)

  • open-group (i.e., {),
  • close-group (i.e., }),
  • control word (e.g., \b),
  • control symbol (e.g., \*),
  • text (e.g., foo), and
  • other (e.g., \0).

The properties of each token differ, but all tokens implement the _toString() magic method., (*4)

Group

This library supports two group tokens: Group\Open and Group\Close. They have no properties:, (*5)

namespace Jstewmc\RtfToken\Group;

(string) (new Open());   // returns "{"
(string) (new Close());  // returns "}"

Controls

This library supports control word and control symbol tokens., (*6)

By default, control tokens are space-delimited. However, this can be turned off using the setIsSpaceDelimited() method., (*7)

Control words

The control word token has a word and (optional) integer parameter property:, (*8)

namespace Jstewmc\RtfToken\Control;

$word = new Word('b', 0);

$word->getWord();       // returns "b"
$word->getParameter();  // returns 0

(string) $word;  // returns "\b0 "

$word->setIsSpaceDelimited(false);

(string) $word;  // returns "\b0" (note, no space)

Control symbol

The control symbol token has a symbol and mixed parameter property:, (*9)

namespace Jstewmc\RtfToken\Control;

$symbol = new Symbol('\'', 99);

$symbol->getSymbol();     // returns "'"
$symbol->getParameter();  // returns 99

(string) $symbol;  // returns "\'99 "

$symbol->setIsSpaceDelimited(false);

(string) $symbol;  // returns "\'99" (note, no space)

Text

The text token has a single property, text:, (*10)

namespace Jstewmc\RtfToken;

$text = new Text('foo');

$text->getText();  // returns "foo"

(string) $text;  // returns "foo"

Other

The "other" token exists for any character that isn't an open-group, close-group, control word, control symbol, or text token. Usually, this includes special characters like line-feeds ("\n"), carriage-returns ("\r"), etc., (*11)

The "other" token has a single property, character:, (*12)

namespace Jstewmc\RtfToken;

$other = new Other("\n");

$other->getCharacter();  // returns "\n"

(string) $other;  // returns "\n"

That's about it!, (*13)

Author

Jack Clayton, (*14)

Version

0.1.0, December 10, 2016

  • Initial release

The Versions

10/12 2016

dev-master

9999999-dev

Rich Text Format (RTF) tokens

  Sources   Download

MIT

The Development Requires

by Jack Clayton

php text token format rtf rich

10/12 2016

v0.1.0

0.1.0.0

Rich Text Format (RTF) tokens

  Sources   Download

MIT

The Development Requires

by Jack Clayton

php text token format rtf rich