@@ -38,6 +38,20 @@ inline_extension Inline.errorExplanationLink (errorName : Name) where
3838 logError s! "Could not find external tag for error explanation '{ name} ' corresponding to ID '{ id} '"
3939 content.mapM go
4040
41+ /- Renders the suffix of an error explanation, allowing line breaks before capital letters. -/
42+ inline_extension Inline.errorExplanationShortName (errorName : Name) where
43+ data := toJson (getBreakableSuffix errorName)
44+ traverse := fun _ _ _ => pure none
45+ extraCss := [".error-explanation-short-name { hyphenate-character: ''; }" ]
46+ toTeX := none
47+ toHtml := some fun _go _id info _content =>
48+ open Verso.Output Html in do
49+ let .ok (some errorName) := fromJson? (α := Option String) info
50+ | HtmlT.logError "Invalid data for explanation name element"
51+ pure .empty
52+ let html := {{ <code class ="error-explanation-short-name" >{{errorName}}</code> }}
53+ return html
54+
4155@[block_role_expander error_explanation_table]
4256def error_explanation_table : BlockRoleExpander
4357 | #[], #[] => do
@@ -49,11 +63,10 @@ def error_explanation_table : BlockRoleExpander
4963 let headers ← #["Name" , "Summary" , "Severity" , "Since" ]
5064 |>.mapM fun s => ``(Verso.Doc.Block.para #[Doc.Inline.text $(quote s)])
5165 let vals ← entries.flatMapM fun (name, explan) => do
52- let sev := quote <|
53- if explan.metadata.severity == .warning then "Warning" else "Error"
66+ let sev := quote <| if explan.metadata.severity == .warning then "Warning" else "Error"
5467 let sev ← ``(Doc.Inline.text $sev)
55- let nameStr := toString name
56- let nameLink ← ``( Doc.Inline.other (Inline.errorExplanationLink $(quote name)) #[Doc.Inline.code $(quote nameStr) ])
68+ let nameLink ← ``(Doc.Inline.other (Inline.errorExplanationLink $(quote name))
69+ #[ Doc.Inline.other (Inline.errorExplanationShortName $(quote name)) #[] ])
5770 let summary ← ``(Doc.Inline.text $(quote explan.metadata.summary))
5871 let since ← ``(Doc.Inline.text $(quote explan.metadata.sinceVersion))
5972 #[nameLink, summary, sev, since]
@@ -72,7 +85,8 @@ htmlToc := false
7285%%%
7386
7487This section provides explanations of errors and warnings that may be generated
75- by Lean when processing a source file.
88+ by Lean when processing a source file. All error names listed below have the
89+ `lean` package prefix.
7690
7791{error_explanation_table}
7892
0 commit comments