📰 Edition

WARNING: This is a pre-release project.

Edition is a command-line application for creating beautiful HTML and Markdown editions of your projects' documentation.

In fact, the document you're reading right now was pressed by Edition.

Highlights

Getting started

Installation

Edition requires Python 3.8 or later.

Install Edition via pip:

pip install edition

Quick-start example

Create this Markdown document as example-source.md:

# Edition example

Save this file to your local machine as `example-source.md`
then run:

```bash
edition example-source.md example.html --press html
```

Now open `example.html` in a web browser. The code example
below will be complete.

```bash
python --version
```

<!--edition-exec-->

Run:

edition docs/example-source.md docs/example.html --press html
Pressed: docs/example.html

Fun fact! The code above is executed every time I press this documentation. That gives me confidence that it works and lets you see the actual example.html it generates.

Usage

Command line

Edition takes three command line arguments:

Creating your source document

Your source document is the Markdown document from which all your editions will be pressed.

Any Markdown document you already have -- like your project's README.md -- is already a valid source document, but we can add some front matter and additional markup to help guide the presses.

Front matter

The following front matter properties come into play only when pressing HTML.

Property Description Default
author Author name No author
favicon-emoji Emoji to use as favicon No favicon
title Page title Top-level heading

For example:

---
author: Cariad Eccleston
favicon-emoji: 🍕
# If "title" was omitted then the top-level "Example"
# heading would be used instead:
title: Embedded Example
---

# Example

Markup

Code execution

To have Edition execute your code then embed the result:

  1. Create a regular Markdown code block
  2. Add <!--edition-exec--> after the block

For example:

```python
print("Hello, world!")
```

<!--edition-exec-->

If your code fails then an error message will be injected:

print(foo)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'foo' is not defined

Currently only bash and python code blocks are supported. More languages can be added if they are requested.

Table of Contents

To insert a table of contents:

<edition value="toc" />

You can optionally specify "hi" and "lo" values to restrict the table to a range of headings.

For example, to exclude the title and start at second-level headings:

<edition value="toc" hi="2" />

To exclude any headings below level three:

<edition value="toc" lo="2" />

Project

Contributing

To contribute a bug report, enhancement or feature request, please raise an issue at github.com/cariad/edition/issues.

If you want to contribute a code change, please raise an issue first so we can chat about the direction you want to take.

Licence

Edition is released at github.com/cariad/edition under the MIT Licence.

See LICENSE for more information.

Author

Hello! 👋 I'm Cariad Eccleston and I'm a freelance DevOps and backend engineer. My contact details are available on my personal wiki at cariad.earth.

Please consider supporting my open source projects by sponsoring me on GitHub.

Acknowledgements