jstewmc/rtf-token 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jstewmc/rtf-token

Composer 安装命令:

composer require jstewmc/rtf-token

包简介

Rich Text Format (RTF) tokens

README 文档

README

Rich Text Format (RTF) tokens.

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:

{\foo bar}

Tokens

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

  • 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.

Group

This library supports two group tokens: Group\Open and Group\Close. They have no properties:

namespace Jstewmc\RtfToken\Group;

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

Controls

This library supports control word and control symbol tokens.

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

Control words

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

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:

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:

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.

The "other" token has a single property, character:

namespace Jstewmc\RtfToken;

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

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

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

That's about it!

Author

Jack Clayton

Version

0.1.0, December 10, 2016

  • Initial release

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固