Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for parsing w:sym tags in Word2007 reader #2805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
Copilot wants to merge 2 commits into master
base: master
Choose a base branch
Loading
from copilot/fix-2802

Conversation

Copy link

@Copilot Copilot AI commented Jul 26, 2025
edited
Loading

This PR adds support for parsing w:sym (symbol) tags in DOCX files, which was previously ignored by PHPWord's Word2007 reader.

Problem

When reading DOCX files containing symbol elements (like special characters from Wingdings or Symbol fonts), PHPWord would skip these w:sym tags entirely, resulting in missing content in the parsed document.

Solution

Added handling for w:sym nodes in the readRunChild() method of AbstractPart.php. The implementation:

  1. Extracts the w:font and w:char attributes from w:sym elements
  2. Formats them as readable text in the format [{font},{char}]
  3. Adds the formatted text to the document while preserving font and paragraph styling

Example

A DOCX file containing:

<w:r>
 <w:t>XXXX </w:t>
</w:r>
<w:r>
 <w:sym w:font="Wingdings 2" w:char="00A3"/>
</w:r>

Will now produce the text output:

XXXX [Wingdings 2,00A3]

Changes

  • Core functionality: Added 6 lines to handle w:sym nodes in AbstractPart.php
  • Test coverage: Added comprehensive test testReadSymbol() to verify the functionality works correctly with multiple symbols and edge cases
  • Edge cases: Handles missing or empty attributes gracefully

The implementation is minimal and surgical, adding only the necessary functionality without modifying existing code paths.

Fixes #2802.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHPOffice/Math/zipball/fc31c8f57a7a81f962cbf389fd89f4d9d06fc99a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/oLUyoc /usr/bin/composer install --no-dev (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Progi1984 <1533248+Progi1984@users.noreply.github.com>
@Copilot Copilot AI changed the title (削除) [WIP] how to parse docx file "w:sym" tag? (削除ここまで) (追記) Add support for parsing w:sym tags in Word2007 reader (追記ここまで) Jul 26, 2025
@Copilot Copilot AI requested a review from Progi1984 July 26, 2025 17:17
Copilot finished work on behalf of Progi1984 July 26, 2025 17:17
Copy link

Coverage Status

coverage: 96.757%. remained the same
when pulling 1904d0e on copilot/fix-2802
into 0ab0b49 on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Progi1984 Progi1984 Awaiting requested review from Progi1984

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

how to parse docx file "w:sym" tag?

AltStyle によって変換されたページ (->オリジナル) /