Vazor
Vazor copied to clipboard
Escaping illegal characters
Did you figure out how to get past the problem of illegal characters in XML Literals? For example, and — are commonly used in HTML markup, but a project won't compile if we use them in Vazor. The problem is the standalone ampersand (&).
The best workaround I could find is to use & in the literals and then replace them all in *.cshtml.vb:
html = Me.GetVbXml(Me.ViewData).ParseZML.Replace("&", "&")
But of course that's a kludge.
Any ideas for an elegant solution to this?
Try something like this:
Const nbsp = " "
Dim x = <html>
<b><%= nbsp %></b>
</html>
From: Jeff Bowman @.> Sent: Sunday, November 12, 2023 4:23 AM To: VBAndCs/Vazor @.> Cc: Subscribed @.***> Subject: [VBAndCs/Vazor] Escaping illegal characters (Issue #15)
Did you figure out how to get past the problem of illegal characters in XML Literals? For example, and — are commonly used in HTML markup, but a project won't compile if we use them in Vazor. The problem is the standalone ampersand (&).
The best workaround I could find is to use & in the literals and then replace them all in *.cshtml.vb:
html = Me.GetVbXml(Me.ViewData).ParseZML.Replace("&", "&")
But of course that's a kludge.
Any ideas for an elegant solution to this?
— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/Vazor/issues/15, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVWKVVTGAUVQD46ZZ2LYEBFKRAVCNFSM6AAAAAA7HXODJWVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4DSMRTGIZTCNY. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Got it, thanks.
Oops, I spoke too soon.
Turns out that inserts an ampersand entity into the HTML (&), which mucks things up.
The end result: &nbsp;. Which of course displays a on the page, where there should be a non-breaking space instead.
Guess we'll have to go with the kludge.
OK, I found the fix. Use the HTML entity & instead of a bare ampersand (&).
For example: &nbsp;
Now we don't have to muck around with replacing stuff in *.cshtml.vb.
Damn... that one doesn't work either! No matter what we try, the XML Literals engine escapes that ampersand.
It seems the only way to do it is to modify the text after the engine generates it, not before. Runtime only. We don't get design-time support on this one.
And the engine replaces & with &, so we might as well use & in the first place. Easier to type, easier to remember.
In ZML source code, I use the const __amp__ which is not likely to be found in the original page, then replace it with & in the final text.
From: Jeff Bowman @.> Sent: Monday, November 13, 2023 2:36 AM To: VBAndCs/Vazor @.> Cc: Mohammad Hamdy Ghanem @.>; Comment @.> Subject: Re: [VBAndCs/Vazor] Escaping illegal characters (Issue #15)
Damn... that one doesn't work either! No matter what we try, the XML Literals engine escapes that ampersand.
It seems the only way to do it is to modify the text after the engine generates it, not before. Runtime only. We don't get design-time support on this one.
— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/Vazor/issues/15#issuecomment-1807388197, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVTT4DX4MPICEFECIEDYEGBRNAVCNFSM6AAAAAA7HXODJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBXGM4DQMJZG4. You are receiving this because you commented.Message ID: @.***>
OK.
In any case, the only solution seems to be a combination designtime/runtime solution. If the author wants to use HTML entities such as and —, he must use special notations (designtime) and then modify ZML's output after the fact (runtime).
Unfortunately, this results in brittle code. But so far as I can tell, it's the only answer to a sticky problem.
In ZML, you can find this note:
You can use >, < and & symbols directly in ZML code, as it handles them internally. Don't encode these symbols unless you intend to view them in the browser. But note that using these symbols in vbxml literals is not valid, unless you embed the string containing them in <%= %> quotes to force VB to encode them for you.
So, if you use ZML files, you need to do nothing, but if you write XML literals in VB code, you just need to define a place holder and add an extra line to replace it in the output. I think leaving this to the coder is better, instead of forcing him to memories some special placeholders for & and alike.
From: Jeff Bowman @.> Sent: Monday, November 13, 2023 4:01 PM To: VBAndCs/Vazor @.> Cc: Mohammad Hamdy Ghanem @.>; Comment @.> Subject: Re: [VBAndCs/Vazor] Escaping illegal characters (Issue #15)
OK.
In any case, the only solution seems to be a combination designtime/runtime solution. If the author wants to use HTML entities such as and —, he must use special notations (designtime) and then modify ZML's output after the fact (runtime).
Unfortunately, this results in brittle code. But so far as I can tell, it's the only answer to a sticky problem.
— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/Vazor/issues/15#issuecomment-1808453157, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVQ3TV76TTX4GGDO43DYEI75XAVCNFSM6AAAAAA7HXODJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYGQ2TGMJVG4. You are receiving this because you commented.Message ID: @.***>
[https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free.www.avast.comhttps://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Makes sense.
I may be getting ZML and XML Literals mixed up in my terminology.
I'm going by the sample code in Index.vbhtml.vb:
<zml xmlns:z="zml">
... HTML markup here ...
</zml>
I've been thinking that everything here is encompassed by the concept of XML Literals, and that ZML is everything between <zml> and </zml>.
Is that correct?
No. This is still xml literal, that contains html tags and possibly some zml tags to fix some issues in for loops. On the other hand there are pure .zml files, where you can design the page with html and zml tag language. See: https://github.com/VBAndCs/ZML The missing part in this project is thee editor support for zml tags. Note: I no longer have access to my github account, because I don't use 2 factor authintication, and github doesn't support phone messages to Egypt! I will not install any extension to the browser not use any mobile app to scan codes. In fact github was sending the authentication code via email, and that was a 2 factor already, but now it just complicated things. So, I can just replay on your messages via email. There will be no further activity on my projects until github supports SMS or go back to the email auth. So, it is better to fork such projects and evolve it as you want. Thanks.
From: Jeff Bowman @.> Sent: Tuesday, November 14, 2023 1:36 AM To: VBAndCs/Vazor @.> Cc: Mohammad Hamdy Ghanem @.>; Comment @.> Subject: Re: [VBAndCs/Vazor] Escaping illegal characters (Issue #15)
Makes sense.
I must be getting ZML and XML Literals mixed up in my terminology.
I'm going by the sample code in Index.vbhtml.vb:
I've been thinking that everything here is encompassed by the concept of XML Literals, and that ZML is everything between
Is that correct?
— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/Vazor/issues/15#issuecomment-1809400978, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVXZDAW2Z7JLFGTBH5DYELDIXAVCNFSM6AAAAAA7HXODJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBZGQYDAOJXHA. You are receiving this because you commented.
[https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free.www.avast.comhttps://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
I no longer have access to my github account
What!!
That'll never do! OK, I'm going to help you get back in there.
First, get a Google Voice number in the U.S. (free). Then, send me an email so we can communicate that way (much easier). My email address is on my website.