{"id":15048713,"url":"https://github.com/pyrustic/litemark","last_synced_at":"2025-04-10T01:33:24.466Z","repository":{"id":60722511,"uuid":"411809602","full_name":"pyrustic/litemark","owner":"pyrustic","description":"Lightweight Markdown dialect for Python desktop apps","archived":false,"fork":false,"pushed_at":"2022-04-24T15:07:41.000Z","size":36,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T23:46:05.278Z","etag":null,"topics":["codegame","desktop-app","lightweight","litemark","markdown","markup","preview","pyrustic","scanner","text","tkinter","tokens"],"latest_commit_sha":null,"homepage":"https://pyrustic.github.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyrustic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-29T19:48:21.000Z","updated_at":"2024-12-16T12:10:45.000Z","dependencies_parsed_at":"2022-10-03T21:01:43.264Z","dependency_job_id":null,"html_url":"https://github.com/pyrustic/litemark","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Flitemark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Flitemark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Flitemark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Flitemark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyrustic","download_url":"https://codeload.github.com/pyrustic/litemark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248140823,"owners_count":21054355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codegame","desktop-app","lightweight","litemark","markdown","markup","preview","pyrustic","scanner","text","tkinter","tokens"],"created_at":"2024-09-24T21:15:39.518Z","updated_at":"2025-04-10T01:33:24.445Z","avatar_url":"https://github.com/pyrustic.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project is part of the [Pyrustic Open Ecosystem](https://pyrustic.github.io).\n\n[Usage](#usage) | [Installation](#installation)\n\n# Litemark\n\n`Litemark` is a lightweight `Markdown` dialect originally created to be the markup language for the [Codegame Platform](https://github.com/pyrustic/codegame) project.\nWhen you run `litemark` from the command line interface without any arguments, the `Litemark Viewer` opens and displays the rendered demo.\n\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/litemark-rendered.png\" alt=\"Figure\" width=\"668\"\u003e\n    \u003cp align=\"center\"\u003e\n    \u003ci\u003e Litemark demo rendered in the Litemark Viewer \u003c/i\u003e\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/litemark-plain-text.png\" alt=\"Figure\" width=\"700\"\u003e\n    \u003cp align=\"center\"\u003e\n    \u003ci\u003e litemark-demo.md (plain text) \u003c/i\u003e\n    \u003c/p\u003e\n\u003c/div\u003e\n\n## Usage\nThe name `Litemark` refers to both the markup language and the distribution package.\n\nThe distribution package comes with an API, a command line interface, and a graphical viewer.\n### API\nIt is easy to break an arbitrary plain text into a flat list of tokens:\n```python\nimport litemark\n\n\nplain_text = \"\"\"Hello *World* ! Visit the [repository](https://github.com/pyrustic/litemark) !\"\"\"\n\nfor token in litemark.scan(plain_text):\n    # a token instance is a named tuple with 2 fields: name and data \n    print(token)\n```\nThe output:\n```\nToken(name='STRING', data='Hello ')\nToken(name='BOLD', data='World')\nToken(name='STRING', data=' ! Visit the ')\nToken(name='LINK', data=('repository', 'https://github.com/pyrustic/litemark', ''))\nToken(name='STRING', data=' !')\n```\nThe formal names of the tokens are defined in `litemark.Element`:\n```python\nclass Element:\n    CODEBLOCK = \"CODEBLOCK\"\n    HEADING = \"HEADING\"\n    BOLD = \"BOLD\"\n    ITALIC = \"ITALIC\"\n    WARNING = \"WARNING\"\n    OVERSTRIKE = \"OVERSTRIKE\"\n    IMAGE = \"IMAGE\"\n    INLINK = \"INLINK\"\n    LINK = \"LINK\"\n    STRING = \"STRING\"\n```\nThe token's `data` field represents a string for all elements except the following:\n- **Element.CODEBLOCK**: 2-tuple (str-title, str-content)\n- **Element.HEADING**: 2-tuple (int-level, str-content)\n- **Element.IMAGE**: 3-tuple (str-inline, str-path, str-alt)\n- **Element.INLINK**: 3-tuple (str-inline, str-path, str-alt)\n- **Element.LINK**: 3-tuple (str-inline, str-URL, str-alt)\n\n### Command line interface\nTo open `litemark-demo.md` in the graphical `Viewer`:\n```bash\n$ litemark\n```\n\nTo open a specific `litemark` file in the graphical `Viewer`:\n```bash\n$ cd /path/to/root\n$ litemark my-file.md\n```\n\n**Note:**\n\u003e 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.\n\n### Graphical Viewer\nIt is easy to embed a `Litemark Viewer` in your Python desktop app:\n```python\nimport litemark\nimport tkinter as tk\n\nroot_directory = \"/home/alex/demo\"\nlitemark_filename = \"/home/alex/demo/document.md\"\n\n# your GUI\ngui = tk.Tk()\ngui.geometry(\"500x500+0+0\")\n\n# let's embed a Litemark Viewer in this GUI\n\n# -- text widget\ntext_widget = tk.Text(gui)\ntext_widget.pack(expand=1, fill=tk.BOTH)\n\n# -- the viewer instance\nviewer = litemark.Viewer(widget=text_widget, root=root_directory)\nviewer.open(litemark_filename)\nviewer.readonly = True\n\n# done !\ngui.mainloop()\n```\n\nThis is a work in progress. A reference documentation will be released soon.\n\n## Installation\n\n### Install for the first time\n```bash\npip install litemark\n```\n\n### Upgrade\n```bash\npip install litemark --upgrade --upgrade-strategy eager\n```\n\n## Related projects\n- [Codegame Platform](https://github.com/pyrustic/codegame): create, distribute, and run codegames\n- [shared](https://github.com/pyrustic/shared): library to store, expose, read, and edit collections of data\n\n\nThis is a work in progress...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyrustic%2Flitemark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyrustic%2Flitemark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyrustic%2Flitemark/lists"}