On 19 Jan 2015 at 09:15:32, Thanh Hong Dai (hdthanh@tma.com.vn(mailto:hdthanh@tma.com.vn)) wrote:
Hi,
Sorry, but I can’t see how it would help in my use case.
My code currently generates a list of links and the title of the page:
* [[name >> fullname]]
Adding the {{{…}}} outside the link syntax [[…]] doesn’t make sense, and placing it inside breaks everything (it doesn’t pass any of my hard test cases).
It will work in the label but not in the reference obviously… Thanks -Vincent PS: Please use the list
From: Vincent Massol [mailto:vmassol@gmail.com] On Behalf Of vincent@massol.net Sent: Monday, 19 January, 2015 2:23 PM To: Thanh Hong Dai; XWiki Users Subject: Re: [xwiki-users] Is there an escape tool to escape text in XWiki syntax?
Hi,
If you want to make sure to output verbatim text (ie not interpreted) you can use the {{{…}}} syntax when using XWiki Syntax 2.0+
See http://platform.xwiki.org/xwiki/bin/view/Main/XWikiSyntax#HVerbatim
However this may not be enough for your needs. We’re currently lacking an escape tool for wiki syntax AFAIK and I remember seeing a JIRA issue about this (can’t find it right now). I agree that we should push for this since it’s becoming something more and more asked for.
Thanks
-Vincent
On 19 Jan 2015 at 08:15:16, Thanh Hong Dai (hdthanh@tma.com.vn(mailto:hdthanh@tma.com.vn))(mailto:hdthanh@tma.com.vn(mailto:hdthanh@tma.com.vn))) wrote:
Currently, I'm using something like this to generate a list of pages whose prefix is "Prefix:" and link to them:
{velocity}} (((
#foreach ($row in $services.query.hql("select doc.name, doc.fullName from XWikiDocument doc where doc.space.hidden = false and doc.space not in ('XWiki', 'Sandbox', 'Main', 'Macros') and doc.name like 'Prefix:%'").execute())
* **[[$row[0].replaceFirst("Prefix: *", "").replaceAll("~", "~~~~").replaceAll("[\x20-\x7f&&[^a-zA-Z0-9 ~]]", "~~$0")>>doc:$row[1].replaceAll("~", "~~").replaceAll("[\x5b\x5d|]", "\\$0 (file://///$0%0b%3e%20) ")]]**
#end
))) {{/velocity}}
I have tested with some heavy test cases like
Prefix: ~~~!!!```@@@$$$%%%^^^&&&***((()))___----+++==={{{}}}[[[]]]\\\|||:::;;;'''""" ???///...>>>,,,<<<
And what I have above works correctly (both showing the title and linking to the document). I only work on a few hard test cases, though, so I'm not sure if I missed anything.
Is there a method that does all this automatically? Or is there a better approach to this?