Lightweight Markdown dialect for Python desktop apps

Overview

This project is part of the Pyrustic Open Ecosystem.

Usage | Installation

Litemark

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.

Figure

Litemark demo rendered in the Litemark Viewer


Figure

litemark-demo.md (plain text)

Usage

The name Litemark refers to both the markup language and the distribution package.

The distribution package comes with an API, a command line interface, and a graphical viewer.

API

It is easy to break an arbitrary plain text into a flat list of tokens:

import litemark


plain_text = """Hello *World* ! Visit the [repository](https://github.com/pyrustic/litemark) !"""

for token in litemark.scan(plain_text):
    # a token instance is a named tuple with 2 fields: name and data 
    print(token)

The output:

Token(name='STRING', data='Hello ')
Token(name='BOLD', data='World')
Token(name='STRING', data=' ')
Token(name='STRING', data='! ')
Token(name='STRING', data='Visit ')
Token(name='STRING', data='the ')
Token(name='LINK', data=('repository', 'https://github.com/pyrustic/litemark', ''))
Token(name='STRING', data=' ')
Token(name='STRING', data='!')
Token(name='STRING', data='')

The formal names of the tokens are defined in litemark.Element:

class Element:
    CODEBLOCK = "CODEBLOCK"
    HEADING = "HEADING"
    BOLD = "BOLD"
    ITALIC = "ITALIC"
    WARNING = "WARNING"
    OVERSTRIKE = "OVERSTRIKE"
    IMAGE = "IMAGE"
    INTRALINK = "INTRALINK"
    LINK = "LINK"

The token's data field represents a string for all elements except the following:

  • Element.CODEBLOCK: 2-tuple (str-title, str-content)
  • Element.HEADING: 2-tuple (int-level, str-content)
  • Element.IMAGE: 3-tuple (str-inline, str-path, str-alt)
  • Element.INTRALINK: 3-tuple (str-inline, str-path, str-alt)
  • Element.LINK: 3-tuple (str-inline, str-URL, str-alt)

Command line interface

To open litemark-demo.md in the graphical Viewer:

$ litemark

To open a specific litemark file in the graphical Viewer:

$ cd /path/to/root
$ litemark my-file.md

Note:

Litemark is created for use in a desktop application. Thus, the Litemark Scanner assumes that the images referenced in a litemark document are relative to the root directory. The root directory is simply the current working directory. For this reason, you must first do a cd (change directory) to the root before rendering a document.

Graphical Viewer

It is easy to embed a Litemark Viewer in your Python desktop app:

import litemark
import tkinter as tk

root_directory = "/home/alex/demo"
litemark_filename = "/home/alex/demo/document.md"

# your GUI
gui = tk.Tk()
gui.geometry("500x500+0+0")
# let's embed a Litemark Viewer in this GUI
# -- text widget
text_widget = tk.Text(gui)
text_widget.pack(expand=1, fill=tk.BOTH)
# -- the viewer instance
viewer = litemark.Viewer(widget=text_widget, root=root_directory)
viewer.open(litemark_filename)
viewer.readonly = True
# done !
gui.mainloop()

This is a work in progress. A reference documentation will be released soon.

Installation

Install for the first time

pip install litemark

Upgrade

pip install litemark --upgrade --upgrade-strategy eager

Related projects

  • Codegame Platform: create, distribute, and run codegames
  • shared: library to store, expose, read, and edit collections of data

This is a work in progress...

You might also like...
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

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

Convert HTML to Markdown-formatted text.

html2text html2text is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to

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

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

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.

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

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 -

Owner
Pyrustic Open Ecosystem to develop and distribute Python apps
null
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 markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

stonepresto 4 Aug 13, 2022
A lightweight and fast-to-use Markdown document generator based on Python

A lightweight and fast-to-use Markdown document generator based on Python

快乐的老鼠宝宝 1 Jan 10, 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
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
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
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