[![Hackage version](https://img.shields.io/hackage/v/agda2lagda.svg?label=Hackage&color=informational)](http://hackage.haskell.org/package/agda2lagda) [![agda2lagda on Stackage Nightly](https://stackage.org/package/agda2lagda/badge/nightly)](https://stackage.org/nightly/package/agda2lagda) [![Stackage LTS version](https://www.stackage.org/package/agda2lagda/badge/lts?label=Stackage)](https://www.stackage.org/package/agda2lagda) [![Cabal build](https://github.com/andreasabel/agda2lagda/workflows/Haskell-CI/badge.svg)](https://github.com/andreasabel/agda2lagda/actions) [![Stack build](https://github.com/andreasabel/agda2lagda/workflows/Stack%20build/badge.svg)](https://github.com/andreasabel/agda2lagda/actions) agda2lagda: Convert program to literate program (Agda/Haskell) ============================================================== Generate a literate Agda/Haskell script from an Agda/Haskell script. Produces LaTeX or Markdown literate scripts. Specification ------------- Conversion into LaTeX (default): - Single line comments are turned into ordinary LaTeX. * Paragraphs followed by a line of equal signs are turned into `\heading`s. * Paragraphs followed by a line of dashes are turned into `\subheading`s. * Consecutive paragraphs starting `*` are turned into an `itemize` environment. * At the end of the file, extra block comment terminators are removed. - Comment blocks, if started on the 0th column, count as _commenting out_. These will be turned into TeX comments. Nested comments are not recognized. - The rest is interpreted as code and wrapped in a `code` environment. Conversion into Markdown (option `--markdown`) is similar, but nothing needs to be done for headings and itemize environments: - Single line comments are turned into ordinary text. * At the end of the file, extra block comment terminators are removed. - Comment blocks, if started on the 0th column, count as _commenting out_. These will be turned into HTML comments. Nested comments are not recognized. - The rest is interpreted as code and wrapped in a code environment (triple backticks). Examples -------- Given input [`Foo.agda`](https://github.com/andreasabel/agda2lagda/blob/master/test/Foo.agda): - Invocation `agda2lagda Foo.agda` produces output [`Foo.lagda.tex`](https://github.com/andreasabel/agda2lagda/blob/master/test/golden/Foo.lagda.tex). - Invocation `agda2lagda --markdown Foo.agda` produces output [`Foo.lagda.md`](https://github.com/andreasabel/agda2lagda/blob/master/test/golden/Foo.lagda.md). LaTeX examples (rendered): - http://www.cse.chalmers.se/~abela/#MultiSortedAlgebra - http://www.cse.chalmers.se/~abela/#cr-sk Example `Makefile` to turn `.agda` file into highlighted HTML via Markdown (since `v0.2023.1.12`): ```make FILE=Foo TITLE=The Title default : md/html/$(FILE).html # Step 1: agda2lagda: Produce Markdown literate script. md/%.lagda.md : %.agda agda2lagda -f --markdown -o md/ $< # Step 2: agda: Highlight and format code blocks as HTML. # Also produces Agda.css. md/html/%.md : md/%.lagda.md cd md ; agda --html --html-highlight=auto ../$< # Step 3: pandoc: Produce HTML. Improvise header to make HTML self-contained. md/html/%.html : md/html/%.md echo '