[xwiki-devs] [Rendering] XHTML placeholder for links
Hi, Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax. We have 2 solutions I can think of: 1) Using a span with a class value: <span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span> 2) Using a comment: <!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink --> Pros and cons: * 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/> * 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments. Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution. WDYT? Thanks -Vincent
Two more things to take into account: a) This needs to work for macros too. Indeed we need to save the macro definition so that when we get back to the wiki editor we get the macro back (otherwise we would only get the result of the execution of the macro). b) The WYSIWYG editor code must be able to read the macro definition (be it in span or in comments) since the editor should do the following: - display some outline around portions of text that are the result of the macro execution - allow users to double click inside the outline to edit the macro definition Thanks -Vincent On Oct 3, 2008, at 9:13 PM, Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
ok I've started the implementation using Comments. Thanks -Vincent On Oct 4, 2008, at 10:05 AM, Vincent Massol wrote:
Two more things to take into account:
a) This needs to work for macros too. Indeed we need to save the macro definition so that when we get back to the wiki editor we get the macro back (otherwise we would only get the result of the execution of the macro). b) The WYSIWYG editor code must be able to read the macro definition (be it in span or in comments) since the editor should do the following: - display some outline around portions of text that are the result of the macro execution - allow users to double click inside the outline to edit the macro definition
Thanks -Vincent
On Oct 3, 2008, at 9:13 PM, Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></ span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Vincent, First of all I don't know why do we need to wrap the anchor in a span and not put the "wikilink" class directly on the anchor. I see there are no CSS rules attached to it so I guess is has a semantic purpose. Furthermore, what do you think about using custom attributes on the anchor, like xwiki:doc="Main.WebHome"? Anyway, I'll be able to detect/inset if it's either span or comment or custom attributes. One note though: in the case of span or comment I'll have to take care when I'm inserting other DOM nodes so the link DOM fragment is taken as a unit. For instance, I shouldn't inset strong or em between the span and the anchor. Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Oct 6, 2008, at 12:17 PM, Marius Dumitru Florea wrote:
Hi Vincent,
First of all I don't know why do we need to wrap the anchor in a span and not put the "wikilink" class directly on the anchor.
This need comes from Laurent Lunati who said there are cases where we need both the span and the A to able to style the way we want. It has no semantic meaning.
I see there are no CSS rules attached to it so I guess is has a semantic purpose. Furthermore, what do you think about using custom attributes on the anchor, like xwiki:doc="Main.WebHome"?
This will mean defining a custom DTD right? So this also makes it more complex for users doing copy/paste of our code. The comment solution seems the less intrusive for me even though not "strongly typed". Thanks -Vincent
Anyway, I'll be able to detect/inset if it's either span or comment or custom attributes. One note though: in the case of span or comment I'll have to take care when I'm inserting other DOM nodes so the link DOM fragment is taken as a unit. For instance, I shouldn't inset strong or em between the span and the anchor.
Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></ span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Vincent Massol wrote:
On Oct 6, 2008, at 12:17 PM, Marius Dumitru Florea wrote:
Hi Vincent,
First of all I don't know why do we need to wrap the anchor in a span and not put the "wikilink" class directly on the anchor.
This need comes from Laurent Lunati who said there are cases where we need both the span and the A to able to style the way we want. It has no semantic meaning.
Yes, for Internet Exploiter, which should better die faster. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Marius Dumitru Florea wrote:
Hi Vincent,
First of all I don't know why do we need to wrap the anchor in a span and not put the "wikilink" class directly on the anchor. I see there are no CSS rules attached to it so I guess is has a semantic purpose. Furthermore, what do you think about using custom attributes on the anchor, like xwiki:doc="Main.WebHome"?
Does the editor support namespaces? I thought it didn't... Also, does wikimodel/doxia support them? If they do, then this is the way to go.
Anyway, I'll be able to detect/inset if it's either span or comment or custom attributes. One note though: in the case of span or comment I'll have to take care when I'm inserting other DOM nodes so the link DOM fragment is taken as a unit. For instance, I shouldn't inset strong or em between the span and the anchor.
Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
-- Sergiu Dumitriu http://purl.org/net/sergiu/
On Oct 6, 2008, at 12:41 PM, Sergiu Dumitriu wrote:
Marius Dumitru Florea wrote:
Hi Vincent,
First of all I don't know why do we need to wrap the anchor in a span and not put the "wikilink" class directly on the anchor. I see there are no CSS rules attached to it so I guess is has a semantic purpose. Furthermore, what do you think about using custom attributes on the anchor, like xwiki:doc="Main.WebHome"?
Does the editor support namespaces? I thought it didn't... Also, does wikimodel/doxia support them? If they do, then this is the way to go.
Yes it sounds nice. Since we're using Wikimodel for the XHTML parser we would only need to add support for it in wikimodel and in xwiki (it doesn't support them right now but I can modify it). What about macros? Here's an example: {{velocity}} #set ($var = "value") {{/velocity}} How would that be represented in an attribute? Like this? xwiki:macro="{{velocity}}\n#set ($var = "value")\n{{/velocity}}" (special chars would also be encoded) Is it an issue that it's less readable? Is there a size limit to attributes (Since a macro can get very long)? Answer: I don't think so. Probably the size limit of a Java String or the JVM available memory. Thanks -Vincent PS: ... and it seems I lost several hours of work yesterday modifying wikimodel to support external comment handling... My fault for working on weekends...
Anyway, I'll be able to detect/inset if it's either span or comment or custom attributes. One note though: in the case of span or comment I'll have to take care when I'm inserting other DOM nodes so the link DOM fragment is taken as a unit. For instance, I shouldn't inset strong or em between the span and the anchor.
Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></ span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
On Oct 6, 2008, at 12:51 PM, Vincent Massol wrote:
On Oct 6, 2008, at 12:41 PM, Sergiu Dumitriu wrote:
Marius Dumitru Florea wrote:
Hi Vincent,
First of all I don't know why do we need to wrap the anchor in a span and not put the "wikilink" class directly on the anchor. I see there are no CSS rules attached to it so I guess is has a semantic purpose. Furthermore, what do you think about using custom attributes on the anchor, like xwiki:doc="Main.WebHome"?
Does the editor support namespaces? I thought it didn't... Also, does wikimodel/doxia support them? If they do, then this is the way to go.
Yes it sounds nice.
Is this how to do it: http://www.w3.org/MarkUp/Guide/xhtml-m12n-tutorial/ http://alistapart.com/articles/customdtds2/ Is XHTML Modularization spec supported by all browsers/parsers? Thanks -Vincent
Since we're using Wikimodel for the XHTML parser we would only need to add support for it in wikimodel and in xwiki (it doesn't support them right now but I can modify it).
What about macros?
Here's an example:
{{velocity}} #set ($var = "value") {{/velocity}}
How would that be represented in an attribute?
Like this?
xwiki:macro="{{velocity}}\n#set ($var = "value")\n{{/velocity}}"
(special chars would also be encoded)
Is it an issue that it's less readable?
Is there a size limit to attributes (Since a macro can get very long)? Answer: I don't think so. Probably the size limit of a Java String or the JVM available memory.
Thanks -Vincent
PS: ... and it seems I lost several hours of work yesterday modifying wikimodel to support external comment handling... My fault for working on weekends...
Anyway, I'll be able to detect/inset if it's either span or comment or custom attributes. One note though: in the case of span or comment I'll have to take care when I'm inserting other DOM nodes so the link DOM fragment is taken as a unit. For instance, I shouldn't inset strong or em between the span and the anchor.
Vincent Massol wrote:
Hi,
Since recognizing links to be xwiki links is hard (not even always possible) we need to add some extra information when we render wiki syntax content into XHTML (for the WYSIWYG editor for ex) so that we can convert it back to wiki syntax.
We have 2 solutions I can think of:
1) Using a span with a class value:
<span class="wikilinkplaceholder wikilink"><! [CDATA[Space.ExistingPage]]><a href="/xwiki/bin/view/Space/ ExistingPage">Space.ExistingPage</a></span>
2) Using a comment:
<!-- startwikilink:Space.Existing --><span class="wikilink"><a href="/ xwiki/bin/view/Space/ExistingPage">Space.ExistingPage</a></ span><!-- stopwikilink -->
Pros and cons:
* 2) allows not generating visible content in XHTML so that if someone copy/paste our generated XHTML he won't have to add some CSS rule to prevent it from being visible. BTW I'm not even sure we can find a CSS rule to do that in solution 1) so we might need to have 2 spans as in: <span class="startwikilink"><![CDATA[Space.ExistingPage]]></ span><span class="wikilinkplaceholder wikilink"><a href="/xwiki/bin/view/ Space/ ExistingPage">Space.ExistingPage</a></span><span class="stopwikilink"/>
* 1) is harder to code since it requires using a SAX2 LexicalHandler, which btw is not supported by all XML parsers: "This is an optional extension handler for SAX2 to provide lexical information about an XML document, such as comments and CDATA section boundaries. XML readers are not required to recognize this handler, and it is not part of core-only SAX2 distributions." It also requires that I make some modifications to wikimodel since wikimodel currently ignores comments.
Solution 2) seems slightly better to me but as it's quite more complex to implement I'd like to be sure that it's the best solution.
WDYT?
Thanks -Vincent
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (3)
-
Marius Dumitru Florea -
Sergiu Dumitriu -
Vincent Massol