@@ -275,19 +275,21 @@ elab_rules : command
275275 let dirName := x.getId ++ `directive |> mkIdentFrom x
276276 let (toHtml?, other) ← splitToHtml contents
277277 let noJson ← argNames.mapM deJson
278- let arr : TSyntax `Lean.Parser.Term.doSeqItem ←
279- if !argNames.isEmpty then
280- `(Lean.Parser.Term.doSeqItem|
281- let .arr #[$(argNames.map (·.1 )),*] := json
282- | HtmlT.logError s! "Expected array, got { json} "
283- return .empty)
284- else `(Lean.Parser.Term.doSeqItem|pure ())
285278 let toHtml ← toHtml?.mapM fun tm =>
286- `(Lean.Parser.Term.structInstField|
287- toHtml id json goI goB contents := do
288- $arr
289- $noJson*
290- ($tm id json goI goB contents))
279+ if argNames.isEmpty then
280+ `(Lean.Parser.Term.structInstField|
281+ toHtml id json goI goB contents := do
282+ ($tm id json goI goB contents))
283+ else
284+ `(Lean.Parser.Term.structInstField|
285+ toHtml id json goI goB contents := do
286+ match json with
287+ | .arr #[$(argNames.map (·.1 )),*] => do
288+ $noJson*
289+ ($tm id json goI goB contents)
290+ | _ => do
291+ HtmlT.logError s! "Expected array, got { json} "
292+ return .empty)
291293 let other := toHtml.toArray ++ other
292294 let cmd2 ←
293295 `(command|
@@ -325,19 +327,21 @@ elab_rules : command
325327 let compName := x.getId ++ `comp |> mkIdentFrom x
326328 let (toHtml?, other) ← splitToHtml contents
327329 let noJson ← argNames.mapM deJson
328- let arr : TSyntax `Lean.Parser.Term.doSeqItem ←
329- if !argNames.isEmpty then
330- `(Lean.Parser.Term.doSeqItem|
331- let .arr #[$(argNames.map (·.1 )),*] := json
332- | HtmlT.logError s! "Expected array, got { json} "
333- return .empty)
334- else `(Lean.Parser.Term.doSeqItem|pure ())
335330 let toHtml ← toHtml?.mapM fun tm =>
336- `(Lean.Parser.Term.structInstField|
337- toHtml id json goI contents := do
338- $arr
339- $noJson*
340- ($tm id json goI contents))
331+ if argNames.isEmpty then
332+ `(Lean.Parser.Term.structInstField|
333+ toHtml id json goI contents := do
334+ ($tm id json goI contents))
335+ else
336+ `(Lean.Parser.Term.structInstField|
337+ toHtml id json goI contents := do
338+ match json with
339+ | .arr #[$(argNames.map (·.1 )),*] => do
340+ $noJson*
341+ ($tm id json goI contents)
342+ | _ => do
343+ HtmlT.logError s! "Expected array, got { json} "
344+ return .empty)
341345 let other := toHtml.toArray ++ other
342346 let cmd2 ←
343347 `(command|
0 commit comments