Skip to content

Commit b6bc7b8

Browse files
committed
Show LaTeX math expressions in haddockToMarkdown
- Replace fallback messages with raw LaTeX math expressions using $...$ and $$...$$. - This lets editors display the original math content even if they don't render LaTeX. - No sanitization is performed, raw LaTeX is output as-is.
1 parent 0a52558 commit b6bc7b8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ghcide/src/Development/IDE/Spans/Common.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,10 @@ haddockToMarkdown (H.DocOrderedList things) =
190190
haddockToMarkdown (H.DocDefList things)
191191
= '\n' : (unlines $ map (\(term, defn) -> "+ **" ++ haddockToMarkdown term ++ "**: " ++ haddockToMarkdown defn) things)
192192

193-
-- we cannot render math by default
194-
haddockToMarkdown (H.DocMathInline _)
195-
= "*cannot render inline math formula*"
196-
haddockToMarkdown (H.DocMathDisplay _)
197-
= "\n\n*cannot render display math formula*\n\n"
193+
haddockToMarkdown (H.DocMathInline s)
194+
= "$" ++ s ++ "$"
195+
haddockToMarkdown (H.DocMathDisplay s)
196+
= "\n$$\n" ++ s ++ "\n$$\n"
198197

199198
-- TODO: render tables
200199
haddockToMarkdown (H.DocTable _t)

0 commit comments

Comments
 (0)