Project

General

Profile

Feature #44636 » 0001-Describe-Mermaid-diagrams-in-the-wiki-syntax-help-pa.patch

Go MAEDA, 2026-10-25 06:21

View differences:

app/assets/stylesheets/wiki_syntax.css
}
table td { background-color: var(--oc-gray-0); block-size: 2em; vertical-align: middle;}
table td code { font-size: 1.2em; }
table td img { max-width: 100%; }
table td h1 { font-size: 1.8em; text-align: start; }
table td h2 { font-size: 1.4em; text-align: start; }
table td h3 { font-size: 1.2em; text-align: start; }
app/views/help/wiki_syntax/common_mark/en/wiki_syntax_common_mark.html.erb
</code></pre>
</td></tr>
<tr><th colspan="3">Mermaid diagrams <span class="more_info">(<a href="<%= help_wiki_syntax_path(:detailed, anchor: "17") %>" target="_blank">more</a>)</span></th></tr>
<tr><th></th><td>```mermaid<br />flowchart TD<br />&nbsp;&nbsp;A[Start] --&gt; B[End]<br />```</td><td><%= image_tag("help/mermaid_flowchart_simple.png", width: 168, alt: "Flowchart from Start to End") %></td></tr>
<tr><th colspan="3">Line breaks and Paragraphs</th></tr>
<tr><th></th><td>An empty line<br><br>creates<br>a new paragraph.</td><td><p>An empty line</p><p>creates a new paragraph.</p></td></tr>
<tr><th></th><td>End a line with a backslash\<br> or two spaces to insert a manual line break.</td><td><p>End a line with a backslash<br>or two spaces to insert a manual line break.</p></td></tr>
app/views/help/wiki_syntax/common_mark/en/wiki_syntax_detailed_common_mark.html.erb
</ul>
<li><a href='#12'>Macros</a></li>
<li><a href='#13'>Code highlighting</a></li>
<li><a href='#17'>Mermaid diagrams</a></li>
<li><a href='#15'>Raw HTML</a></li>
<li><a href='#16'>Alerts</a></li>
</ul>
......
<span class="k">end</span>
</code></pre>
<h2><a name="17" class="wiki-page"></a>Mermaid diagrams</h2>
<p>Code blocks written in the <strong>mermaid</strong> language are rendered as diagrams, such as flowcharts, sequence diagrams and Gantt charts, by <a href="https://mermaid.js.org/" class="external">Mermaid.js</a>. Please refer to the <a href="https://mermaid.js.org/intro/syntax-reference.html" class="external">Mermaid syntax reference</a> for the available diagrams and their syntax.<% if Redmine::Mermaid.installed_version %> Please note that the reference describes the latest version of Mermaid.js, and some of the syntax described there may not be supported by the installed version, <%= Redmine::Mermaid.installed_version %>.<% end %></p>
<p>Mermaid.js is not bundled with Redmine, and diagrams are rendered only if the administrator has installed it. Otherwise, the code is displayed as a plain code block.</p>
<p>You can draw a diagram at any place that supports wiki formatting using this syntax:</p>
<pre>
```mermaid
Place your diagram definition here.
```
</pre>
<p>Example:</p>
<pre>
```mermaid
flowchart LR
A[New issue] --&gt; B{Reproducible?}
B --&gt;|Yes| C[Fix]
B --&gt;|No| D[Close]
```
</pre>
<p>yields</p>
<%= image_tag("help/mermaid_flowchart_decision.png", width: 635, alt: "Flowchart: a new issue is fixed if it is reproducible, and closed otherwise") %>
<p>A rendered diagram can be downloaded as a PNG image.</p>
<h2><a name="15" class="wiki-page"></a>Raw HTML</h2>
<p>You may use raw HTML for more complex formatting tasks, i.e. complex tables with cells spanning multiple rows or columns:</p>
app/views/help/wiki_syntax/common_mark/ja/wiki_syntax_common_mark.html.erb
</code></pre>
</td></tr>
<tr><th colspan="3">Mermaidによる図 <span class="more_info">(<a href="<%= help_wiki_syntax_path(:detailed, anchor: "17") %>" target="_blank">詳細</a>)</span></th></tr>
<tr><th></th><td>```mermaid<br />flowchart TD<br />&nbsp;&nbsp;A[Start] --&gt; B[End]<br />```</td><td><%= image_tag("help/mermaid_flowchart_simple.png", width: 168, alt: "StartからEndへのフローチャート") %></td></tr>
<tr><th colspan="3">改行と段落</th></tr>
<tr><th></th><td>空行は<br><br>新しい段落を<br>作ります</td><td><p>空行は</p><p>新しい段落を作ります</p></td></tr>
<tr><th></th><td>バックスラッシュで終わる行\<br>または半角スペース2個で改行を挿入します</td><td><p>バックスラッシュで終わる行<br>または空白2個で改行を挿入します</p></td></tr>
app/views/help/wiki_syntax/common_mark/ja/wiki_syntax_detailed_common_mark.html.erb
</ul>
<li><a href='#12'>マクロ</a></li>
<li><a href='#13'>コードハイライト</a></li>
<li><a href='#17'>Mermaidによる図</a></li>
<li><a href='#15'>HTMLを直接使用する</a></li>
<li><a href='#16'>アラートボックス</a></li>
</ul>
......
<span class="k">end</span>
</code></pre>
<h2><a name="17" class="wiki-page"></a>Mermaidによる図</h2>
<p>言語に <strong>mermaid</strong> を指定したコードブロックは、<a href="https://mermaid.js.org/" class="external">Mermaid.js</a> によってフローチャート・シーケンス図・ガントチャートなどの図として表示されます。利用できる図の種類と記法は <a href="https://mermaid.js.org/intro/syntax-reference.html" class="external">Mermaidの記法リファレンス</a> を参照してください。<% if Redmine::Mermaid.installed_version %>なお、記法リファレンスは最新バージョンのMermaid.jsについて書かれているため、記載されている記法の一部はインストールされているバージョン(<%= Redmine::Mermaid.installed_version %>)では使用できない場合があります。<% end %></p>
<p>Mermaid.js はRedmineには同梱されておらず、管理者がインストールした場合にのみ図が表示されます。インストールされていない場合は通常のコードブロックとして表示されます。</p>
<p>Wiki記法に対応している箇所であればどこでも以下の記述により図を描くことができます:</p>
<pre>
```mermaid
Place your diagram definition here.
```
</pre>
<p>表示例:</p>
<pre>
```mermaid
flowchart LR
A[New issue] --&gt; B{Reproducible?}
B --&gt;|Yes| C[Fix]
B --&gt;|No| D[Close]
```
</pre>
<p>以下のようになります</p>
<%= image_tag("help/mermaid_flowchart_decision.png", width: 635, alt: "New issueがReproducible?ならFix、そうでなければCloseに進むフローチャート") %>
<p>表示された図はPNG画像としてダウンロードできます。</p>
<h2><a name="15" class="wiki-page"></a>HTMLを直接使用する</h2>
<p>複数の行や列がが結合している表のような複雑なフォーマットを記述したいときはMarkdown記法を使わずHTMLを直接書くこともできます。</p>
app/views/help/wiki_syntax/textile/en/wiki_syntax_detailed_textile.html.erb
</ul>
<li><a href='#12'>Macros</a></li>
<li><a href='#13'>Code highlighting</a></li>
<li><a href='#15'>Mermaid diagrams</a></li>
</ul>
<h2><a name="2" class="wiki-page"></a>Links</h2>
......
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h2><a name="15" class="wiki-page"></a>Mermaid diagrams</h2>
<p>Code blocks written in the <strong>mermaid</strong> language are rendered as diagrams, such as flowcharts, sequence diagrams and Gantt charts, by <a href="https://mermaid.js.org/" class="external">Mermaid.js</a>. Please refer to the <a href="https://mermaid.js.org/intro/syntax-reference.html" class="external">Mermaid syntax reference</a> for the available diagrams and their syntax.<% if Redmine::Mermaid.installed_version %> Please note that the reference describes the latest version of Mermaid.js, and some of the syntax described there may not be supported by the installed version, <%= Redmine::Mermaid.installed_version %>.<% end %></p>
<p>Mermaid.js is not bundled with Redmine, and diagrams are rendered only if the administrator has installed it. Otherwise, the code is displayed as a plain code block.</p>
<p>You can draw a diagram at any place that supports wiki formatting using this syntax:</p>
<pre>
&lt;pre&gt;&lt;code class="mermaid"&gt;
Place your diagram definition here.
&lt;/code&gt;&lt;/pre&gt;
</pre>
<p>Example:</p>
<pre>
&lt;pre&gt;&lt;code class="mermaid"&gt;
flowchart LR
A[New issue] --&gt; B{Reproducible?}
B --&gt;|Yes| C[Fix]
B --&gt;|No| D[Close]
&lt;/code&gt;&lt;/pre&gt;
</pre>
<p>yields</p>
<%= image_tag("help/mermaid_flowchart_decision.png", width: 635, alt: "Flowchart: a new issue is fixed if it is reproducible, and closed otherwise") %>
<p>A rendered diagram can be downloaded as a PNG image.</p>
</body>
</html>
app/views/help/wiki_syntax/textile/en/wiki_syntax_textile.html.erb
</code></pre>
</td></tr>
<tr><th colspan="3">Mermaid diagrams <span class="more_info">(<a href="<%= help_wiki_syntax_path(:detailed, anchor: "15") %>" target="_blank">more</a>)</span></th></tr>
<tr><th></th><td>&lt;pre&gt;&lt;code class="mermaid"&gt;<br />flowchart TD<br />&nbsp;&nbsp;A[Start] --&gt; B[End]<br />&lt;/code&gt;&lt;/pre&gt;</td><td><%= image_tag("help/mermaid_flowchart_simple.png", width: 168, alt: "Flowchart from Start to End") %></td></tr>
<tr><th colspan="3">Lists</th></tr>
<tr><th><%= image_tag("jstoolbar/list.svg", { alt: "Unordered list" }) %></th><td>* Item 1<br />** Sub<br />* Item 2</td><td><ul><li>Item 1<ul><li>Sub</li></ul></li><li>Item 2</li></ul></td></tr>
<tr><th><%= image_tag("jstoolbar/list-numbers.svg", { alt: "Ordered list" }) %></th><td># Item 1<br />## Sub<br /># Item 2</td><td><ol><li>Item 1<ol><li>Sub</li></ol></li><li>Item 2</li></ol></td></tr>
app/views/help/wiki_syntax/textile/ja/wiki_syntax_detailed_textile.html.erb
</ul>
<li><a href='#12'>マクロ</a></li>
<li><a href='#13'>コードハイライト</a></li>
<li><a href='#15'>Mermaidによる図</a></li>
</ul>
<h2><a name="2" class="wiki-page"></a>リンク</h2>
......
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h2><a name="15" class="wiki-page"></a>Mermaidによる図</h2>
<p>言語に <strong>mermaid</strong> を指定したコードブロックは、<a href="https://mermaid.js.org/" class="external">Mermaid.js</a> によってフローチャート・シーケンス図・ガントチャートなどの図として表示されます。利用できる図の種類と記法は <a href="https://mermaid.js.org/intro/syntax-reference.html" class="external">Mermaidの記法リファレンス</a> を参照してください。<% if Redmine::Mermaid.installed_version %>なお、記法リファレンスは最新バージョンのMermaid.jsについて書かれているため、記載されている記法の一部はインストールされているバージョン(<%= Redmine::Mermaid.installed_version %>)では使用できない場合があります。<% end %></p>
<p>Mermaid.js はRedmineには同梱されておらず、管理者がインストールした場合にのみ図が表示されます。インストールされていない場合は通常のコードブロックとして表示されます。</p>
<p>Wiki記法に対応している箇所であればどこでも以下の記述により図を描くことができます:</p>
<pre>
&lt;pre&gt;&lt;code class="mermaid"&gt;
Place your diagram definition here.
&lt;/code&gt;&lt;/pre&gt;
</pre>
<p>表示例:</p>
<pre>
&lt;pre&gt;&lt;code class="mermaid"&gt;
flowchart LR
A[New issue] --&gt; B{Reproducible?}
B --&gt;|Yes| C[Fix]
B --&gt;|No| D[Close]
&lt;/code&gt;&lt;/pre&gt;
</pre>
<p>以下のようになります</p>
<%= image_tag("help/mermaid_flowchart_decision.png", width: 635, alt: "New issueがReproducible?ならFix、そうでなければCloseに進むフローチャート") %>
<p>表示された図はPNG画像としてダウンロードできます。</p>
</body>
</html>
app/views/help/wiki_syntax/textile/ja/wiki_syntax_textile.html.erb
</code></pre>
</td></tr>
<tr><th colspan="3">Mermaidによる図 <span class="more_info">(<a href="<%= help_wiki_syntax_path(:detailed, anchor: "15") %>" target="_blank">詳細</a>)</span></th></tr>
<tr><th></th><td>&lt;pre&gt;&lt;code class="mermaid"&gt;<br />flowchart TD<br />&nbsp;&nbsp;A[Start] --&gt; B[End]<br />&lt;/code&gt;&lt;/pre&gt;</td><td><%= image_tag("help/mermaid_flowchart_simple.png", width: 168, alt: "StartからEndへのフローチャート") %></td></tr>
<tr><th colspan="3">リスト</th></tr>
<tr><th><%= image_tag("jstoolbar/list.svg", { alt: "リスト" }) %></th><td>* 項目1<br />** 下位階層の項目<br />* 項目2</td><td><ul><li>項目1<ul><li>下位階層の項目</li></ul></li><li>項目2</li></ul></td></tr>
<tr><th><%= image_tag("jstoolbar/list-numbers.svg", { alt: "順序付きリスト" }) %></th><td># 項目1<br />## 下位階層の項目<br /># 項目2</td><td><ol><li>項目1<ol><li>下位階層の項目</li></ol></li><li>項目2</li></ol></td></tr>
test/functional/help_controller_test.rb
end
end
def test_get_help_wiki_syntax_detailed_should_show_installed_mermaid_version
Redmine::Mermaid.stubs(:installed_version).returns('12.0.0')
get :show_wiki_syntax, :params => {:type => 'detailed'}
assert_response :success
assert_select 'p', :text => /not be supported by the installed version, 12\.0\.0\./
Redmine::Mermaid.stubs(:installed_version).returns(nil)
get :show_wiki_syntax, :params => {:type => 'detailed'}
assert_response :success
assert_select 'p', :text => /installed version/, :count => 0
end
def test_get_help_wiki_syntax_should_return_lang_if_available
user = User.find(2)
user.language = 'de'
(1-1/2)