Keeping Outlook Specific Conditionals in XSL - html

I have an outlook specific conditional statement that I can't seem to get to render in XSL. I've tried saving them as variables and printing them, putting them in tags... All with no luck.
Below is the code:
<!--[if gte mso 9]>
... code ...
<![endif]-->
Any ideas?

I have an outlook specific conditional statement that I can't seem to get to render in XSL.
What you are showing is an XML comment (<!-- comment -->) . Therefor you may try:
<xsl:comment>[if gte mso 9]>
... code ...
<![endif]</xsl:comment>
As an alternative you can use disable-output-escaping="yes" with <![CDATA[. Try:
<xsl:text disable-output-escaping="yes">
<![CDATA[ <!--[if gte mso 9]>
... code ...
<![endif]--> ]]>
</xsl:text>

Related

Conditional comments in outlook365 (Win10)

As known Outlook client (Win version) doesn't use div's so I have to use tables. In order to make responsive design, I'm trying to use the hybrid design (as mentioned here https://www.litmus.com/blog/mobile-responsive-email-stacking/)
The problem is that the outlook client (outlook365 on win10) just ignores every syntax of conditional comments, and gives me the same results as if it was Gmail.
I couldn't find any answer. Could it be that Microsoft just removed this feature from their mail client? or am I doing something wrong.
I'll appreciate any idea. Thank you.
This is the HTML I've sent to myself and I got only the lines saying "this is not mso" (both conditions were ignored (the positive and the negative).
<!--[if mso]>
this is mso
<![endif]-->
<!--[if (gte mso 9)|(IE)]>
gte mso 9
<![endif]-->
<!--[if gte mso 16]>
this is mso 16
<![endif]-->
<!--[if (gte mso 9)|(IE)]>
gte mso 9
<![endif]-->
<!--[if !((gte mso 9)|(IE))]><!-- -->
This is not mso 9\ie
<!--<![endif]-->
<!--[if !mso]><!-- -->
This is not mso
<!--<![endif]-->

Prevent TinyMCE from adding spaces within HTML comments

For emails I use conditional comments in order to make UI adjustments for Outlook '07+. When saving in TinyMCE it adds a space changing
this
<!--[if gte mso 9]>
to this
<!-- [if gte mso 9]> (with space before the [)
which doesn't get interpreted by Outlook anymore.
Any idea if there is a setting in TinyMCE to prevent this change?
--
Secondary: In case this is easy to add, I'd ideally would like comments to also not be moved to the previous line, but couldn't find a setting for this either.
Example:
Some text
<!-- Outlook hack here -->
<!--[if gte mso 9]>
<tag>
should not become
Some text <!-- Outlook hack here --> <!-- [if gte mso 9]>
<tag>
We had this problem and solved it by adding
allow_conditional_comments: true
Example below taken directly from the documentation: https://www.tiny.cloud/docs/configure/content-filtering/
tinymce.init({
selector: 'textarea', // change this value according to your HTML
allow_conditional_comments: true
});
I'm not sure how to best solve the second question.

Remove from <!--[if gte mso 9]> to <![endif]--> in HTML [REGEX, RUBY]

I have a HTML text with <!--[if gte mso 9]> and <![endif]--> tags. I want to remove everything that there is between those two tags.
I'm using the ruby function gsub with a Regex expression, but it won't work.
This is what I've tried:
text = "<!--[if gte mso 9]><xml>\n <w:WordDocument>\n [...] \n</style>\n<![endif]-->"
text2 = text.gsub /(?=<!\-\-\[if gte mso 9\]>)(.*?)(?<=<!\[endif\]\-\->)/, ""
What I want as an answer is:
text2 = "<!--[if gte mso 9]><![endif]-->"
Or even:
text2 = ""
I tried this based on this article
I've tried this online Regex tester and, it seems to be the right way to do it, but it won't work on my program!
Please help!
Thanks in advance!
Try this regex /(?<=<!--\[if gte mso 9\]>).*?(?=<!\[endif\]-->)/m, and do a gsub on the string. You will get <!--[if gte mso 9]><![endif]-->
(?<=<!--\[if gte mso 9\]>) is a positive look behind, which matches the <!--\[if gte mso 9\]> string, but doesn't include it in the result.
.* matches any characters 0 or more times.
(?=<!\[endif\]-->) is a positive look forward, which matches the <!\[endif\]--> but doesn't include it in the result.
the m identifier at the end means the match multiline strings. Since you declared your string with "", the \n will be interpreted as a new line.
Essentially, you are matching everything in between the two tags.
In your regex, /(?=<!\-\-\[if gte mso 9\]>)(.*?)(?<=<!\[endif\]\-\->)/, you used the positive look forward for the first tag, and positive look behind for the second tag, you need to flip them.
Positive look forward matches a group after the main expression without including it in the result.
Positive look behind matches a group before the main expression without including it in the result.

How can I display something if its opened with Oulook and if its not display something else?

So basicly I made a html email that looks like this:
<html>
<head>
...
</head>
<!--[if mso ]>
<body>
<p>Hello world, its Outlook!</p>
</body>
<![endif]-->
<!--[if !mso ]>
<body>
<p>Hello world, its NOT Outlook!</p>
</body>
<![endif]-->
</html>
Now here is the problem, when I open the mail with Outlook correct body tag with its children is rendered which is correct "Hello world, its outlook!".
But when I open the mail with Gmail or Hotmail its blank nothing is displayed..
Whats the problem? And how can I make sure that the "NOT Outlook" body tag and its children is displayed if its not outlook and if it is Outlook how can I display the first top body tag with its children in same html markup?
Correct answer:
<!--[if mso ]>
...
<![endif]-->
<![if !mso ]>
...
<![endif]>

Is there a conditional CSS If for outlook?

I need some particular css for an html email, but only in outlook.
I'm looking for the outlook equivalent of
<!--[if IE]>body {background-color:red} <![endif]-->
<!--[if gte mso 9]
// This CSS will only be seen in Outlook 2007
![endif]-->