@@ -34,10 +34,16 @@ function RawInline(el)
34
34
return el
35
35
end
36
36
37
+ -- function CodeBlock(el)
38
+ -- -- Use native CodeBlock to prevent `{=markdown}` wrapping
39
+ -- local lang = el.classes[1] or "sh" -- Preserve language if available
40
+ -- return pandoc.CodeBlock(el.text, lang)
41
+ -- end
42
+
37
43
function CodeBlock (el )
38
- -- Use native CodeBlock to prevent `{=markdown}` wrapping
44
+ -- Ensure fenced code blocks with backticks
39
45
local lang = el .classes [1 ] or " sh" -- Preserve language if available
40
- return pandoc .CodeBlock ( el .text , lang )
46
+ return pandoc .RawBlock ( " markdown " , " ``` " .. lang .. " \n " .. el .text .. " \n ``` " )
41
47
end
42
48
43
49
function wrap_text (text , max_length , indent )
95
101
-- return pandoc.Para({pandoc.RawInline("markdown", "")})
96
102
-- end
97
103
98
- -- function DefinitionList(el)
99
- -- local new_blocks = {}
104
+ function DefinitionList (el )
105
+ local new_blocks = {}
100
106
101
- -- for _, item in ipairs(el.content) do
102
- -- local term = item[1] -- Term (<dt>)
103
- -- local definitions = item[2] -- Definitions (<dd>)
104
-
105
- -- -- Split the term into separate parts: first word as header, rest as sub-item
106
- -- if #term > 1 then
107
- -- -- First part of the term becomes the header (###)
108
- -- -- term[1] = term[1].src
109
- -- table.insert(new_blocks, pandoc.Header(3, term[1], {}))
110
-
111
- -- -- Remaining parts are combined and formatted (e.g., italicized)
112
- -- local sub_term = {}
113
- -- for i = 2, #term do
114
- -- table.insert(sub_term, term[i])
115
- -- end
116
- -- table.insert(new_blocks, pandoc.Para(sub_term))
117
- -- else
118
- -- -- If the term is simple, just use it as a header
119
- -- table.insert(new_blocks, pandoc.Header(3, term, {}))
120
- -- end
121
-
122
- -- -- Process the definitions and convert to blockquote format
123
- -- for _, def in ipairs(definitions) do
124
- -- table.insert(new_blocks, pandoc.BlockQuote(def))
125
- -- end
126
- -- end
107
+ for _ , item in ipairs (el .content ) do
108
+ local term = item [1 ] -- Term (<dt>)
109
+ local definitions = item [2 ] -- Definitions (<dd>)
127
110
128
- -- return new_blocks
129
- -- end
111
+ -- Split the term into separate parts: first word as header, rest as sub-item
112
+ if # term > 1 then
113
+ -- First part of the term becomes the header (###)
114
+ -- term[1] = term[1].src
115
+ table.insert (new_blocks , pandoc .Header (3 , term [1 ], {}))
116
+
117
+ -- Remaining parts are combined and formatted (e.g., italicized)
118
+ local sub_term = {}
119
+ for i = 2 , # term do
120
+ table.insert (sub_term , term [i ])
121
+ end
122
+ table.insert (new_blocks , pandoc .Para (sub_term ))
123
+ else
124
+ -- If the term is simple, just use it as a header
125
+ table.insert (new_blocks , pandoc .Header (3 , term , {}))
126
+ end
127
+
128
+ -- Process the definitions and convert to blockquote format
129
+ for _ , def in ipairs (definitions ) do
130
+ table.insert (new_blocks , pandoc .BlockQuote (def ))
131
+ end
132
+ end
133
+
134
+ return new_blocks
135
+ end
130
136
131
137
function TableCell (el )
132
138
-- Remove inline styles from table cells
0 commit comments