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
Provides syntax for Python-Markdown which allows for the inclusion of the contents of other Markdown documents.

Markdown-Include This is an extension to Python-Markdown which provides an "include" function, similar to that found in LaTeX (and also the C pre-proc

Chris MacMackin 85 Dec 30, 2022
Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files

Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. Mdformat is a Unix-style command-line tool as well as a Python library.

Executable Books 180 Jan 6, 2023
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
Application that converts markdown to html.

Markdown-Engine An application that converts markdown to html. Installation Using the package manager [pip] pip install -r requirements.txt Usage Run

adriano atambo 1 Jan 13, 2022
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 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 31, 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 4, 2023
Static site generator that supports Markdown and reST syntax. Powered by Python.

Pelican Pelican is a static site generator, written in Python. Write content in reStructuredText or Markdown using your editor of choice Includes a si

Pelican dev team 11.3k Jan 5, 2023
Extensions for Python Markdown

PyMdown Extensions Extensions for Python Markdown. Documentation Extension documentation is found here: https://facelessuser.github.io/pymdown-extensi

Isaac Muse 685 Jan 1, 2023
markdown2: A fast and complete implementation of Markdown in Python

Markdown is a light text markup format and a processor to convert that to HTML. The originator describes it as follows: Markdown is a text-to-HTML con

Trent Mick 2.4k Dec 30, 2022