9c4464a8b6f85855c9e758f04f0b811403efb64f
lrnassar
  Thu Sep 19 16:00:34 2024 -0700
Adding a new --filter to the pandoc run linking to a file with special cases we want handled by the conversion. This first case takes an image code block and converts it to an html image tag with source and width specified. Refs #30335

diff --git docs/GBpandocHTMLrules.lua docs/GBpandocHTMLrules.lua
new file mode 100644
index 0000000..399bd37
--- /dev/null
+++ docs/GBpandocHTMLrules.lua
@@ -0,0 +1,26 @@
+-- Function to create an HTML image tag with a given src and width
+function add_image(src, width)
+  -- Ensure src and width are provided
+  if src == nil or width == nil then
+    error("Error: src or width is nil in add_image")
+  end
+  return string.format('<img src="%s" width="%s">', src, width)
+end
+
+-- Function to detect and process code blocks with class "image"
+function CodeBlock(el)
+  -- Check if the code block is tagged with the class "image"
+  if el.classes[1] == "image" then
+    -- Extract src and width from the code block text
+    local src = el.text:match("src=(%S+)")
+    local width = el.text:match("width=(%S+)")
+    
+    -- Ensure that both src and width are captured
+    if src and width then
+      return pandoc.RawBlock("html", add_image(src, width))
+    else
+      error("Error: src or width not found in block")
+    end
+  end
+  return el  -- Return the unchanged element if it's not an image block
+end