承接 wiki-connect/parsewiki 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wiki-connect/parsewiki

Composer 安装命令:

composer require wiki-connect/parsewiki

包简介

A library that helps parse wikitext template data

README 文档

README

A powerful PHP library for parsing MediaWiki-style content from raw wiki text.

📚 Overview

This library allows you to extract:

  • Templates (single, multiple, nested)
  • Internal wiki links
  • External links
  • Citations (references)
  • Categories (with or without display text)
  • Tables (complete MediaWiki table syntax support) Perfect for handling wiki-formatted text in PHP projects.

🗂️ Project Structure

  • ParserTemplates: Parses multiple templates.
  • ParserTemplate: Parses a single template.
  • ParserInternalLinks: Parses internal wiki links.
  • ParserExternalLinks: Parses external links.
  • ParserCitations: Parses citations and references.
  • ParserCategories: Parses categories from wiki text.
  • ParserTable: Parses MediaWiki tables with full syntax support.
  • DataModel classes:
    • Attribute
    • Citation
    • ExternalLink
    • InternalLink
    • Parameters
    • Template
    • Table
    • Cell
    • LegacyTableCompatibility (backward compatibility trait)
  • tests/: Contains PHPUnit test files:
    • ParserCategoriesTest
    • ParserCitationsTest
    • ParserExternalLinksTest
    • ParserInternalLinksTest
    • ParserSectionTest
    • ParserTableTest (39 tests)
    • ParserTemplatesTest
    • ParserTemplateTest
    • DataModel tests:
      • AttributeTest
      • CellTest
      • ParametersTest
      • TableTest (46 tests with 106 assertions)
      • TemplateTest
  • demo/: Live HTML testing interface:
    • index.html - Interactive demo frontend
    • parser.php - Backend API for real-time parsing

🚀 Features

  • ✅ Parse single and multiple templates.
  • ✅ Support nested templates.
  • ✅ Handle named and unnamed template parameters.
  • ✅ Extract internal links with or without display text.
  • ✅ Extract external links with or without labels.
  • ✅ Parse citations including attributes and special characters.
  • ✅ Parse categories, support custom namespaces, handle whitespaces and special characters.
  • Full MediaWiki table syntax support with advanced features:
    • Multi-line cell content (paragraphs, lists, complex markup)
    • Rowspan and colspan attributes with proper span matrix handling
    • HTML wrapper detection (automatically strips <div> wrappers)
    • Accessibility support (scope attributes for screen readers)
    • Complex attribute parsing (style, alignment, etc.)
    • Nested table support
    • Caption and header attributes

🧩 Wikitext Features Support

FeatureRead ✅Modify ✏️Replace 🔄
Templates✅ Yes✅ Yes✅ Yes
Parameters✅ Yes✅ Yes✅ Yes
Citations✅ Yes✅ Yes✅ Yes
Citations>Attributes✅ Yes✅ Yes✅ Yes
Internal Links✅ Yes
External Links✅ Yes
Categories✅ Yes
Tables✅ Yes✅ Yes✅ Yes
Tables>Attributes✅ Yes✅ Yes✅ Yes
Tables>Cells✅ Yes✅ Yes✅ Yes
Tables>Headers✅ Yes✅ Yes✅ Yes
Tables>Captions✅ Yes✅ Yes✅ Yes
Tables>Rowspan/Colspan✅ Yes✅ Yes✅ Yes
Tables>Multi-line✅ Yes✅ Yes✅ Yes
Tables>HTML Wrappers✅ Yes✅ Yes✅ Yes
Tables>Nested✅ Yes
HTML Tags
Parser Functions
Sections
Magic Words

🟡 Note: Some features are partially supported or under development. Contributions are welcome!

📋 Table Usage Examples

Basic Table Parsing

use WikiConnect\ParseWiki\ParserTable;

$wikitext = <<<WIKI
{| class="wikitable"
|+ Table Caption
|-
! Header 1 !! Header 2
|-
| Cell 1 || Cell 2
|-
| Cell 3 || Cell 4
|}
WIKI;

$parser = new ParserTable($wikitext);
$table = $parser->parse();

// Access table properties
echo $table->getCaption(); // "Table Caption"
echo $table->getAttributes()['class']; // "wikitable"

// Access headers
$headers = $table->getHeaders();
echo $headers[0]->getContent(); // "Header 1"

// Access data
$rows = $table->getRows();
echo $rows[0][0]->getContent(); // "Cell 1"

Advanced Table Features

// Table with attributes, spans, and accessibility
$complexTable = <<<WIKI
{| class="wikitable" style="width: 100%;"
! scope="col" colspan="2" | Product Info
! scope="col" | Price
|-
! scope="row" | Bread
| 2 loaves
| style="text-align: right;" | $3.50
|-
| rowspan="2" | Dairy
| Milk (1 gallon)
| align="right" | $4.25
|}
WIKI;

$parser = new ParserTable($complexTable);
$table = $parser->parse();

// Check spans
$headers = $table->getHeaders();
echo $headers[0]->getColSpan(); // 2
echo $headers[0]->getScope(); // "col"

// Check alignment
$rows = $table->getRows();
echo $rows[0][2]->getAlign(); // "right"

Multi-line Cell Content

// Table with complex multi-line content
$multiLineTable = <<<WIKI
{|
|Lorem ipsum dolor sit amet,
consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt
ut labore et dolore magna aliquyam erat.

At vero eos et accusam et justo duo dolores
et ea rebum. Stet clita kasd gubergren.
|
* Lorem ipsum dolor sit amet
* consetetur sadipscing elitr
* sed diam nonumy eirmod tempor invidunt
|}
WIKI;

$parser = new ParserTable($multiLineTable);
$table = $parser->parse();

// Access multi-line content
$rows = $table->getRows();
echo $rows[0][0]->getRawContent(); // Full paragraph content
echo $rows[0][1]->getRawContent(); // List content with bullets

HTML Wrapper Support

// Parser automatically handles HTML wrappers
$wrappedTable = <<<HTML
<div class="noresize">
{| class="wikitable"
! colspan="6" |Shopping List
|-
| rowspan="2" |Bread & Butter
| Pie
| Buns
|}
</div>
HTML;

$parser = new ParserTable($wrappedTable);
$table = $parser->parse(); // Automatically strips <div> wrapper

// Access span attributes
$headers = $table->getHeaders();
echo $headers[0]->getAttributes()['colspan']; // "6"

$rows = $table->getRows();
echo $rows[0][0]->getAttributes()['rowspan']; // "2"

🌐 Demo Interface

The library includes HTML demo interface files for testing:

  • demo/index.html - Interactive frontend interface
  • demo/parser.php - Backend API for parsing

Demo Features:

  • Real-time parsing for all parser types
  • Tabbed output (Parsed Data, JSON, Methods)
  • Example library with pre-built syntax examples
  • Responsive design for desktop and mobile
  • Statistics display (cell counts, attributes, etc.)
  • Error handling with detailed messages

Supported Parsers in Demo:

  • Templates Parser
  • Single Template Parser
  • Table Parser (with full span and multi-line support)
  • Internal Links Parser
  • External Links Parser
  • Citations Parser
  • Categories Parser
  • Sections Parser

🆕 Recent Enhancements

Table Parser Improvements (2025)

  • Multi-line cell support: Handles paragraphs, lists, and complex content spanning multiple lines
  • Rowspan/colspan detection: Proper span matrix handling for advanced table layouts
  • HTML wrapper stripping: Automatically detects and removes <div>, <span>, and other HTML wrappers
  • Enhanced attribute parsing: Support for complex CSS styles and accessibility attributes
  • Content consistency: Unified getRawContent() and getContent() methods across all data models
  • 100% MediaWiki compatibility: Tested against all official MediaWiki table examples

Testing & Development

  • Comprehensive test suite: 169 tests with 533 assertions (100% success rate)
  • TableTest.php: 46 dedicated tests for Table data model and LegacyTableCompatibility
  • Live demo interface: Real-time testing with JSON output and method documentation
  • Official examples: Validated against MediaWiki.org documentation examples

⚙️ Requirements

  • PHP 8.0 or higher
  • PHPUnit 9 or higher

💻 Installation

composer require wiki-connect/parsewiki

Make sure you have proper PSR-4 autoloading for the WikiConnect\ParseWiki namespace.

🧪 Running Tests

vendor/bin/phpunit tests

wiki-connect/parsewiki 适用场景与选型建议

wiki-connect/parsewiki 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「parser」 「mediawiki」 「wikitext」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wiki-connect/parsewiki 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wiki-connect/parsewiki 我们能提供哪些服务?
定制开发 / 二次开发

基于 wiki-connect/parsewiki 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2023-12-03