Skip to main content

NimblePublisher

Full example on GitHub

NimblePublisher ships with Makeup-based highlighting, but it also exposes a custom html_converter hook. That is the right integration point for Lumis.

Use MDEx as the markdown engine inside that converter. This is cleaner than post-processing HTML, and it keeps syntax highlighting inside the markdown renderer where it belongs.

Keep highlighters empty

Do not configure NimblePublisher's built-in highlighters when Lumis owns code blocks.

use NimblePublisher,
build: Post,
from: Application.app_dir(:my_app, "priv/posts/**/*.md"),
as: :posts,
html_converter: MyApp.Blog.Markdown,
highlighters: []

Add dependencies

def deps do
[
{:nimble_publisher, "~> 1.0"},
{:mdex, "~> 0.11"}
]
end

Custom converter

defmodule MyApp.Blog.Markdown do
def convert(_path, body, _attrs, _opts) do
MDEx.to_html!(body,
syntax_highlight: [
formatter: {:html_inline, theme: "github_light"}
]
)
end
end

Multi-theme version

MDEx.to_html!(body,
syntax_highlight: [
formatter: {:html_multi_themes,
themes: [light: "github_light", dark: "github_dark"],
default_theme: "light-dark()"}
]
)