-
Notifications
You must be signed in to change notification settings - Fork 154
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
addExcludedSelector does not exclude everything that is in selector #347
Comments
@voyteck0 Thanks for the bug report. What exactly do you provide as $html to Emogrifier? The PHP code (i.e., including PHP opening and closing tags) or the output of executing PHP (i.e. only HTML, no PHP opening or closing tags)? |
FYI, excluding selectors does not keep Emogrifier from parsing that part as XML and then re-building it by outputting the XML - it only keeps the CSS from getting applied to it. If you need sections or your HTML to be completely untouched by Emogrifier, you need to put them into CDATA. (But maybe I've completely misunderstood your issue.) |
Hi Wojtek, could you please quote a minimal HTML and CSS that creates the problem for you? Thanks! |
I could try - but fixing this on the issue level will not be an option. So I think the bug should be rather recategorized for New Feature - but I would strongly recommend to update the instructions so they clearly states it only omits CSS inlining. |
I still don't quite understand what the exact issue is (i.e., what you are trying to do and what you mean by "ommited during emogrification process"). So the code would help me understand that. |
Here's the full file that I send to emogrifier: Still if you look what is inside <message_preview> tag - there you can find "citated" message - and I think Emogrifier messes up there... But in general it happens (as per my current tests) only on Outlook emails - Windows Mail or GMail works fine. However I cannot guarantee that e.g. Apple mail will not make it fail again. Additionally the following CSS code is added:
|
Thanks for the code. I'll have a look at it. Another question: You mentioned "when the email is sent from Microsoft Outlook". What is your workflow with Emogrifier? (I would assume that usually the email client is only used for reading the email, and that it the initial markup (template) is generated manually.) |
@voyteck0 In the meantime, would you be willing to provide a PR to make the workings of addExcludedSelector more explicit both in the method PHPDoc as well as in the README? |
@oliverklee - the process my application is realizing, where Emogrifier is being used is following:
Emogrifier comes in play in point 4 - I will go in more details there: The solution is to tell Emgrifier which part of HTML it should simply not touch - and that is for I thought the addExcludedSelector() method can be used for. Can you tell me what would you require from me in scope of "to make the workings of addExcludedSelector more explicit both in the method PHPDoc as well as in the README" - sorry, maybe I am not a specialist in GitHub, but do not understand that part :) |
@voyteck0 Do you need instructions on how to create a fork and a pull request for this, or do you need more explanations on the PHPDoc changes or the README changes? |
I read a bit and found out what you mean... But I was actually not going to modify your class, but implement that "omitting" functionality in my code (somehow outside the class). I succeeded and please find the code that is realizing that below:
This is basically part of a function. Generally one of the parameters for the function is $ignoreEmogrifyingTags, which is an array (default array()) or strings. These strings are the tags that should be "left alone" once emogrifying - so they are basically excluded from the text (replaced by uniqid()) and after text is emogrified - they are pu back where they were originally. I hope it will help if you'd wish to modify the way addExcludedSelector() method works. |
Thanks for the additional information! I'll have a look at it and then comment here with further ideas. Thanks again! (And if you have anything else, please feel free to open another ticket. I'd also love it if we could get you on board as a contributor with a pull request. ❤️ ) |
Looking at the code, I think So as well as $emogrifier->addExcludedSelector('message_preview'); it would also be necessary to add an exclusion selector to match all the descendant elements: $emogrifier->addExcludedSelector('message_preview *'); We should expand on the documentation and/or PHPDoc to clarify this. (I don't know whether, for convenience, a single selector list We should also ensure that this use case is covered by unit tests. |
I agree. |
I use Emgrifier to create confirmation mail for email messages sent to user. Therefore I have an email that contains a section, in which contents of another email (email preview) is put into. Normally sometimes - especially when source email is sent from Microsoft Outlook - Emogrifier ends up with problem:
DOMXPath::query(): Invalid expression in .../Emogrifier.php:366
To avoid Emogrifier from parsing the email I have introduced in an email additional tag:
Then after Emogrifier is initiated (.emogrify() method is called) I call function:
$emogrifier->addExcludedSelector('message_preview');
Unfortunatelly still the error persists.
The full code calling Emogrifier is:
As per my understanding this should prevent from using Emogrifier against anything that is inside <message_preview> tag - but apparently it does not.
The text was updated successfully, but these errors were encountered: