Project

General

Profile

Wiki External Filter plugin released

Added by Alexander Tsvyashchenko about 14 years ago

Redmine Wiki External Filter plugin allows defining macros that process macro argument using external filter program and render its result in Redmine wiki.

Currently supported macros are plantuml (for UML diagrams drawing), graphviz (for graphs drawing), ritex (for formula drawing) and fortune (simply for fun ;-), but additional ones are easy to add.

plantuml example input:

    {{plantuml(
    Alice -> Bob: Authentication Request
    alt successful case
      Bob -> Alice: Authentication Accepted
    else some kind of failure
      Bob -> Alice: Authentication Failure
      opt
        loop 1000 times
          Alice -> Bob: DNS Attack
        end
      end
    else Another type of failure
      Bob -> Alice: Please repeat
    end
    )}}

and output:

graphviz example input:

    {{graphviz(
    digraph finite_state_machine {
        rankdir=LR;
        size="8,5" 
        node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8;
        node [shape = circle];
        LR_0 -> LR_2 [ label = "SS(B)" ];
        LR_0 -> LR_1 [ label = "SS(S)" ];
        LR_1 -> LR_3 [ label = "S($end)" ];
        LR_2 -> LR_6 [ label = "SS(b)" ];
        LR_2 -> LR_5 [ label = "SS(a)" ];
        LR_2 -> LR_4 [ label = "S(A)" ];
        LR_5 -> LR_7 [ label = "S(b)" ];
        LR_5 -> LR_5 [ label = "S(a)" ];
        LR_6 -> LR_6 [ label = "S(b)" ];
        LR_6 -> LR_5 [ label = "S(a)" ];
        LR_7 -> LR_8 [ label = "S(b)" ];
        LR_7 -> LR_5 [ label = "S(a)" ];
        LR_8 -> LR_6 [ label = "S(b)" ];
        LR_8 -> LR_5 [ label = "S(a)" ];
    }
    )}}

and output:

ritex example input:

    {{ritex(
    G(y) = \left\{\array{ 1 - e^{-\lambda x} & \text{ if } y \geq 0 \\ 0 & \text{ if } y < 0 }\right.
    )}}

and output:

fortune sample input:

{{fortune}}

and output:

Detailed information is available here: https://www.ndl.kiev.ua/content/redmine-wiki-external-filter-plugin


Replies (80)

RE: Wiki External Filter plugin released - Added by Sergey Kovalev about 12 years ago

Thank you! It works!
But I have one little question - is it possible to remove "pre" tags? Older version didn't work without it, so, all our diagrams start with "pre" tag.

RE: Wiki External Filter plugin released - Added by Alexander Tsvyashchenko about 12 years ago

Hi Sergey,

Sergey Kovalev wrote:

Thank you! It works!
But I have one little question - is it possible to remove "pre" tags? Older version didn't work without it, so, all our diagrams start with "pre" tag.

The thing is that with current Redmine code it's arguably easier to make it handle "pre" tags properly than ignore them ;-)

The block of code that performs macros parsing is now called within this loop:

text = parse_non_pre_blocks(text) do |text|
[:parse_sections, :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros, :parse_headings].each do |method_name|
send method_name, text, project, obj, attr, only_path, options
end
end
This loop passes only non-pre blocks to the macros parser. Therefore, if you want to perform substitutions in "pre" blocks, you should do the following:
  • Move parse_macros call outside of this loop and pass to it the whole ``text`` without breaking it to ``non_pre`` blocks.
  • Remove restore_macros call after loop (you should not need it anymore).
  • Depending on macros you use: if they conflict in any way with ``parse_headings`` call (unlikely, but still ...), you would have to break the loop after ``parse_redmine_links``, then call ``parse_macros`` for the whole text, and then - perform separate loop for ``parse_headings`` function.

RE: Wiki External Filter plugin released - Added by Sergey Kovalev about 12 years ago

Okay, i'll remove all "pre" tags from diagrams :)
Anyway thank you for the patch!

Notes for Redmine 1 .4.1 - Added by Marc Mengel almost 12 years ago

I've got it running to the first order under Redmine 1.4.1; just a few tweaks:

  • the patches to redmine are slightly different
  • you need an additional config/routes.rb entry in the plugin itself

Attached for your enjoyment.

RE: Only first image is displayed if "newpage" is used - Added by Helge Sychla over 11 years ago

Hi,

we tend to create pretty long diagrams with PlantUML and hence would like to use the "newpage" command to split them in logical groups.
Unfortunately, only the first resulting image is embedded in redmine, the other(s) seem to be ignored.

Example:

{{plantuml(
@startuml

Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

newpage Second page

Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response

@enduml)}}

Splitting our diagram into several PlantUML macros is a bad option as the participant, skin, color declarations etc. need to be repeated in every single diagram
as no include mechanism would work in the Redmine plugin context.

It would be great if this could be changed to show all images rendered by PlantUML.

(76-80/80)