Skip to content

Commit

Permalink
Replace also div tags not only code tags (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix van Oost <[email protected]>
  • Loading branch information
ChrisOboe and felixvanoost committed Feb 27, 2024
1 parent 229c7ef commit ad0cd99
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/jekyll/kroki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Kroki
SUPPORTED_LANGUAGES = %w[actdiag blockdiag bpmn bytefield c4plantuml d2 dbml diagramsnet ditaa erd excalidraw
graphviz mermaid nomnoml nwdiag packetdiag pikchr plantuml rackdiag seqdiag structurizr
svgbob symbolator tikz umlet vega vegalite wavedrom wireviz].freeze
EXPECTED_HTML_TAGS = %w[code div].freeze
HTTP_MAX_RETRIES = 3

class << self
Expand Down Expand Up @@ -54,10 +55,12 @@ def embed_doc(connection, doc)

rendered_diag = 0
SUPPORTED_LANGUAGES.each do |language|
parsed_doc.css("code[class~='language-#{language}']").each do |diagram_desc|
# Replace the diagram description with the SVG representation rendered by Kroki
diagram_desc.replace(render_diagram(connection, diagram_desc, language))
rendered_diag += 1
EXPECTED_HTML_TAGS.each do |tag|
parsed_doc.css("#{tag}[class~='language-#{language}']").each do |diagram_desc|
# Replace the diagram description with the SVG representation rendered by Kroki
diagram_desc.replace(render_diagram(connection, diagram_desc, language))
rendered_diag += 1
end
end
end

Expand Down

0 comments on commit ad0cd99

Please sign in to comment.