A markdown extension for converting Leiden+ epigraphic text to TEI XML/HTML

Overview

LeidenMark

$ pip install leidenmark

A Python Markdown extension for converting Leiden+ epigraphic text to TEI XML/HTML. Inspired by the Brill plain text (BPT) format that aims to incorporate Leiden+ into a Markdown-based syntax.

>>> from leidenmark import leiden_plus
>>> content = """\
<D=.r<=
1. Lorem ipsum dolor
vac.1lin
2. sit amet, con[ca.3]c
3.-etur adipiscing
=>=D>
<D=.v<=
lost.2lin
6. ut labore et dol
7.-ore magna aliqua
=>=D>"""
>>> leiden_plus(content, indent=True)

The output of the above lines is the following XML snippet:

<div n="r" type="textpart">
  <ab>
    <l n="1">Lorem ipsum dolor</l>
    <space quantity="1" unit="line"/>
    <l n="2">sit amet, con<gap precision="low" quantity="3" reason="lost" unit="character"/>c</l>
    <l break="no" n="3">etur adipiscing</l>
  </ab>
</div>
<div n="v" type="textpart">
  <ab>
    <gap quantity="2" unit="line"/>
    <l n="6">ut labore et dol</l>
    <l break="no" n="7">ore magna aliqua</l>
  </ab>
</div>

leiden_plus() is syntactic sugar for the registered Markdown extension, and equivalent to:

>>> import leidenmark
>>> from markdown import markdown
>>> markdown(content, extensions=['leiden_plus']) # Other extensions can be added to this list

Configuration

Given that this is a Markdown extension, conventions like *italics* and **bold** will also be recognized an converted (these in particular will additionally be transformed to the TEI element <hi>). Though these are in principle not part of the Leiden+ syntax, in practice the use of italics and boldface is still encountered a lot. Therefore, support is maintaned by default, which can be switched off by passing strict=True:

>>> leiden_plus(content, strict=True)

NB: The blockprocessors for paragraphs and ordered list are always switched off, because they interfer too much with Leiden+.

You might also like...
Comprehensive Markdown plugin built for Django
Comprehensive Markdown plugin built for Django

Django MarkdownX Django MarkdownX is a comprehensive Markdown plugin built for Django, the renowned high-level Python web framework, with flexibility,

Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

martor Martor is a Markdown Editor plugin for Django, supported for Bootstrap & Semantic-UI. Features Live Preview Integrated with Ace Editor Supporte

Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed. Now in Python!

markdown-it-py Markdown parser done right. Follows the CommonMark spec for baseline parsing Configurable syntax: you can add new rules and even replac

A fast, extensible and spec-compliant Markdown parser in pure Python.

mistletoe mistletoe is a Markdown parser in pure Python, designed to be fast, spec-compliant and fully customizable. Apart from being the fastest Comm

Livemark is a static page generator that extends Markdown with interactive charts, tables, and more.

Livermark This software is in the early stages and is not well-tested Livemark is a static site generator that extends Markdown with interactive chart

Remarkable Markdown Debian Package Fix

Remarkable debian package fix For some reason the Debian package for remarkable markdown editor has not been made to install properly on Ubuntu 20.04

Read a list in markdown and do something with it!

Markdown List Reader A simple tool for reading lists in markdown. Usage Begin by running the mdr.py file and input either a markdown string with the -

Lightweight Markdown dialect for Python desktop apps
Lightweight Markdown dialect for Python desktop apps

Litemark is a lightweight Markdown dialect originally created to be the markup language for the Codegame Platform project. When you run litemark from the command line interface without any arguments, the Litemark Viewer opens and displays the rendered demo.

A Discord Bot for rendering Markdown

Markdown to PDF Bot A discord bot that accepts markdown files (or messages) and displays them as images. Prerequisite To install, you must have have :

Comments
  • `enable_paragraphs` option not working as intended

    `enable_paragraphs` option not working as intended

    When enabling paragraphs, the following unwanted behaviour is occuring:

    >>> leiden_plus('<= Leiden+ section =>', enable_paragraphs=True)
    '<ab><p>Leiden+ section </p></ab>'
    

    This should just be <ab>Leiden+ section</ab>.

    The problem is that <= and => are formatted as different blocks using preprocessors, and stitched together using postprocessors, rendering the text content as a single paragraph in between by the regular markdown paragraph processor. It's probably better to use a mechanism where <= ... => and <D= ... =D> are interpreted as separate blocks.

    opened by andredelft 0
Releases(v0.2.2)
  • v0.2.2(Aug 4, 2021)

  • v0.2.1(Jul 28, 2021)

    This release includes several new processors for broader Leiden+ support, as well as some bugfixes to old ones. The new processors are listed below, linked to the corresponding sections on http://papyri.info

    Special characters

    1. Paragraphos: ----

    Marginalia

    1. Text inserted / added above line: \ὅλων/
    2. Text added between lines: ||interlin: ὧν||

    Other editorial conventions

    1. Handshift: $m4

    Extras (Not yet on papyri.info)

    1. Diples:
      To get this PN preview: (diple)
      Use this Leiden+: ((diple))
      <milestone rend="diple" unit="undefined"/>
      
    2. Eisthesis (indentation):
      To get this PN preview: line in eisthesis
      Use this Leiden+: (1, indent)
      To create this XML: <lb n="1" rend="indent"/>
      
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Jul 28, 2021)

    This release includes:

    • A pytest integration and some first basic tests
    • A new, decentralized processor registration system. Each submodule now has a register function (e.g. register_divisions in divisions.py) that registers the corresponding processors. These functions can also be imported when building a custom extension using this package. Note that individual processors should be imported from their submodules (e.g. from leidenmark.divisions import DivisionsPreproc instead of the former from leidenmark import DivisionsPreproc).
    Source code(tar.gz)
    Source code(zip)
  • v0.1.31(May 11, 2021)

  • v0.1.28(Apr 29, 2021)

Owner
André van Delft
Python & front-end web developer, passionate about digital humanities
André van Delft
Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed. Now in Python!

markdown-it-py Markdown parser done right. Follows the CommonMark spec for baseline parsing Configurable syntax: you can add new rules and even replac

Executable Books 398 Dec 24, 2022
A markdown generation library for Python.

Welcome to SnakeMD SnakeMD is your ticket to generating Markdown in Python. To prove it to you, we've generated this entire README using SnakeMD. See

The Renegade Coder 22 Dec 08, 2022
A fast yet powerful Python Markdown parser with renderers and plugins.

Mistune v2 A fast yet powerful Python Markdown parser with renderers and plugins. NOTE: This is the re-designed v2 of mistune. Check v1 branch for ear

Hsiaoming Yang 2.2k Jan 04, 2023
Pure-python-server - A blogging platform written in pure python for developer to share their coding knowledge

Pure Python web server - PyProject A blogging platform written in pure python (n

Srikar Koushik Satya Viswanadha 10 Nov 07, 2022
Preview GitHub README.md files locally before committing them.

Grip -- GitHub Readme Instant Preview Render local readme files before sending off to GitHub. Grip is a command-line server application written in Pyt

Joe Esposito 5.9k Jan 08, 2023
Toci is a markdown tool to generate an outline from a given Jupyter notebook.

Toci is a markdown tool to generate an outline from a given Jupyter notebook. It traverses the markdown cells of a given ipynb file to form a toc for you.

Hakan Özler 7 Jan 22, 2022
Rich-cli is a command line toolbox for fancy output in the terminal

Rich CLI Rich-cli is a command line toolbox for fancy output in the terminal, built with Rich. Rich-cli can syntax highlight a large number of file ty

Textualize 2.5k Jan 02, 2023
Comprehensive Markdown plugin built for Django

Django MarkdownX Django MarkdownX is a comprehensive Markdown plugin built for Django, the renowned high-level Python web framework, with flexibility,

neutronX 740 Jan 08, 2023
A Discord Bot for rendering Markdown

Markdown to PDF Bot A discord bot that accepts markdown files (or messages) and displays them as images. Prerequisite To install, you must have have :

1 Oct 21, 2021
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 30, 2022
A markdown template manager for writing API docs in python.

DocsGen-py A markdown template manager for writing API docs in python. Contents Usage API Reference Usage You can install the latest commit of this re

Ethan Evans 1 May 10, 2022
A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.

A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.

Çalgan Aygün 213 Dec 22, 2022
A minimal platform for Markdown-based blogs

madblog This project provides a minimal blogging platform based on Markdown files. Demos This project powers the following blogs: Platypush My persona

Fabio Manganiello 2 Aug 02, 2022
A fast, extensible and spec-compliant Markdown parser in pure Python.

mistletoe mistletoe is a Markdown parser in pure Python, designed to be fast, spec-compliant and fully customizable. Apart from being the fastest Comm

Mi Yu 546 Jan 01, 2023
Read a list in markdown and do something with it!

Markdown List Reader A simple tool for reading lists in markdown. Usage Begin by running the mdr.py file and input either a markdown string with the -

Esteban Garcia 3 Sep 13, 2021
CiteURL is an extensible tool that parses legal citations and makes links to websites where you can read the cited language for free.

CiteURL is an extensible tool that parses legal citations and makes links to websites where you can read the cited language for free. It can be used t

15 Dec 27, 2022
😸Awsome markdown readme for your profile or your portfolio

GitHub Profile Readme Description That's a simple and minimalist README.md for your profile Usage You can download or copy to your repository and make

0 Jul 24, 2022
A command line tool that can convert Day One data into markdown files.

Introduction Features Before Start Export data from Day One Check Integrity Special Cases for Photo Extension Name Audio Extension Name Usage Known Is

gyro永不抽风 26 Dec 31, 2022
A Straightforward Markdown Journal

Introducing Pepys: A straightforward markdown journal "It is rightly made for those who love to document their daily life events" - FOSSBytes Pepys is

Luke Briggs 23 Nov 12, 2022
Livemark is a static page generator that extends Markdown with interactive charts, tables, and more.

Livermark This software is in the early stages and is not well-tested Livemark is a static site generator that extends Markdown with interactive chart

Frictionless Data 86 Dec 25, 2022