| Copyright | Copyright (c) 2020-2024 Travis Cardwell |
|---|---|
| License | MIT |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
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
- data Line
- = NormalLine ![Part]
- | RedactLine !Text
- data Part
- data Error
- = IOError !IOError
- | RedactError !String
- redact :: Text -> Either String [Line]
- redact' :: Text -> [Line]
- textToTerminal :: MonadTerminal m => [SGR] -> Text -> m (Either Error ())
- textToTerminal' :: MonadTerminal m => [SGR] -> Text -> m ()
- handleToTerminal :: (MonadHandle m, MonadTerminal m) => [SGR] -> Handle -> m (Either Error ())
- handleToTerminal' :: (MonadHandle m, MonadTerminal m) => [SGR] -> Handle -> m ()
- fileToTerminal :: (MonadHandle m, MonadTerminal m) => [SGR] -> FilePath -> m (Either Error ())
- fileToTerminal' :: (MonadHandle m, MonadTerminal m) => [SGR] -> FilePath -> m (Either Error ())
- redactLine :: Text -> Maybe Line
- redactLine' :: Text -> Line
Types
Lines of redacted text
Since: 0.4.0.0
Constructors
| NormalLine ![Part] | normal line of text |
| RedactLine !Text | fully-redacted line of text |
Parts of a normal line
Since: 0.4.0.0
Error sum type
Since: 0.4.0.0
Constructors
| IOError !IOError | I/O error |
| RedactError !String | redact parsing error |
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
Redact text strictly, putting it to the terminal
Since: 0.4.0.0
Arguments
| :: MonadTerminal m | |
| => [SGR] |
|
| -> Text | |
| -> m () |
Redact text leniently, putting it to the terminal
Since: 0.4.0.0
Arguments
| :: (MonadHandle m, MonadTerminal m) | |
| => [SGR] |
|
| -> Handle | |
| -> m (Either Error ()) |
Redact text from a Handle strictly, putting it to the terminal
Since: 0.4.0.0
Arguments
| :: (MonadHandle m, MonadTerminal m) | |
| => [SGR] |
|
| -> Handle | |
| -> m () |
Redact text from a Handle leniently, putting it to the terminal
Since: 0.4.0.0
Arguments
| :: (MonadHandle m, MonadTerminal m) | |
| => [SGR] |
|
| -> FilePath | |
| -> m (Either Error ()) |
Redact text from a file strictly, putting it to the terminal
Since: 0.4.0.0
Arguments
| :: (MonadHandle m, MonadTerminal m) | |
| => [SGR] |
|
| -> 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