Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/tests/Tests/LiterateHtml.lean
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ private def testAllBuiltinDocRoles (data : TestData) : IO Unit := withTestDir da
unless hasSubstring jsonContent "\"content\":\"lhs\",\"kind\":{\"keyword\":{\"docs\":\"" do
throw <| IO.userError "Builtins JSON has no docs on the `lhs` keyword token. \
The conv handler did not attach the syntax kind's docstring."
unless hasSubstring jsonContent "{\"content\":\"funext\",\"kind\":{\"keyword\":{\"docs\":\"" do
throw <| IO.userError "Builtins JSON has no docs on the `funext` keyword token. \
The kw handler did not attach the syntax kind's docstring."

/--
Checks that user-registered `@[inline_to_literate]` and `@[block_to_literate]` handlers shadow the
Expand Down
13 changes: 7 additions & 6 deletions src/verso-literate/VersoLiterate/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,13 @@ def handleConvTactic : InlineToLiterate
| _, _, _ => pure none

def handleKwAtom : InlineToLiterate
| name, _val, content => do
-- Data.Atom is mistakenly marked private in Lean. Here's a workaround until we fix that.
-- Check the name's suffix because private names have a mangled prefix:
unless name.toString.endsWith "Lean.Doc.Data.Atom" do return none
let some s := (match content with | #[.code s] => some s | _ => none) | return none
return some <| .other (.highlighted <| .token ⟨.keyword none none none, s⟩) content
| ``Lean.Doc.Data.Atom, val, content => do
if let some { name, .. } := val.get? Lean.Doc.Data.Atom then
let #[.code s] := content | return none
let docs ← findDocString? (← getEnv) name
return some <| .other (.highlighted <| .token ⟨.keyword (some name) none docs, s⟩) content
throwError "Wrong data"
| _, _, _ => pure none

def handleSyntax : InlineToLiterate
| ``Lean.Doc.Data.Syntax, val, content => do
Expand Down
2 changes: 1 addition & 1 deletion test-projects/literate-config/LitConfig/Builtins.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set_option doc.verso.suggestions false in

{syntaxCat}`term` is a syntax category, and {syntax term}`1 + [] - (· / ·)` is syntax in it.

{kw (of := Lean.«command__Unif_hint____Where_|_-⊢__»)}`unif_hint` is a keyword atom.
{kw}`funext` is a keyword atom.
{kw? (of := Lean.«command__Unif_hint____Where_|_-⊢__»)}`where` is also a keyword atom, and
{kw! (of := Lean.Parser.Command.definition)}`def` is an unchecked keyword atom.

Expand Down