diff options
Diffstat (limited to 'haddock-library/src/Documentation/Haddock')
-rw-r--r-- | haddock-library/src/Documentation/Haddock/Parser.hs | 16 | ||||
-rw-r--r-- | haddock-library/src/Documentation/Haddock/Types.hs | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs index ca9e9d8d..919ea37f 100644 --- a/haddock-library/src/Documentation/Haddock/Parser.hs +++ b/haddock-library/src/Documentation/Haddock/Parser.hs @@ -73,6 +73,7 @@ overIdentifier f d = g d g (DocCodeBlock x) = DocCodeBlock $ g x g (DocHyperlink x) = DocHyperlink x g (DocPic x) = DocPic x + g (DocMathInline x) = DocMathInline x g (DocAName x) = DocAName x g (DocProperty x) = DocProperty x g (DocExamples x) = DocExamples x @@ -113,7 +114,8 @@ parseStringBS = snd . parse p where p :: Parser (DocH mod Identifier) p = docConcat <$> many (monospace <|> anchor <|> identifier <|> moduleName - <|> picture <|> markdownImage <|> hyperlink <|> bold + <|> picture <|> mathDisplay <|> markdownImage + <|> hyperlink <|> bold <|> emphasis <|> encodedChar <|> string' <|> skipSpecialChar) @@ -224,6 +226,18 @@ picture :: Parser (DocH mod a) picture = DocPic . makeLabeled Picture . decodeUtf8 <$> disallowNewline ("<<" *> takeUntil ">>") +-- FIXME: I have just copied the code for `picture` but it is not +-- clear why we should disallow a newline (if that is what +-- `disallowNewline` does) + +-- | Inline math parser, surrounded by \$\$ and \$\$. +-- +-- >>> parseString "$$\int_{-infty}^{infty} e^{-x^2/2} = \sqrt{2\pi}$$" +-- DocMathInline (DocString "\int_{-infty}^{infty} e^{-x^2/2} = \sqrt{2\pi}") +mathDisplay :: Parser (DocH mod a) +mathDisplay = DocMathInline . decodeUtf8 + <$> disallowNewline ("$$" *> takeUntil "$$") + markdownImage :: Parser (DocH mod a) markdownImage = fromHyperlink <$> ("!" *> linkParser) where diff --git a/haddock-library/src/Documentation/Haddock/Types.hs b/haddock-library/src/Documentation/Haddock/Types.hs index 4ef89658..2b1e7f26 100644 --- a/haddock-library/src/Documentation/Haddock/Types.hs +++ b/haddock-library/src/Documentation/Haddock/Types.hs @@ -71,6 +71,7 @@ data DocH mod id | DocCodeBlock (DocH mod id) | DocHyperlink Hyperlink | DocPic Picture + | DocMathInline String | DocAName String | DocProperty String | DocExamples [Example] |