snippet-0.0.0.0: README.lhs
# Snippet
[](https://codeberg.org/pbrisbin/snippet/releases)
[](https://hackage.haskell.org/package/snippet)
[](http://stackage.org/lts/package/snippet)
[](http://stackage.org/nightly/package/snippet)
[](https://codeberg.org/pbrisbin/snippet/actions?workflows=ci.yml)
Pretty-print regions within source code files.
## Usage
<!--
```haskell
module Main (main) where
import Text.Markdown.Unlit ()
```
-->
```haskell
import Prelude
import Data.Foldable (traverse_)
import Prettyprinter (reAnnotate)
import Prettyprinter.Render.Terminal (putDoc)
import Snippet
import Snippet.Pretty
main :: IO ()
main = do
let
region = Region
{ startLine = 32
, endLine = Just 44
, startColumn = Just 8
, endColumn = Nothing
}
-- Returns Nothing if file is missing/empty or region is invalid
mSnippet <- snippetFromFile region "README.md"
traverse_ (putDoc . reAnnotate annToAnsi . prettySnippet) mSnippet
```
The above `Region` focuses just the body of the `do` block in this file.
Rendering it with the default `annToAnsi` looks like:

Supplying an alternative `annToAnsi` function is how you can adjust colors.
## License
This package is licensed AGPLv3. See [COPYING](./COPYING).