redact-0.5.0.0: hide secret text on the terminal
CopyrightCopyright (c) 2020-2023 Travis Cardwell
LicenseMIT
Safe HaskellSafe-Inferred
LanguageHaskell2010

Redact.Markdown

Description

Markdown inline code (text enclosed in backticks) is redacted. This redacted text may not span multiple lines. Example:

The word hidden is redacted.

Markdown fenced code (text in between lines of three or more backticks is redacted. The number of backticks is not matched. The backticks in the beginning line may optionally be followed by addition text, which is ignored. Example:

```
All lines of text between the backticks
are hidden.
```
Synopsis

Types

data Line Source #

Lines of redacted text

Since: 0.4.0.0

Constructors

NormalLine ![Part]

normal line of text

RedactLine !Text

fully-redacted line of text

Instances

Instances details
Show Line Source # 
Instance details

Defined in Redact.Types

Methods

showsPrec :: Int -> Line -> ShowS #

show :: Line -> String #

showList :: [Line] -> ShowS #

Eq Line Source # 
Instance details

Defined in Redact.Types

Methods

(==) :: Line -> Line -> Bool #

(/=) :: Line -> Line -> Bool #

data Part Source #

Parts of a normal line

Since: 0.4.0.0

Constructors

Stet !Text

text intended to be displayed as-is

Redact !Text

text intended to be made unreadable

Instances

Instances details
Show Part Source # 
Instance details

Defined in Redact.Types

Methods

showsPrec :: Int -> Part -> ShowS #

show :: Part -> String #

showList :: [Part] -> ShowS #

Eq Part Source # 
Instance details

Defined in Redact.Types

Methods

(==) :: Part -> Part -> Bool #

(/=) :: Part -> Part -> Bool #

data Error Source #

Error sum type

Since: 0.4.0.0

Constructors

IOError !IOError

I/O error

RedactError !String

redact parsing error

Instances

Instances details
Show Error Source # 
Instance details

Defined in Redact.Types

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

Eq Error Source # 
Instance details

Defined in Redact.Types

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

Pure API

redact :: Text -> Either String [Line] Source #

Redact text strictly

This function fails if inline or fenced code is not closed.

Since: 0.4.0.0

redact' :: Text -> [Line] Source #

Redact text leniently

This function does not fail if inline or fenced code is not closed.

Since: 0.4.0.0

Terminal API

textToTerminal Source #

Arguments

:: MonadTerminal m 
=> [SGR]

SGRs for redacted text

-> Text 
-> m (Either Error ()) 

Redact text strictly, putting it to the terminal

Since: 0.4.0.0

textToTerminal' Source #

Arguments

:: MonadTerminal m 
=> [SGR]

SGRs for redacted text

-> Text 
-> m () 

Redact text leniently, putting it to the terminal

Since: 0.4.0.0

handleToTerminal Source #

Arguments

:: (MonadHandle m, MonadTerminal m) 
=> [SGR]

SGRs for redacted text

-> Handle 
-> m (Either Error ()) 

Redact text from a Handle strictly, putting it to the terminal

Since: 0.4.0.0

handleToTerminal' Source #

Arguments

:: (MonadHandle m, MonadTerminal m) 
=> [SGR]

SGRs for redacted text

-> Handle 
-> m () 

Redact text from a Handle leniently, putting it to the terminal

Since: 0.4.0.0

fileToTerminal Source #

Arguments

:: (MonadHandle m, MonadTerminal m) 
=> [SGR]

SGRs for redacted text

-> FilePath 
-> m (Either Error ()) 

Redact text from a file strictly, putting it to the terminal

Since: 0.4.0.0

fileToTerminal' Source #

Arguments

:: (MonadHandle m, MonadTerminal m) 
=> [SGR]

SGRs for redacted text

-> FilePath 
-> m (Either Error ()) 

Redact text from a file leniently, putting it to the terminal

Since: 0.4.0.0

Internal

redactLine :: Text -> Maybe Line Source #

Redact a NormalLine strictly

redactLine' :: Text -> Line Source #

Redact a NormalLine leniently