|
Yeah, but not just for the PRE blocks. In the example I was talking about, the guy used a CODE block instead of a PRE block, so what I'm after is the raw text of the entire message (rather than for each PRE block).
|
|
|
|
|
I want to Add "Google" Tag to my CodeProject article, But I don't know why It has not being added to the article's tags when I publish it. All other tags work fine.
My article address is :<a href="http://www.codeproject.com/KB/DLL/GAConnect.aspx">http://www.codeproject.com/KB/DLL/GAConnect.aspx</a>
|
|
|
|
|
I'll get Sean to look into this.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
|
When you add it to the list of your article's tags it creates the tag, but in order to add it to your article you have to go edit the article a second time, and when you go to add "Google" to your list of tags you will see it appear.
We'll look into simplifying this
Thanks,
Sean Ewington
The Code Project
|
|
|
|
|
Take a look at the XSLT at the bottom of this page. When I paste it into a PRE block and set the LANG to XML, it gets cut off early:
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:theScript='urn:CustomScript'>
<xsl:output omit-xml-declaration='yes' method='text'
media-type='text/plain' indent='no' />
<xsl:variable name='displayme' />
<msxsl:script implements-prefix='theScript' language='C#'>
<![CDATA[
</msxsl:script>
<xsl:template match='/'>
<xsl:text disable-output-escaping='yes'>Print Integers > 3</xsl:text>
<xsl:apply-templates select='Root/Numbers' />
Script Result: <xsl:value-of select='theScript:HelloName("Joe")' />
Done: <xsl:value-of select='$displayme' />
</xsl:template>
<xsl:template match='Numbers'>
Numbers:<xsl:apply-templates select='Integer[@value > 3]' />
</xsl:template>
<xsl:template match='Integer'>
Integer: <xsl:value-of select='@value' />
</xsl:template>
</xsl:stylesheet>
Now, if I use the same exact PRE block but set the LANG to TEXT, all the code shows up in full:
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:theScript='urn:CustomScript'>
<xsl:output omit-xml-declaration='yes' method='text'
media-type='text/plain' indent='no' />
<xsl:variable name='displayme' />
<msxsl:script implements-prefix='theScript' language='C#'>
<![CDATA[
public string HelloName(string name)
{
return "Hello " + name;
}
]]>
</msxsl:script>
<xsl:template match='/'>
<xsl:text disable-output-escaping='yes'>Print Integers > 3</xsl:text>
<xsl:apply-templates select='Root/Numbers' />
Script Result: <xsl:value-of select='theScript:HelloName("Joe")' />
Done: <xsl:value-of select='$displayme' />
</xsl:template>
<xsl:template match='Numbers'>
Numbers:<xsl:apply-templates select='Integer[@value > 3]' />
</xsl:template>
<xsl:template match='Integer'>
Integer: <xsl:value-of select='@value' />
</xsl:template>
</xsl:stylesheet>
I think the XML formatter chokes on the Print Integers > 3 part. Remove that, and the world is happy again. However, that did mean I needed to tweak the example a bit when I was posting an answer here. Seems like the colorizer should not chop off code when it doesn't recognize it... it should just color it incorrectly (though, ideally, it would recognize the code correctly).
|
|
|
|
|
shouldn't you encode some data characters ( < > & ) to create valid XML?
(as you should for any code snippet you want to show in PRE tags)
|
|
|
|
|
The > is encoded, but it isn't double encoded. The .Net XSLT processor will forgive a greater than, but will sometimes choke on a less than. Inside of an xsl:text tag, though, less thans and greater thans may be legal (or maybe not... but the greater thans still work). In any event, the code colorizer shouldn't cut off code, even if the format is incorrect (if the HTML is icorrect, that's another matter entirely... but the HTML is encoded fine).
|
|
|
|
|
aspdotnetdev wrote: The > is encoded, but it isn't double encoded.
Just to clarify, I mean that the character is encoded in the pasted code sample. It is not encoded in the original XSLT sample.
|
|
|
|
|
aspdotnetdev wrote: the code colorizer shouldn't cut off code
that's the part I'm agreeing with most, however it still may be the browser is swallowing stuff due to incorrect HTML.
aspdotnetdev wrote: The > is encoded, but it isn't double encoded
IMO, and to make it very clear (I hope) it should be encoded one more time than your XML tags themselves.
aspdotnetdev wrote: the greater thans still work
yes, most often > seems to work without extra encoding, and < does or does not depending on circumstances (e.g. a forum message accepts them when the next character is a space or a digit). But it is not in accordance with the rules, some browser/HTML parser/XML parser might rightfully choke on them.
|
|
|
|
|
Just to be clear, it is only the XML that MAY be malformed (but will still work fine when put through an XSLT processor). The HTML is encoded as it should be. Every < is replaced by < and the same goes for the other characters. I selected "Encoded < When Pasting", so that should be perfectly fine. To demonstrate this, here is the XML code block from my above post, encoded further and wrapped in a PRE block with the LANG set to HTML:
<pre lang="xml"><xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:msxsl='urn:schemas-microsoft-com:xslt'
xmlns:theScript='urn:CustomScript'>
<xsl:output omit-xml-declaration='yes' method='text'
media-type='text/plain' indent='no' />
<xsl:variable name='displayme' />
<msxsl:script implements-prefix='theScript' language='C#'>
<![CDATA[
public string HelloName(string name)
{
return "Hello " + name;
}
]]>
</msxsl:script>
<xsl:template match='/'>
<xsl:text disable-output-escaping='yes'>Print Integers > 3</xsl:text>
<xsl:apply-templates select='Root/Numbers' />
Script Result: <xsl:value-of select='theScript:HelloName("Joe")' />
Done: <xsl:value-of select='$displayme' />
</xsl:template>
<xsl:template match='Numbers'>
Numbers:<xsl:apply-templates select='Integer[@value > 3]' />
</xsl:template>
<xsl:template match='Integer'>
Integer: <xsl:value-of select='@value' />
</xsl:template>
</xsl:stylesheet></pre>
The HTML is definitely not the issue. It's the colorizers interpretation of the XML that is the problem.
|
|
|
|
|
Sorry but I don't like the > which sits
here
|
V
<xsl:text disable-output-escaping='yes'>Print Integers > 3</xsl:text>
I'm not familiar with XSL, bowever I'm pretty convinced it should be escaped.
FWIW: Yes, it is unfortunate things may go wrong when escaping isn't applied correctly, and yes it would be nice if the forum and the browser would be as tolerant as the system that is intended to process your code.
FWIW2: jeez, these forums are much harder without proper mail notifications.
|
|
|
|
|
Luc Pattyn wrote: jeez, these forums are much harder without proper mail notifications.
Sucker! Notifications have been working fine for me. Maybe Jim just doesn't like you.
|
|
|
|
|
You must be living in an alternate reality...
|
|
|
|
|
I agree with Luc.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
You agree that "it would be nice if the forum and the browser would be as tolerant as the system that is intended to process your code"?
|
|
|
|
|
I agree that "I'm pretty convinced it should be escaped"
Even so, it's easy enough to add some code that will take <[non-alphanumeric] and convert it to <[non-alphanumeric]
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
I think what you mean is change this:
<xsl:text>xyz > abc</xsl:text>
Into this:
<xsl:text>xyz > abc</xsl:text>
That might change the meaning of the code (that's basically what I had to do though, unfortunately)... I'm not sure, but I think XSLT interprets anything inside of an XSL:TEXT block as a string literal (so a greater than would be output as a greater than and an ampersand would be output as an ampersand... not sure though). Also, I don't see how a character being alphanumeric or not is relevant.
I can't see any way to get the above to display with XML as the LANG:
<xsl:text>xyz > abc</xsl:text>
Are you saying I should modify the code content so the colorizer doesn't cut off the code? Probably a suitable workaround for most every scenario, but still seems like a bug, and one that takes time to figure out how to fix.
|
|
|
|
|
Luc Pattyn wrote: jeez, these forums are much harder without proper mail notifications
How are they now?
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
mail just arrived, 9 hours late.
full header included:
softfail (mta1148.mail.mud.yahoo.com: domain of transitioning forums@codeproject.com does not designate 65.39.148.44 as permitted sender)
|
|
|
|
|
We're slowly corralling things into shape. Mail is always the slowest to get sorted.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
it started to work promptly for me some 10 minutes ago.
|
|
|
|
|
As luck would have it, it appears this may have just happend to somebody else here:
VisualLive wrote: i tried to use PRE tag but when i post the code many lines of code disappear
|
|
|
|
|
That guy didn't HTML encode any HTML entities. I've corrected it.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
I was sitting with 5 articles, and then added the GadgetPacker one the other night.
It still shows 5 as the tally, both at the top of the My Articles and the table on the right of member profile, however all 6 are listed.
Something broke?
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|