定制 writecrow/highlighter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

writecrow/highlighter

最新稳定版本:2.0.3

Composer 安装命令:

composer require writecrow/highlighter

包简介

Highlights words/phrases per specified parameters

README 文档

README

A PHP library for creating a highlighted excerpt a provided list of tokens in a provided text string.

Basic usage in an application

The included index.php file contains a generation form demo.

Make your code aware of the Highlighter class via your favorite method (e.g., use writecrow\Highlighter\HighlightExcerpt;)

print HighlightExcerpt::highlight('Round the rugged rock,' ['the']);
// Will print 'Round <mark>the</mark> rugged rock'

print HighlightExcerpt::highlight('Round the rugged rock,' ['the', 'rock']);
// Will print 'Round <mark>the</mark> rugged <mark>rock</mark>'

print HighlightExcerpt::highlight('Round the rugged rock,' ['ro', '"round"']);
// Will print 'Round the rugged rock', since `ro` is present, 
// but only a word partial,
// and `round` is present, but double-quotes indicate case-sensitivity
// so `round` != `Round`

Advanced behaviors

The excerpt highlighter will:

  • Default to case-insensitive highlighting for a word (e.g., 'the')
  • Become case-sensitive if the token is wrapped in double quotes (e.g. '"The"')
  • Not highlight partial word matched (e.g., 'the' will not highlight therefore)
  • Given multiple tokens passed to be highlighted, will create shorter, concatenated excerpts from the text which overall try to honor the length parameter specified (see below)
  • Produce excerpts that start/end on word boundaries

Length

Pass a 3rd parameter, an integer, to the function to specify the desired length of the excerpt.

print HighlightExcerpt::highlight('Round the rugged rock,' ['the'], 300);
// Would limit the excerpt to 300 characters

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固