comparison src/bbcode/Bbcode.luan @ 48:4e1a01db19ec

add lists
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 17 Nov 2022 00:11:44 -0700
parents 2d4f00755092
children f225e82b2bf8
comparison
equal deleted inserted replaced
47:7ef9222474e2 48:4e1a01db19ec
210 end 210 end
211 211
212 local function list_to_html(bbcode,options) 212 local function list_to_html(bbcode,options)
213 local list = to_list(bbcode.contents) 213 local list = to_list(bbcode.contents)
214 for _, item in ipairs(list) do 214 for _, item in ipairs(list) do
215 if type(item) == "table" and item.name == "li" then 215 if type(item) == "table" and item.name == "item" then
216 %><li><% to_html(item.contents,options) %></li><% 216 %><li><% to_html(item.contents,options) %></li><%
217 end 217 end
218 end 218 end
219 options.strip_newline = true 219 options.strip_newline = true
220 end 220 end
221 221
222 function html.ul(bbcode,options) 222 function html.list(bbcode,options)
223 %><ul><% 223 local tag = bbcode.param == "1" and "ol" or "ul"
224 %><<%=tag%>><%
224 list_to_html(bbcode,options) 225 list_to_html(bbcode,options)
225 %></ul><% 226 %></<%=tag%>><%
226 end
227
228 function html.ol(bbcode,options)
229 %><ol><%
230 list_to_html(bbcode,options)
231 %></ol><%
232 end 227 end
233 228
234 function to_html(bbcode,options) 229 function to_html(bbcode,options)
235 if options.strip_newline then 230 if options.strip_newline then
236 if type(bbcode) == "string" then 231 if type(bbcode) == "string" then