<commit_before>{-
HAAP: Haskell Automated Assessment Platform

This module provides wrappers to the _pandoc_ library (<https://hackage.haskell.org/package/pandoc>) for inter-format markdown processing.
-}

module HAAP.Web.HTML.Pandoc where

import HAAP.Pretty as PP

import Text.Pandoc.Readers.HTML
import Text.Pandoc.Writers.HTML
import Text.Pandoc
import Text.Parsec.Error

import Data.Default
import Data.Generics

import Debug.Trace

instance Out PandocError where
    docPrec i x = doc x
    doc (ParseFailure str) = text "parsing failure:" <+> text str
    doc (ParsecError _ err) = text "parsing failure:" <+> doc err

instance Out ParseError where
    docPrec i x = doc x
    doc e = text "parsec failed at" <+> text (show $ errorPos e) PP.<> char ':' $+$ nest 4 (vcat $ map doc msgs)
        where msgs = errorMessages e
<commit_msg>ghc 8.4<commit_after>{-
HAAP: Haskell Automated Assessment Platform

This module provides wrappers to the _pandoc_ library (<https://hackage.haskell.org/package/pandoc>) for inter-format markdown processing.
-}

module HAAP.Web.HTML.Pandoc where

import HAAP.Pretty as PP

import Text.Pandoc.Readers.HTML
import Text.Pandoc.Writers.HTML
import Text.Pandoc
import Text.Parsec.Error

import Data.Default
import Data.Generics

import Debug.Trace

instance Out PandocError where
    docPrec i x = doc x
    doc = text . show
    --doc (ParseFailure str) = text "parsing failure:" <+> text str
    --doc (ParsecError _ err) = text "parsing failure:" <+> doc err

instance Out ParseError where
    docPrec i x = doc x
    doc e = text "parsec failed at" <+> text (show $ errorPos e) PP.<> char ':' $+$ nest 4 (vcat $ map doc msgs)
        where msgs = errorMessages e

{'fraction_non_alphanumeric': 0.09683098591549295, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 3.671232876712329, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823095', 'n_tokens_mistral': 575, 'n_tokens_neox': 551, 'n_words': 196}