Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace also div tags not only code tags #22

Merged
merged 6 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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