Topic on Extension talk:Mermaid

Using Mermaid with SMW SRF (SEP issue)

2
Summary by Revansx

SOLVED - the solution was .. wait for it.. to add a CR/LF to the beginning of the "Foo-item" template.

Revansx (talkcontribs)

I'm trying to use SMW SRF to return the results of a ASK statement as lines of unprocessed text within some other parser call (say Mermaid [1])

Here is an example of the parser function result I'm trying to emulate:

{{#mermaid:gantt
  Event1: myevent1, 2018/10/18, 1d
  Event2: myevent2, 2018/10/20, 1d
}}

Here is the way I am coding it:

{{#mermaid:gantt
  {{#ask: [[Category:Foo]]  |?has name  |?has date |link=none
     |format=template
     |template=Foo-item
     |import-annotation=true
     |sep=\n
  }}
}}

It works perfectly for a single result but not for multiple results.

Here is what the resulting html source looks like:

<div id="ext-mermaid-57345bc89a90cf8bf" class="ext-mermaid" data-mermaid="{"content":"gantt\n Event1: myevent1, 2018\/10\/18, 1d\\n Event2: myevent2, 2018\/10\/20, 1d","config":{"theme":"forest"}}"><div class="mermaid-dots"></div></div>

By inspecting the html source of the rendered page, I can see that the problem is that the "\" in the SEP of the results is ultimately getting printed as "\\n" in the final HTML.

I know that what it needs to be to work is this:

<div id="ext-mermaid-57345bc89a90cf8bf" class="ext-mermaid" data-mermaid="{"content":"gantt\n Event1: myevent1, 2018\/10\/18, 1d\n Event2: myevent2, 2018\/10\/20, 1d","config":{"theme":"forest"}}"><div class="mermaid-dots"></div></div>

Does anyone know a way that I can avoid having the SRF output formatter (or the MW output formatter) add the extra "\" to the "\n"?

[1] Extension:Mermaid

Revansx (talkcontribs)

SOLVED - the solution was .. wait for it.. to add a CR/LF to the beginning of the "Foo-item" template.

The 3 tricks to getting Mermaid to receive events information from SMW queries are:

  1. use the format=template SRF call pointing to a template that contains the wikitext:
    
    {{{2|Milestone Name}}}: {{{3|2000-01-01}}}, 1d
    
  2. notice that the template begins with a "CR/LF". This is crucial for the Mermaid parser call to process properly.
  3. use the "import-annotation=true" option in the SMW query to shut off the [[SMW::off/on]] tags.

I'm now able to make great Gantt charts with my site.

MW + SMW + SRF + Mermaid = Project Management in a Wiki.