joelwenger/textspecial

TextSpecial 是一个用于处理多列的私有标记语言的轻量级解析类。

dev-master 2022-07-04 14:32 UTC

This package is auto-updated.

Last update: 2024-09-25 11:49:29 UTC


README

描述

TextSpecial 是一个用于解析私有但简单的标记语言,可以处理多列的类。未使用CSS框架,适用于小型项目中的简单、快速和方便使用。

要求

  • PHP >= 5.6

安装

composer require joelwenger/textspecial

基本用法

首先是一些设置

<?php

# use this namespace
use joelwenger\textspecial\src\TextSpecial;

# When installed via composer
require  __DIR__.'/vendor/autoload.php';

# Instantiate class
$textSpecial = new TextSpecial();

# multiple settings at once, not required
$textSpecial->setSettings( [
    'debug' => FALSE,
    'pathimg' => 'img/',
    'font_family' => 'Verdana,Arial,Helvetica,sans-serif',
    'color' => '#003388',
    'background' => '#ffffff',
    'table_title_bg_color' => '#888888',
    'table_title_text_color' => '#ffffff',
    'table_td_bg_color' => '#cccccc',
    'table_td_text_color' => '#000000',
    'code_text_color' => '#2e6e3c',
    'code_bg_color' => '#cccccc',
    'marking_color' => '#ff0000',
] );

// or single setting
$textSpecial->setSetting( 'color', '#003388');

// now read markup from file
$textSpecial->setFile( 'example.txt' );

// or get markup from string
$textSpecial->setText( 'c:9
h1u:title
p:Lorem ipsum dolor sit amet, ...' );

然后是输出

<!DOCTYPE html>

<html lang='de'>
<head>
    <title>any title</title>
    <meta http-equiv='content-type' content='text/html; charset=utf-8'>
    <style><?= $textSpecial->getCSS() ?></style>
</head>
<body>
<?= $textSpecial->getHtml() ?>
</body>
</html>

完成

标记语言

如示例中所述。其他选项肯定会陆续推出。

@待办事项

  • 表单创建
  • 使用 Bootstrap 5
  • 导出为单个文件 Html 或 MHTML
  • 解析 URL、电子邮件地址等。
  • 等等 ...

许可证

TextSpecial 在 MIT 许可证下发布。