Comments (3)
You can also use custom html tags, so your fix would not work.
from mjml-net.
Oh, you're right, I have another implementation based on your xml fixer but it's a bit complex and doesn't necessarily handle all cases.
internal static string EscapeLowerThanCharacterInTags(string html)
{
var span = html.AsSpan();
var result = StringBuilders.Get();
try
{
for (var i = 0; i < span.Length; i++)
{
if (span[i] != '<')
{
result.Append(span.Slice(i, 1));
continue;
}
if (i > 0 && span[i - 1] == span[i]) // same character '<'
{
result.Append("<");
continue;
}
// find end tag
var indexOfEndTag = span[i..].IndexOf('>');
if (indexOfEndTag != -1)
{
var tag = span.Slice(i, indexOfEndTag + 1);
if (tag[..2] is "</" || tag[..3] is "<br")
{
result.Append(tag);
i += tag.Length - 1;
}
else
{
bool notATag = false;
if (!(tag.Trim().IndexOfAny('!', '=') != -1 && tag.Trim().Length > 3)) // not found
{
foreach (var tagCharacter in tag)
if (char.IsWhiteSpace(tagCharacter) || (char.IsPunctuation(tagCharacter) && tagCharacter is not '-' or '_'))
{
notATag = true;
break;
}
}
if (notATag)
result.Append("<");
else
{
result.Append(tag);
i += tag.Length - 1;
}
}
}
else
result.Append(span[i]);
}
return result.ToString();
}
finally
{
StringBuilders.Return(result);
}
}
from mjml-net.
Could work.
Can you:
- Create a PR
- Integrate it into this class: https://github.com/SebastianStehle/mjml-net/blob/main/Mjml.Net/XmlFixer.cs?
- Write a few tests?
from mjml-net.
Related Issues (20)
- css-class in mj-attributes not working for <mj-table> HOT 2
- What is the license of this nuget package? HOT 2
- FixXML has problems with attribute names with hyphens HOT 1
- Support <mj-text align="justify"> HOT 2
- MjImage is malformed HOT 6
- Use of mj-hero results in broken email HOT 4
- Question: Is it possible to override the default styles? HOT 1
- <td> attribute is valign not vertical-align HOT 5
- Support for mj-list HOT 1
- MjmlRenderer.FixXml() results in invalid character entity code HOT 2
- Asynchronous rendering HOT 5
- Replace XmlReader? HOT 2
- Not possible to include root element HOT 5
- IFileLoader can't handle nested files HOT 2
- Upgrading to v2 or latest version removes .fixXML() and Lax HOT 6
- E-mail formatting broke after upgrade from 1.2.0 to 3.1.0 HOT 4
- .NET 8 HOT 2
- Request for .net core version HOT 3
- MJML Upgrade broke .NET href Url.Page() builder link. HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mjml-net.