Hi, On 5 Oct 2015 at 09:20:27, Thomas Mortagne (thomas.morta...@xwiki.com(mailto:thomas.morta...@xwiki.com)) wrote:
> On Mon, Oct 5, 2015 at 1:09 AM, Paul Libbrecht wrote: > > Hello Vincent, > >> What failed? > > Reading the content. > >> I was just saying that our Confluence parser should support macros. I’ve > >> just tried writing a page in Confluence syntax using an existing XWiki > >> macro and it worked: > >> > >> {html}hello{html} > > I can't explain why this one works but I presume there's a switch > > internally to it that automatically converts the html macro into a > > closing html macro (and indeed, it's nonsense to nest html). > >> This worked too: > >> > >> {documentTree} > >> This worked too (showing we can pass one parameter): > >> {documentTree:checkboxes=true} > > Yes, parameters reading (single and multiple) worked fine (but they need > > escaping). > > > > > > I tried a tick more formally to see if I could make a macro with content > > and failed. Here's how. > > > > Page: > > {testmacro} > > this is the content > > {testmacro} > > > > Macro: (Tools.TestMacro, object XWiki.WikiMacroClass) > > id: testmacro > > inline: no (I tried yes too, with inlined macro in the page) > > visibility: global > > macro content type: optional > > macro code: > > testMacroStart{{velocity}}$!xcontext.macro.content{{/velocity}}testMacroEnd > > > > The resulting page gives: > > > > testMacroStarttestMacroEnd > > this is the content > > testMacroStarttestMacroEnd > > > > I tried to adjust the content type to mandatory but this bragged... > > having no content! > > > > If macro content was thinkable, then there should be somewhere in the > > grammar a different mark for start and end macro or? I don't see the latter. > > No there is no special syntax, I guess in Confluence world macro > handled are talling the parser which kind of macro they are during the > parsing. In XWiki Confluence parser there is just a hardcoded list of > known content macro right now and the default seems to be no content. > We need to make it a bit more extensible. Indeed, I was checking that at the same time as you did :) Paul, if you’re interested the grammar is in ConfluenceWikiScanner.jj and the list of macro which are defined to have content is: | <#MACRO_BLOCK: "{" ( "color" // TODO: {color:xx} paragraph {color} | "section" | "column" | "csv" | "table-plus" // TODO: {table-plus:width=100..} table {table-plus} | "code" | "html" | "composition-setup" | "float" // TODO: {float:xx} paragraph {float} | "cloak" | "deck" | "card" | "show-card" | "chart" // TODO: {chart: params} table {charŧ} | "slideshow" | "slide" | "note" | "warning" | "important" | "caution" | "example" | "docbook" | "screen" | "table-plus" | "info" | "tip" | "cache" | "sql" | "noformat" | "panel" | "sub-section" | "clickable" | "tm" // TODO: {tm} inline text {tm} | "sm" // TODO: {sm} inline text {sm} | "reg-tm" // TODO: {reg-tm} inline text {reg-tm} | "copyright" // TODO: {copyright} inline text {copyright} | "span" // TODO: {span} inline text {span} | "lozenge" | "style" | "div" | "bgcolor" | "center" | "strike" | "privacy-policy" | "roundrect" | "align" | "iframe" | "table" | "table-row" | "table-cell" | "th" | "tbody" | "thead" | "ul" | "li" | "rollover" | "fancy-bullets" | "contentformattingtest" | "toc-zone" | "excerpt" ) <MACRO_PARAMS> "}" > BTW, this is why my earlier example with {html} worked... So if you write a macro not in this list, it cannot currently have any content, only parameters. I’ve created http://jira.xwiki.org/browse/XRENDERING-412 Thanks -Vincent > > Since, according to > > https://developer.atlassian.com/confdev/tutorials/macro-tutorials-for-confluence/creating-a-new-confluence-macro, > > "there are three available body types for macros: PLAIN_TEXT, RICH_TEXT, > > and NONE. ", I suppose the only solution is to make the scanner read the > > macro content type and fork differently if mandatory (and optional?) or > > no content type. Maybe these two levels are a bit far from each other... > > > > Paul _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users