Skip to main content

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
![Flying Wind Dragon](dragon.png)
"""

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

winding-0.3.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

winding-0.3.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

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

Hashes for winding-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9a0daea077eb12f96a437a5379b03255a38f8b82ad2f90d1defe4d90d0e9d516
MD5 fc13756993a6242d0fb5493decbc6efb
BLAKE2b-256 acb80720073db16af161f049a21c50f72719fd8b425dd8d8a9bcbaff244bbae1

See more details on using hashes here.

Provenance

The following attestation bundles were made for winding-0.3.0.tar.gz:

Publisher: workflow.yaml on Wind-WindKids/winding

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for winding-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 416e163928383c6c332a0c8ff2586fdbefb141eae4160dbc0ce5aa36a2f2d6be
MD5 ba5015225194f01ced8649294277678a
BLAKE2b-256 27bb9ef824579abe11ea0ebdd0546c1f9d5c1aea980852f51d4bcbb7dfc26713

See more details on using hashes here.

Provenance

The following attestation bundles were made for winding-0.3.0-py3-none-any.whl:

Publisher: workflow.yaml on Wind-WindKids/winding

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page