#html-parser #html #markdown-parser #markdown #javascript #github #framework #js #open-source #public

antwerp

An open-source framework ported from JavaScript to Rust for GitHub pages and built with the Marcus HTML to MarkDown parser

2 releases

Uses new Rust 2021

0.3.2 Nov 19, 2022
0.3.1 Nov 19, 2022
0.2.4 Aug 21, 2022
0.1.4 Jul 31, 2022

#368 in Development tools

Download history 29/week @ 2022-08-09 80/week @ 2022-08-16 11/week @ 2022-08-23 4/week @ 2022-08-30 27/week @ 2022-09-06 21/week @ 2022-09-13 5/week @ 2022-09-20 1/week @ 2022-09-27 10/week @ 2022-10-04 10/week @ 2022-10-25 32/week @ 2022-11-01 1/week @ 2022-11-08 53/week @ 2022-11-15 12/week @ 2022-11-22

98 downloads per month

MIT license

23KB
162 lines

Antwerp

Antwerp is an open-source framework ported from JavaScript to Rust for GitHub pages and built with the Marcus HTML to MarkDown parser. It outputs static web pages in dist/ using HTML and MarkDown templates in public/, which are converted to HTML using the Marcus MarkDown to HTML parser.

Demonstration:

Cargo.toml (Cargo.toml):

[package]
name = "<NAME>"
version = "<VERSION>"
edition = "2021"
description = "<DESCRIPTION>"
license = "MIT"
readme = "README.md"

[dependencies]
antwerp = "0.3.1"

main.rs (src/main.rs):

use antwerp;

fn main() {
  antwerp::build();
}

Input:

base.html (public/base.html):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>{% block title | text | trim %}{% endblock title %}</title>
</head>
<body>
  {% block body %}
    <p>This paragraph serves as the default content for the <code>body</code> block.</p>
  {% endblock body %}

  <footer>
    {% block footer | trim | text %}
      # This is a header for the default footer (it won't get converted to HTML).
    {% endblock footer %}
  </footer>
</body>
</html>

index.md (public/index.md):

{% extends "base.html" %}

{% block title %}Homepage{% endblock title %}

{% block body %}
# Hello World!

This is the template, it contains a link to [a file](/section/chapter/file.html) in the first chapter of a random section and the default footer (below).
{% endblock body %}

file.md (public/section/chapter/file.md):

{% extends "base.html" %}
{% block title %}Section / Chapter / File{% endblock title %}

{% block body %}
# Hello World!

This is the template, it takes you to [the homepage](/).

This page also includes CSS styles, which are ignored by the [Marcus](https://crates.io/crates/marcus) MarkDown to HTML converter.

<style type="text/css">
  a {
    color: hotpink !important;
    text-decoration: none
  }
  h1 {
    font-family: sans-serif
  }
</style>
{% endblock body %}

{% block footer %}
  <footer>
    This is a custom footer for the `section / chapter / file` page.
  </footer>
{% endblock footer %}

Output:

index.html (dist/index.html):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title><p>Homepage</p></title>
</head>
<body>
  <h1>Hello World!</h1>

<p>This is the template, it contains a link to <a href="/section/chapter/file.html">a file</a> in the first chapter of a random section and the default footer (below).</p>

  <footer>
    # This is a header for the default footer (it won't get converted to HTML).
  </footer>
</body>
</html>

file.md (dist/section/chapter/file.md):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title><p>Section / Chapter / File</p></title>
</head>
<body>
  <h1>Hello World!</h1>

<p>This is the template, it takes you to <a href="/">the homepage</a>.</p>

<p>This page also includes CSS styles, which are ignored by the <a href="https://crates.io/crates/marcus">Marcus</a> MarkDown to HTML converter.</p>

<style type="text/css">
  a {
    color: hotpink !important;
    text-decoration: none
  }
  h1 {
    font-family: sans-serif
  }
</style>

  <footer>
    <footer>

<p> This is a custom footer for the <code>section / chapter / file</code> page.</p>
  </footer>
  </footer>
</body>
</html>

References:

Antwerp:

Marcus:

MarkDown/HTML:

Licence:

The source code included in this repository is distributed, for free, under the MIT Licence, for the full license, see LICENSE.md.

Dependencies

~3.5MB
~107K SLoC