urbanmonastics/sourcetextlibrary

一种简单的方式来加载、读取和展示来自各种源文本库的文本。

dev-release 2022-01-31 19:37 UTC

This package is auto-updated.

Last update: 2024-09-05 21:31:18 UTC


README

Build Status Total Downloads Version License

一种简单的方式来加载、读取和展示来自各种源文本库的文本。

这是一个源文本解析器库的配套库。

特性

  • 快速加载一个或多个源文本库
  • 导航到所需的文本或段落,并渲染它们以供显示。

添加到项目中

安装composer包

composer require UrbanMonastics/SourceTextLibrary

示例用法

在最简单的方法中,您可以传递要解析的文本。

$SourceTextLibrary = new /UrbanMonastics/SourceTextLibrary();

echo $SourceTextLibrary->text("Hello *Source Parser*!");  # prints: <p>Hello <em>Source Parser</em>!</p>

您还可以利用源文本的结构。

$SourceTextLibrary = new SourceTextLibrary();

// Load the source data into the parser
$Source = json_decode( file_get_contents('path/to/source.json'), true );
$SourceTextLibrary->loadSource( $Source );

$SourceTextLibrary->loadText();

echo $SourceTextLibrary->text("Hello *Source Parser*!");  # prints: <p>Hello <em>Source Parser</em>!</p>

// Clear the loaded Source and Texts - without altering other options
$SourceTextLibrary->clearSource();