Typesetting illuminate tooling, parser and EBNF for the Winding Markdown extension
Project description
Winding Markdown Extension
Winding is a grammar, AST and parser for the Winding Markdown extension. This extension enhances Markdown, allowing to specify scenes, layout and agentic behaviours.
Features
- Defines a clear and concise EBNF grammar for the Winding Markdown extension.
- Defines a pure Python parser, based on the Lark standalone parser.
- Defines AST and WindingTransformer, to facilitate the parsing.
- No external dependencies required.
Installation
You can install the Winding module from PyPI using pip:
pip install winding
Usage
You can find runnable examples in the samples/ directory.
Here is a simple example of printing the grammar:
>>> from winding import grammar
>>> print(grammar)
start: (winding | markdown)+
winding: meta_winding | space_winding | inline_winding
meta_winding: "---\n" IDENTIFIER ":" attributes header_winding* "\n---\n" content?
space_winding: "--\n" IDENTIFIER ":" attributes header_winding* "\n--\n" content?
header_winding: "\n" IDENTIFIER ":" attributes
inline_winding: "@" IDENTIFIER ":" attributes "\n" content?
content: (winding | markdown)+
markdown: (image | TEXT)+
attributes: (IDENTIFIER ("," IDENTIFIER)*)?
image: "![" CAPTION? "]" "(" URI? ")"
IDENTIFIER: /!?[A-Za-z][A-Za-z0-9_.-]*/
URI: /[^\)\n]+/
TEXT: /(?:(?!@\w+:|--|!\[).)*\n+/
CAPTION: /[^\]]+/
%ignore /[ \t]+/
%ignore "\r"
Example of parsing a Winding Markdown file
See samples/dragon.py for a complete example.
from winding.parser import Lark_StandAlone
from winding.transformer import WindingTransformer
from winding.ast import Winding
from pprint import pprint
parser = Lark_StandAlone()
sample = """---
dragons: portrait-oriented
---
A book about dragons
--
front-cover: portrait-oriented
--
Dragons
@center: large, landscape-oriented

"""
tree = parser.parse(sample)
ast = WindingTransformer().transform(tree)
pprint(ast, indent=2)
This will output the following AST:
Winding(at='this',
attributes=[],
content=[
Winding(at='dragons',
attributes=['portrait-oriented'],
content=[
Markdown(content='A book about dragons\n\n'),
Winding(at='front-cover', attributes=['portrait-oriented'],
content=[
Markdown(content='Dragons\n\n'),
Winding(at='center', attributes=['large', 'landscape-oriented'],
content=[Markdown(content=Image(caption='Flying Wind Dragon',
url='dragon.png')),
Markdown(content='\n')]
)])])])
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file winding-0.3.0.tar.gz.
File metadata
- Download URL: winding-0.3.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a0daea077eb12f96a437a5379b03255a38f8b82ad2f90d1defe4d90d0e9d516
|
|
| MD5 |
fc13756993a6242d0fb5493decbc6efb
|
|
| BLAKE2b-256 |
acb80720073db16af161f049a21c50f72719fd8b425dd8d8a9bcbaff244bbae1
|
Provenance
The following attestation bundles were made for winding-0.3.0.tar.gz:
Publisher:
workflow.yaml on Wind-WindKids/winding
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
winding-0.3.0.tar.gz -
Subject digest:
9a0daea077eb12f96a437a5379b03255a38f8b82ad2f90d1defe4d90d0e9d516 - Sigstore transparency entry: 216563159
- Sigstore integration time:
-
Permalink:
Wind-WindKids/winding@276a9c97aaea6f50d955c3be38b744fa0a1ed093 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Wind-WindKids
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@276a9c97aaea6f50d955c3be38b744fa0a1ed093 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file winding-0.3.0-py3-none-any.whl.
File metadata
- Download URL: winding-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
416e163928383c6c332a0c8ff2586fdbefb141eae4160dbc0ce5aa36a2f2d6be
|
|
| MD5 |
ba5015225194f01ced8649294277678a
|
|
| BLAKE2b-256 |
27bb9ef824579abe11ea0ebdd0546c1f9d5c1aea980852f51d4bcbb7dfc26713
|
Provenance
The following attestation bundles were made for winding-0.3.0-py3-none-any.whl:
Publisher:
workflow.yaml on Wind-WindKids/winding
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
winding-0.3.0-py3-none-any.whl -
Subject digest:
416e163928383c6c332a0c8ff2586fdbefb141eae4160dbc0ce5aa36a2f2d6be - Sigstore transparency entry: 216563168
- Sigstore integration time:
-
Permalink:
Wind-WindKids/winding@276a9c97aaea6f50d955c3be38b744fa0a1ed093 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Wind-WindKids
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@276a9c97aaea6f50d955c3be38b744fa0a1ed093 -
Trigger Event:
workflow_dispatch
-
Statement type: