<commit_before>-- | A renderer that produces a native Haskell 'String', mostly meant for
-- debugging purposes.
--
{-# LANGUAGE OverloadedStrings #-}
module Text.Blaze.Renderer.String
    ( fromChoiceString
    , renderHtml
    ) where

import Data.List (isInfixOf)

import qualified Data.ByteString.Char8 as SBC
import qualified Data.Text as T
import qualified Data.ByteString as S

import Text.Blaze.Internal

-- | Escape HTML entities in a string
--
escapeHtmlEntities :: String  -- ^ String to escape
                   -> String  -- ^ String to append
                   -> String  -- ^ Resulting string
escapeHtmlEntities []     k = k
escapeHtmlEntities (c:cs) k = case c of
    '<'  -> "&lt;"   ++ escapeHtmlEntities cs k
    '>'  -> "&gt;"   ++ escapeHtmlEntities cs k
    '&'  -> "&amp;"  ++ escapeHtmlEntities cs k
    '"'  -> "&quot;" ++ escapeHtmlEntities cs k
    '\'' -> "&apos;" ++ escapeHtmlEntities cs k
    x    -> x : escapeHtmlEntities cs k
<commit_msg>Use &#39; instead of &apos;<commit_after>-- | A renderer that produces a native Haskell 'String', mostly meant for
-- debugging purposes.
--
{-# LANGUAGE OverloadedStrings #-}
module Text.Blaze.Renderer.String
    ( fromChoiceString
    , renderHtml
    ) where

import Data.List (isInfixOf)

import qualified Data.ByteString.Char8 as SBC
import qualified Data.Text as T
import qualified Data.ByteString as S

import Text.Blaze.Internal

-- | Escape HTML entities in a string
--
escapeHtmlEntities :: String  -- ^ String to escape
                   -> String  -- ^ String to append
                   -> String  -- ^ Resulting string
escapeHtmlEntities []     k = k
escapeHtmlEntities (c:cs) k = case c of
    '<'  -> "&lt;"   ++ escapeHtmlEntities cs k
    '>'  -> "&gt;"   ++ escapeHtmlEntities cs k
    '&'  -> "&amp;"  ++ escapeHtmlEntities cs k
    '"'  -> "&quot;" ++ escapeHtmlEntities cs k
    '\'' -> "&#39;"  ++ escapeHtmlEntities cs k
    x    -> x : escapeHtmlEntities cs k

{'fraction_non_alphanumeric': 0.12653061224489795, 'fraction_numerical': 0.003061224489795918, 'mean_word_length': 2.6180811808118083, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, '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': '6512979', 'n_tokens_mistral': 592, 'n_tokens_neox': 602, 'n_words': 190}