🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
⚠️ Malware / Trojaner / VirenVorsicht: Android-Malware verschlüsselt Ihre Handys und nimmt heimlich Fotos auf(11.09.2026 um 09:35 Uhr)
🕵️ SicherheitslückenMicrosoft geht endlich eines der nervigsten Probleme von Windows 11 an(11.09.2026 um 11:58 Uhr)
💾 IT Security ToolsSysinternals Suite(11.09.2026 um 12:00 Uhr)
🕵️ SicherheitslückenDefender 0-Day ShieldBreak (CVE-2026-69414) nicht sauber gepatcht - BornCity(11.09.2026 um 12:52 Uhr)
🔧 AI Nachrichten Stealing AI Reasoning Traces(08.09.2026 um 12:20 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
⚠️ Malware / Trojaner / VirenVorsicht: Android-Malware verschlüsselt Ihre Handys und nimmt heimlich Fotos auf(11.09.2026 um 09:35 Uhr)
🕵️ SicherheitslückenMicrosoft geht endlich eines der nervigsten Probleme von Windows 11 an(11.09.2026 um 11:58 Uhr)
💾 IT Security ToolsSysinternals Suite(11.09.2026 um 12:00 Uhr)
🕵️ SicherheitslückenDefender 0-Day ShieldBreak (CVE-2026-69414) nicht sauber gepatcht - BornCity(11.09.2026 um 12:52 Uhr)
🔧 AI Nachrichten Stealing AI Reasoning Traces(08.09.2026 um 12:20 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 5 Min Lesezeit
0

Executable Blog Posts: Second Take

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

This is a second take for my previous blog post filter for , where I used a literate Haskell program to convert my raw blog posts in Markdown format to a different Markdown format for cross-posting to different blogging platforms. I used has a feature called of and , the creator of environment in my case. Our only additional dependency is pandoc-lua-engine:




CODE
{
##...

ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: [
hpkgs.markdown-unlit
hpkgs.pandoc
hpkgs.pandoc-lua-engine
]);

thisShell = pkgs.mkShell {
buildInputs = [
## ...

ghc

## ...
];

NIX_GHC = "${ghc}/bin/ghc";
NIX_GHCPKG = "${ghc}/bin/ghc-pkg";
NIX_GHC_DOCDIR = "${ghc}/share/doc/ghc/html";
NIX_GHC_LIBDIR = "${ghc}/lib/ghc-9.6.5/lib";
};

# ...
}









The Implementation



For sanity, we need some language extensions:




CODE
{-# LANGUAGE OverloadedStrings #-}






For added pleasure, we need some imports:




CODE
import System.Environment (getArgs)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import qualified Text.Pandoc as P
import qualified Text.Pandoc.Lua as P.Lua






Let's get the entrypoint function ready:




CODE
main :: IO ()
main = do
path <- head <$> getArgs
iTxt <- TIO.readFile path
oTxt <- convert "./static/assets/media/posts/executable-blog-post-pandoc-filters/filter.lua" iTxt
TIO.putStrLn oTxt






Our workhorse function is finally getting more complicated, thank God:




  1. Mark the input as .

  2. Apply a Lua filter to the AST to process the links and images.



Now, let's re-implement our workhorse function:




CODE
convert :: FilePath -> T.Text -> IO T.Text
convert lua txt = P.runIOorExplode $ do
md <- P.readCommonMark readerOptions txt
fmd <- P.Lua.applyFilter P.def ["commonmark"] lua md
P.writeCommonMark writerOptions fmd
where
readerOptions =
P.def
{ P.readerExtensions = P.enableExtension P.Ext_yaml_metadata_block $ P.getDefaultExtensions "commonmark"
, P.readerStripComments = True
}
writerOptions =
P.def
{ P.writerExtensions = P.getDefaultExtensions "commonmark"
, P.writerWrapText = P.WrapNone
}






That's it as far as Haskell goes. Now, we need to write our Lua filter. I where my program can find it.



We are done with the program. We can run our blog post via runhaskell on our blog post. But first, like last time, we need to symlink our Markdown file (.md) with a literate Haskell file extension (.lhs) so that GHC is not upset:




CODE
ln -sr \
content/posts/2024-08-11_executable-blog-post-pandoc-filters.md \
content/posts/2024-08-11_executable-blog-post-pandoc-filters.lhs






Then, we can run the blog post on the blog post itself:




CODE
runhaskell \
-pgmLmarkdown-unlit \
content/posts/2024-08-11_executable-blog-post-pandoc-filters.lhs \
content/posts/2024-08-11_executable-blog-post-pandoc-filters.md






It worked on my computer!






Wrap-Up



I used Lua for years to configure my . Since I bumped into an Emacs bug ( after 20 years of Emacs, and I am using Lua to configure my Neovim. Last but not least, OpenResty gives my Nginx superpowers with Lua.



Lua is silently taking over my life. Now, I am using Lua to configure my blog posts. I am not sure if I am getting better or worse.



As for my solution: Once stupid, always stupid. I promise it will get worse.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Stealing AI Reasoning Traces
1 Quelle
AIs as Modern Genies
1 Quelle
Bitcoin: KI-Hacker räumen Millionen ab! Wird Künstliche Intelligenz zum Problem? - ftd.de
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Executable Blog Posts: Second Take

Thematisch verwandte Begriffe: Executable, Blog, Posts, Second · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...