View Source FancyFences.Processors (fancy_fences v0.3.0)
Common fence processors.
Link to this section Summary
Functions
A fence processor for documenting fence processors usage.
Formats the given code block.
Embeds the original code and the evaluated result.
Link to this section Functions
A fence processor for documenting fence processors usage.
This can be used for documenting fence processors. It return an admonition block containing both the sample code and the output of the fence processor.
usage
Usage
It expects a map with the following key-value pairs:
block- the code block to use as an exampleprocessor- an anonymous function with the processor that will be used.
For example:
```fence-processor
%{
block: "Enum.map([1, 2, 3], fn x -> 2*x end)",
processor: fn block -> FancyFences.Processors.inspect_code(block) end
}
```Embedded code
A fenced code block of the form:
```lang %{ block: "1 + 1", processor: fn block -> "**Code:** `"<> block <> "`" end } ```will be transformed to:
Embedded code
A fenced code block of the form:
```lang 1 + 1 ```will be transformed to:
Code:
1 + 1where
langthe defined code language for this fence processor in yourmix.exs.where
langthe defined code language for this fence processor in yourmix.exs.
Notice that above we used fence_processor_doc/1 to document itself, that's why
we have the nested admonition block.
Formats the given code block.
Embedded code
A fenced code block of the form:
```lang for x <- [1, 2, 3] do 2 * x end ```will be transformed to:
for x <- [1, 2, 3] do 2 * x endwhere
langthe defined code language for this fence processor in yourmix.exs.
Embeds the original code and the evaluated result.
options
Options
:format(boolean) - If set totruethe code blocks will be formatted before inection. Defaults tofalse.
Embedded code
A fenced code block of the form:
```lang Enum.map([1, 2, 3, 4], fn x -> 2*x end) ```will be transformed to:
Enum.map([1, 2, 3, 4], fn x -> 2*x end)[2, 4, 6, 8]where
langthe defined code language for this fence processor in yourmix.exs.