Tuota hyödyllisempiä virheitä huonosti koodatusta syötteestä
This commit is contained in:
parent
824a0e1645
commit
d355a1658d
|
@ -10,6 +10,7 @@ stability: alpha
|
|||
executable gitea-markdown
|
||||
build-depends:
|
||||
base,
|
||||
bytestring,
|
||||
containers,
|
||||
data-default,
|
||||
pandoc,
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
module Gitea.Preview.Markdown where
|
||||
|
||||
import Control.Exception (throwIO)
|
||||
import Data.Default (def)
|
||||
import Text.Pandoc (Pandoc, PandocError, ReaderOptions(..), readMarkdown, runPure, handleError, pandocExtensions, writeHtml5String)
|
||||
import Data.Text (Text)
|
||||
import Data.Text.Encoding (decodeUtf8')
|
||||
import Text.Pandoc (Pandoc, PandocError, ReaderOptions(..), readMarkdown, runPure, handleError, pandocExtensions, writeHtml5String)
|
||||
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.Text.IO as T
|
||||
|
||||
import Gitea.Preview.Markdown.Math
|
||||
|
@ -14,10 +17,13 @@ import Gitea.Preview.Markdown.Signatures
|
|||
|
||||
main :: IO ()
|
||||
main = do
|
||||
input <- T.getContents
|
||||
pandoc <- handleError $ readMD input
|
||||
out <- handleError $ runPure $ writeHtml5String def $ pandocFilter pandoc
|
||||
T.putStr out
|
||||
input <- decodeUtf8' <$> BS.getContents
|
||||
case input of
|
||||
Left err -> throwIO err
|
||||
Right text -> do
|
||||
pandoc <- handleError $ readMD text
|
||||
out <- handleError $ runPure $ writeHtml5String def $ pandocFilter pandoc
|
||||
T.putStr out
|
||||
|
||||
pandocFilter :: Pandoc -> Pandoc
|
||||
pandocFilter = renderSignatures'
|
||||
|
|
Loading…
Reference in New Issue