Skip to content

Conversation

@kpadmasola
Copy link

Generate placeholder text for missing toTex implementations instead failing.

@kpadmasola
Copy link
Author

@david-christiansen With this change, the main.tex gets generated. However, running lualatex main.tex fails with errors. I have categorized the errors below along with the fixes to enable successful conversion to main.pdf.

  • FIX: Need to add the following for showing error text in red color
    \usepackage{xcolor}
    \colorlet{RED}{black}
  • FIX: Replace \Verb with \verb
  • ERROR: Cannot have verbatim text inside section titles
  • ERROR: LaTeX Error: \verb ended by end of line — happens in hyperlink args
    • e.g., in \hyperlink{"https://lean-lang.org/doc/reference/4.23.0-rc2/find/?domain=Verso.Genre.Manual.section&name=do-notation"}{\verb|do|
      -notation}.Because the resulting value is treated as a side-effect-free term, the compiler may re-order,`
    • FIX: use \texttt instead
  • ERROR: LaTeX Error: Command \item invalid in math mode.
    • e.g., .\item The syntax \verb|have (eq := h) pat := e|
      is equivalent to \verb|match h : e with | pat => _|
    • FIX: In the second line there is a | inside \verb
    • So we should use some other delimiter character, such as !
    • Or use \begin{verbatim}
    • Also \item should probably begin on a new line, perhaps?
  • ERROR: LaTeX Error: Lonely \item--perhaps a missing list environment.
    • Issue due to \hyperlink second arg having underscore
    • FIX: escape underscore
  • ERROR: ! Text line contains an invalid character.
    • e.g., l.32508 ... or. Usually accessed via the \verb|^^^
    • FIX: Try \verb|\^\^\^|
  • ERROR: LaTeX Error: \verb illegal in argument.
    • FIX: Replace with \texttt instead

Copy link
Collaborator

@david-christiansen david-christiansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start! Thanks!

But I think it's important that authors don't have to proofread their document to know if something went wrong. The best situation is that they get error messages and a non-zero return code, but also output that is as readable as possible.

let some descr := (← readThe ExtensionImpls).getBlock? b.name
| panic! s!"Unknown block {b.name} while rendering.\n\nKnown blocks: {(← readThe ExtensionImpls).blockDescrs.toArray |>.map (·.fst) |>.qsort (·.toString < ·.toString)}"
let some impl := descr.toTeX
| TeX.logError s!"Block {b.name} doesn't support TeX"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error message should be retained. It's important to prominently tell authors that their document isn't as they expect, without them needing to proofread the resulting text.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

let some descr := (← readThe ExtensionImpls).getInline? i.name
| panic! s!"Unknown inline {i.name} while rendering.\n\nKnown inlines: {(← readThe ExtensionImpls).inlineDescrs.toArray |>.map (·.fst) |>.qsort (·.toString < ·.toString)}"
let some impl := descr.toTeX
| TeX.logError s!"Inline {i.name} doesn't support TeX"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I think this error message should be retained too. It's good to emit better TeX though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

def header [Monad m] (name : TeX) : TeXT g m TeX := do
let opts ← options
let some i := opts.headerLevel
| logError s!"No more header nesting available at {name.asString}"; return \TeX{\textbf{\Lean{name}}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be a proper error, and it should insert a notice like the other two into the document that is unmistakable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@david-christiansen
Copy link
Collaborator

Thanks for the big list of things that need fixing! That'll be really helpful to check off as it goes.

@kpadmasola kpadmasola marked this pull request as ready for review August 28, 2025 09:19
@david-christiansen
Copy link
Collaborator

I'm away from the computer for a few days but will look again as soon as I'm back. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants