Zulip Chat Archive
Stream: mathlib4
Topic: Map of monads
Adam Topaz (Feb 08 2024 at 19:15):
It seems that our Lean4 monad map isn't rendering very well: https://github.com/leanprover-community/mathlib4/wiki/Monad-map
At least on my computer (with firefox), I see many of the nodes rendered as plaintext html tags. Is anyone else seeing a similar issue?
Damiano Testa (Feb 08 2024 at 19:51):
I see the plaintext html tags also on Chrome on my mobile (Android).
Adam Topaz (Feb 08 2024 at 19:55):
Is this just an issue with how github renders markdown?
Eric Rodriguez (Feb 08 2024 at 19:57):
did this use to work?
Adam Topaz (Feb 08 2024 at 19:58):
it did. But I assume that github's markdown rendering engine changed.
Eric Wieser (Feb 08 2024 at 21:00):
Yeah, it looks like a mermaid update, GitHub bug, or stricter escaping rules broke this
Thomas Murrills (Feb 08 2024 at 22:21):
It seems like using mermaid's click functionality for nodes instead of html or markdown provides a partial workaround? Weirdly, I get a clickable hand and a tooltip showing the link, but clicking doesn't work. However, command-clicking does work. Not sure what to make of that...I'm asking on the mermaid discord server.
Thomas Murrills (Feb 08 2024 at 22:24):
In the meantime it also seems there's also a github discussion about the issue.
Thomas Murrills (Feb 08 2024 at 22:43):
For the time being I updated it to use the partially-working click functionality (meaning you have to command/ctrl click to follow the link) so that it's at least readable. :)
Eric Wieser (Feb 09 2024 at 06:57):
Perhaps it's time to migrate this to the docs
Eric Wieser (Feb 09 2024 at 06:58):
Where we can presumably load mermaid without the security restrictions
Damiano Testa (Feb 29 2024 at 00:35):
With Chrome on Linux, the Monad map is again not working:
Unable to render rich display
Lexical error on line 20. Unrecognized text.
... MetaM -. TermElabM.run ..- TermElabM;
-----------------------^
For more information, see https://docs.github.com/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams
Thomas Murrills (Feb 29 2024 at 03:38):
Fixed :) (At least, on Firefox on Mac. But I think this was due to a change on github's end anyway.)
Damiano Testa (Feb 29 2024 at 07:05):
Thanks! It is fixed for me too!
Thomas Murrills (Mar 06 2024 at 19:53):
GitHub notified me (via discussion update) that anchor links are working again for mermaid! :) I updated the monad map so that
- all nodes have links
- all edge labels have links (new)
- all links point directly to the docs page for that declaration instead of a search query for the declaration
Thomas Murrills (Mar 06 2024 at 19:55):
Also, apparently Simp.M
no longer exists (there used to be both Simp.M
and SimpM
), so I removed it. (SimpAll.M
still exists, but I figured the map was good enough without it.)
Thomas Murrills (Mar 06 2024 at 19:57):
Going from a declaration to a URL might exist somewhere in docgen, but in case the map needs to be updated at some point, here's the quick code I used to generate anchors (#docs_url
is included just for completeness):
import Lean
import ImportGraph.RequiredModules
open Lean Elab Command
def toDocsURL (n : Ident) : CommandElabM String := do
let n ← resolveGlobalConstNoOverload n
let some module := (← getEnv).getModuleFor? n
| throwError "could not find module for {n}"
let path := module.toStringWithSep "/" true
return "https://leanprover-community.github.io/mathlib4_docs/" ++ path ++ ".html#" ++ n.toString
elab "#docs_url " n:ident : command => do logInfo (← toDocsURL n)
-- Note: ident's are printed as strings with a leading "`", so drop it
elab "#anchor " n:ident : command => do logInfo <|
"<a href='" ++ (← toDocsURL n) ++ "'>" ++ (s!"{n}</a>").drop 1
Eric Wieser (Mar 06 2024 at 20:42):
You can find out that "somewhere" by looking at where docs#Nat leads to (before the redirect)
Thomas Murrills (Mar 06 2024 at 21:35):
Ah, ok—simply fully resolving the name would have been enough, then! (It's easy to move to ?pattern=
style with a regex replacement, but it turns out the redirect takes a second extra when following the link—so I figure I'll leave it as is, at the cost of slightly busier source for that diagram. Hopefully none of these declarations will be moving very soon. :) )
Last updated: May 02 2025 at 03:31 UTC