-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Feature: Ruby (phonetic guide) text - Word2007 Read/Write, HTML Read/Write, RTF write, ODT basic write #2727
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a wonderful good job.
Could you add a Sample for this new feature ?
Do you only need in Word2007 ? (not in another formats ?)
I've added a new sample -
I only need Word2007 writing personally, but I went ahead and added HTML writing support, too, since I might need that later and to demonstrate how that works. (Reading should be possible, I think, but looking at the code in ODT documents seem to support ruby text (see below file for sample), but the <style> is written in an interesting way, and I'm not sure how to handle that. A future PR by someone else could address ODT reading/writing. It's probably pretty straightforward at this point, but I'm not sure how to do it, so I'll let someone else tackle it. For PDF output, If someone wanted RTF output (another format I am unfamiliar with), my guess is that writing ruby text in the Again, I'll let someone else in another PR or worker handle those since I am not needing them and no one else has ever even asked for ruby support in this lib. :) Someone else who is more familiar with reading/writing ODT as well as writing PDF/RTF can probably handle things faster than I can at this point, anyway. Thank you for your time and managing this lib, etc! 😄 |
Moved to parent AbstractElement so other classes could make use of it
I went ahead and updated the PR to add:
I am not planning on sneaking in native ODT support later 😅 Someone else can do that if they ever need it in the future. At least for now, ODT files now don't totally ignore ruby elements, which is an improvement to before. So this PR is ready to go. EDIT: Have used this PR in my intended project now and it works just as expected. Am able to write a full, 10+ page doc with ruby text and formatting, no problem, and then print that Word doc to PDF via Word itself. Sometimes Word gets upset if you choose the wrong font, but that's a Word problem, not this lib. |
…ature/ruby-text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment and it will be ok.
Tests have been added. Thanks again. |
Thank you for your wonderful contribution, @Deadpikle 🎉 |
Description
Right now, PHPWord does not support ruby text elements (phonetic guides) at all. You can see some documentation (of a sort) on this type of element here: https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.ruby?view=openxml-3.0.1 and some how-to-use here
A ruby (phonetic guide) element allows you to do things like this:
This PR adds both reading and writing support for ruby elements to
Word2007
files. Basic text support has been checked along with Titles. Other elements may or may not be supported at this time (in other words, I didn't test literally every element with ruby); as long as the code eventually gets intoreadRunChild
, the ruby should be read properly.Please note: This is my first contribution to this repository. I may have missed something when trying to match current style guidelines, etc. Please correct me and point me in the right direction if needed. Thank you!
(Update: This PR now supports reading/writing HTML as well as writing support for RTF and basic writing support for ODT.)
Checklist: