Skip to content

iamgio/quarkdown

Repository files navigation

Quarkdown

Quarkdown is a Markdown parser and renderer that extends the capabilities of CommonMark and GFM with its own Quarkdown flavor.

The standout feature the flavor introduces is its support for functions, allowing users to access an extensive standard library, use conditional statements and loops, define new functions and variables - all within Markdown.

This out-of-the-box scripting support opens doors to complex and dynamic content that would be otherwise impossible to achieve with vanilla Markdown.

Comparison

Markdown LaTeX Quarkdown
Concise and readable βœ… ❌ βœ…
Full document control ❌ βœ… βœ…
Scripting ❌ ❌ βœ…
LaTeX Quarkdown
\section{Section}
\subsection{Subsection}
\begin{enumerate}
    \item \textbf{First} item
    \item \textbf{Second} item
\end{itemize}
\begin{center}
    This text is \textit{centered}.
\end{center}
# Section

## Subsection

1. **First** item
2. **Second** item

.center
    This text is _centered_.

Targets

HTML is currently the only supported rendering target. LaTeX rendering is a future goal.

  • HTML
    • βœ… Plain output (default)
    • βœ… Slides (via reveal.js)
    • βœ… Paged (book) (via paged.js)

The desired document type can be set by calling the .doctype function within the Markdown source itself:

  • .doctype {slides}
  • .doctype {paged}

Note

Make sure to set the output directory in order to save the output to file.
This can be done by setting the command line argument --out <dir> or -o <dir>.

Scripting

Iterative Fibonacci
.var {t1} {0}
.var {t2} {1}

.table
    .foreach {0..8}
        n:
        | $ F_{.n} $ |
        |:----------:|
        |    .t1     |
        .var {tmp} {.sum {.t1} {.t2}}
        .var {t1} {.t2}
        .var {t2} {.tmp}
F 0 F 1 F 2 F 3 F 4 F 5 F 6 F 7 F 8
0 1 1 2 3 5 8 13 21
Recursive Fibonacci

The recursive approach is significantly slower than the iterative one.

.function {fib}
    n:
    .if { .islower {.n} than:{2} }
        .n
    .ifnot { .islower {.n} than:{2} }
        .sum {
            .fib { .subtract {.n} {1} }
        } {
            .fib { .subtract {.n} {2} }
        }
  
.table
    .foreach {0..8}
        | $ F_{.1} $ |
        |:----------:|
        | .fib {.1}  |
F 0 F 1 F 2 F 3 F 4 F 5 F 6 F 7 F 8
0 1 1 2 3 5 8 13 21

Status

The project is under active development.

Future plans

  • Wiki, getting started guides and tutorials
  • New themes
  • Contribution guidelines
  • Auto-generated stdlib documentation (Dokka custom plugin)
  • External libraries support
  • LaTeX rendering
  • GUI editor / IDE plugin