Using xwiki syntax '(((' to rendering a SPAN doesn't work

Hello,
I try to rendering this HTML code with xwiki syntax

<span class="titre-listitem">My text<span>

Then I use this xwiki syntax:

(%span class="titre-listitem" %)(((My text)))

but here the rendering HTML code:

<div class="titre-listitem">
  <p>My text</p>
</div>

If I didn’t use ((( I have other issues like “class=” missing in a list or “

” inserted like this example:

{{velocity}}
{{html wiki="true"}}
#foreach ($child in $doc.getChildren())
  #set($MyDoc=$xwiki.getDocument($child))
  (%span class="titre-listitem"%)$MyDoc.title
  $MyDoc.getRenderedContent()
#end{{/html}}
{{/velocity}}

child page contains:

* item 1
* item 2

Previous code displays:

<p><span class="titre-listitem">Ma jolie liste</span></p>
<ul>
  <li><span class="wikilink"><a href="xxxxxx">Page type de doc avec un sommaire</a></span>/li>
   ...
  <li><span class="wikilink"><a href="/bin/view/BacASable/TestPage3">Page de Test 3</a></span></li>
</ul>
Ma 2eme liste
<ul>
  <li><span class="wikilink"><a href="xxxxx">bla bla</a></span></li>
  <li><span class="wikilink"><a href="xxxxx"><span class="wikigeneratedlinkcontent">Tableau filtré</span></a></span></li>
</ul>
<p></p>

Do you have an ideas what’s this issue?

Thxs.
Pascal B

This is invalid syntax.

You should use:

(% class="titre-listitem" %)my text(%%)

See the last example on https://platform.xwiki.org/xwiki/bin/view/XWiki/XWikiSyntax?syntax=2.1&section=Paragraphs

Do you mean I must use the example I added myself on this doc ? :disappointed_relieved:
Thxs.

I wonder why I have some <p> </p> inserted anyways :frowning:

And now I have another issue if I use this:

{{velocity}}
(% class="titre-listitem" %)$doc.title(%%)
{{/velocity}}
org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Velocity Macro for content [(% class="titre-listitem" %)$doc.title(%%)]
...
Caused by: org.apache.velocity.runtime.parser.ParseException: Lexical error: org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 1, column 40.  Encountered: "%" (37), after : ""

I can fix it if I add a space character here “$doc.title (%%)”

I will thinking about that this week end…
Thxs

You’ll have that if you have some space or new line in the velocity code.

Nope, here my testing code when I edit a page with wiki editor. My content is only this:

{{velocity}}(% class="titre-listitem" %)$doc.title (%%){{/velocity}}

(no end of line after “{{/velocity}}”)
HTML rendering contains: <p></p> :

<p>
  <span class="titre-listitem">Sandbox&nbsp;</span>
</p>     

But that example is perfectly normal! Textual content and span are inline elements that have to be inside a standalone elemenent (and thus a paragraph) in HTML :slight_smile:

I thought you said you had an empty paragraph, which is not the case apparently.

Ok fine but how can I have this rendering then?

<p class="titre-listitem">Sandbox</p>    

because every xwiki syntax I use my HTML code contain <p> with <span> or <div>

(and how avoid “velocity.runtime.parser.ParseException” error with (% class=“titre-listitem” %)$doc.title(%%) )

You cannot :slight_smile: You can get something that does something very similar with:

(% class="titre-listitem" %)Sandbox(%%)

You’ll get:

<p><span class="titre-listitem">Sandbox</span></p>

(% class="titre-listitem" %)Sandbox(%%) is perfectly valid and won’t generate any error. If you get one it must be because your example is more complex. Try putting this is a in wiki page by itself. You shouldn’t get any error.

This code generate error:

{{velocity}}
(% class="titre-listitem" %)$doc.title(%%)
{{/velocity}}

Yes that’s normal. That’s velocity not being used properly.

Try:

{{velocity}}
(% class="titre-listitem" %)${doc.title}(%%)
{{/velocity}}

TBH I’m not entirely sure why Velocity is having a problem with your example but it’s using the short hand notation and use the formal notation fixes the problem.

k thxs.
It’s difficult to predict html rendering (I use $MyDoc.getContent() and/or $MyDoc.getRenderedContent())

Now I try to use wiki syntax to avoid some strange issue with HTML code, like: Loading...

Maybe don’t use HTML rendering (which is not a great idea since it would not work with all renderers, e.g. with LaTeX).

You could use the include or display macro maybe instead of getRenderedContent().

Is it ok with $MyDoc.getContent()?
I suppose that return wiki code?

(% class="titre-listitem" %)
Sandbox

(previous line apply to the whole paragraph)

Be careful that $MyDoc.getContent() will just insert the content as is. So if you have relative links/images/etc it won’t work. you’ll need the display macro for that.

good point Thomas, I had forgotten about that :wink:

ok I’m testing includeForm and includeTopic :slight_smile:
ty @tmortagne