/- Copyright (c) 2024 Joseph Tooby-Smith. All rights reserved. Released under Apache 2.0 license. Authors: Joseph Tooby-Smith -/ -- import DocGen4.Output.DocString import HepLean.Meta.Informal.Post import HepLean.Meta.Notes.NoteFile /-! ## Turns a delaration into a html note structure. -/ namespace HepLean open Lean /-- A `HTMLNote` is a structure containing the html information from individual contributions (commands, informal commands, note ..) etc. to a note file. -/ structure HTMLNote where /-- The name of the file the contribution came from. -/ fileName : Name /-- The html contribution of the content. -/ content : String /-- The line in the file where the contribution came from. -/ line : Nat /-- Converts a note info into a HTMLNote. -/ def HTMLNote.ofNodeInfo (ni : NoteInfo) : HTMLNote := { ni with } /-- An formal definition or lemma to html for a note. -/ def HTMLNote.ofFormal (name : Name) : CoreM HTMLNote := do let line ← name.lineNumber let fileName ← name.fileName return { fileName, line, content := s!"
View/Improve
{← name.getDeclString}
" } /-- An informal definition or lemma to html for a note. -/ unsafe def HTMLNote.ofInformal (name : Name) : CoreM HTMLNote := do let line ← name.lineNumber let fileName ← name.fileName let constInfo ← getConstInfoDefn name let webAddress := fileName.toGitHubLink line let mut content := "" if constInfo.type.isConstOf ``InformalDefinition then let doc ← name.getDocString -- let html ← DocGen4.Output.docStringToHtml doc name.toString -- let X ← Informal.constantInfoToInformalDefinition constInfo -- let fragment := X.math.replace "\n" "
" let fragment := doc.replace "\n" "
" content := s!"
Improve/Formalize Informal definition: {name}
{fragment}
" else if constInfo.type.isConstOf ``InformalLemma then -- let X ← Informal.constantInfoToInformalLemma constInfo -- let fragment := X.math.replace "\n" "
" let doc ← name.getDocString let fragment := doc.replace "\n" "
" content := s!"
Improve/Formalize Informal lemma: {name}
{fragment}
" return { content, fileName, line } end HepLean