A Converter Pipeline with a composable library of operations. Conpipe wraps template processors (eg EEx, Liquid) and plain-text markup languages (eg Markdown, Asciidoc). Conpipe is:
- intended for use in Static Site Generators like Tableau
- designed to be extended
Add conpipe to your list of dependencies in mix.exs:
def deps do
[
{:conpipe, "~> 0.1.0"}
]
endOnline docs are at https://hexdocs.pm/conpipe.
A converter is a module with a convert/2 function that implements the
Conpipe.Converter behavior. Here's a converter that processes Liquid tags:
defmodule MyLiquidConverter do
@behavior Conpipe.Converter
def convert({text, assigns}, opts \\ []) do
{:ok, template} = Solid.parse(text, opts)
output = Solid.render!(template, assigns) |> to_string
{output, assigns}
end
endConverters can be chained in Elixir pipes:
defmodule My.DoItAllConverter do
@behavior Conpipe.Converter
def convert({text, assigns}, _opts \\ []) do
{text, assigns}
|> Conpipe.Converter.Solid.convert()
|> MyConverter.convert()
|> Conpipe.Converter.Mdex.convert()
|> MyHtmlPostProcessor.convert()
end
endConverters can be composed and run in a pipeline:
[Conpipe.Converter.Solid, MyConverter, Conpipe.Converter.Mdex]
|> Conpipe.Runner.reduce(text, assigns)This project ships with a library of converters that can be reused across applications:
Markup Languages
Conpipe.Converter.Earmark- Markdown HTMLConpipe.Converter.Mdex- Markdown to HTML
Template Processors
Conpipe.Converter.Eex- EEx template languageConpipe.Converter.Solid- Liquid template language
Find an up-to-date list of converters in the online documentation.
Adding use Conpipe.Extended to a converter provides a convert/4
function that can be called directly from Tableau.
defmodule MyConverter do
@behavior Conpipe.Converter
use Conpipe.Extended
def convert({text, assigns}, _opts \\ []) do
{text, assigns}
|> Conpipe.Converter.Solid.convert()
|> Conpipe.Converter.Mdex.convert()
end
endThen in config/config.exs
config :tableau, :config,
url: "http://localhost:4999",
converters: [
md: MyConverter
]All converters in this package use TableauAdapter.
Pull Requests welcome! PR's require Conventional Commits, passing tests and formatted code.
Pre-commit hooks and setup scripts can be found in .github/hooks.