Skip to content

Commit

Permalink
(core/wiki) Replace Mermaid component to helper notation
Browse files Browse the repository at this point in the history
  • Loading branch information
malkoG committed Nov 20, 2023
1 parent b5df468 commit e3f7a3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions plugins/builders/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Builders::Helpers < SiteBuilder
def build
helper :mermaid do |&block|
<<~HTML.html_safe
<pre class="mermaid">
#{helpers.view.capture(&block)}
</pre>
HTML
end
end
end

2 changes: 1 addition & 1 deletion plugins/builders/toc_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_html(toc_node)
toc_node.children.each do |child|
if child.value.options[:raw_text].present?
text = child.value.options[:raw_text]
next if text.include?('Mermaid.new')
next if text.include?('mermaid do')
end
html << "<li>"
if child.value.options[:raw_text].present?
Expand Down
10 changes: 5 additions & 5 deletions src/_wiki/mermaid.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags: prelude

## Flowchart

<%= render(Mermaid.new) do %>
<%= mermaid do %>
flowchart LR
A[Hard edge] -->|Link text| B(Round edge)
B --> C{Decision}
Expand All @@ -17,15 +17,15 @@ flowchart LR

## Class diagram

<%= render(Mermaid.new) do %>
<%= mermaid do %>
classDiagram
class Animal
Vehicle <|-- Car
<% end %>

## State diagram

<%= render(Mermaid.new) do %>
<%= mermaid do %>
---
title: Simple sample
---
Expand All @@ -43,7 +43,7 @@ stateDiagram-v2
## Git Commit Diagram


<%= render(Mermaid.new) do %>
<%= mermaid do %>
---
title: Example Git diagram
---
Expand All @@ -62,7 +62,7 @@ gitGraph

## Mindmap

<%= render(Mermaid.new) do %>
<%= mermaid do %>
mindmap
root((mindmap))
Origins
Expand Down

0 comments on commit e3f7a3b

Please sign in to comment.