FancyFences

Actions StatusPackageDocumentation

FancyFences is a markdown processor on top of EarmarkParser (the default markdown processor used by ExDoc. You can use it to conditionally post-process code blocks allowing you to:

mermaid example

Usage

In order to use FancyFences you need to set the :markdown_processor option in the :docs section as following:

docs: [
  markdown_processor: {FancyFences, [fences: processors]}
]

where processors defines the code blocks processors.

docs: [
  markdown_processor: {FancyFences, [fences: fancy_processors()]}
]

defp fancy_processors do
  %{
    "format" => {FancyFences.Processors, :format_code, []},
    "inspect" => {FancyFences.Processors, :inspect_code, [format: true]},
    "vl" => {MyProcessors, :vega_lite, []},
    "mermaid" => {MyProcessors, :mermaid, []}
  }
end

will apply the following processors:

Now in your markdown docs you can use the above processors as language and fancy_fences will apply the required transformations during mix docs invocation.

Examples

inspect fence processor example:

inspect example

vl fence processor example:

vega-lite example

Example project

You can find a sample project using fancy_fences here.

Installation

In order to install the package add the following to your mix.exs:

def deps do
  [
    {:fancy_fences, "~> 0.3.0", only: :dev, runtime: false}
  ]
end

and configure your fence processors accoring to the docs.

License

Copyright (c) 2023 Panagiotis Nezis

fancy_fences is released under the MIT License. See the LICENSE file for more details.