Skip to main content

velocitous markup language to JSON parser

Project description

vml

velocitous markup language

(Totally not related with VML-SVG)
This is a JSON parser for a markup language, if you want to call it like that, that i found myself using while jolting notes in the fastest most velocitous, and laziest way that i could think of... It goes pretty much like this:

element 1
	things
		dog
		[x] snacks
			[ ] apple
			pear
		house
	names
		james
		alfred
[ ] element 2
	foo
	bar
	baz
foobar

That translates to this bulky JSON. You see, it makes JSON look bulky!!!

[
    {
        "element 1": [
            {
                "things": [
                    "dog",
                    {
                        "snacks": [
                            {
                                "apple": [],
                                "checked": false
                            },
                            "pear"
                        ],
                        "checked": true
                    },
                    "house"
                ]
            },
            {
                "names": [
                    "james",
                    "alfred"
                ]
            }
        ]
    },
    {
        "element 2": [
            "foo",
            "bar",
            "baz"
        ],
        "checked": false
    },
    "foobar"
]

vml uses tabs to differentiate the hierarchical level of the current line... i think you got what i mean. Plus, you can also add checkboxes to every line with "[ ]", and you can check it with "[x]", and all this translates to a "checked" property in the JSON representation. It's easy to write vml with vi, for example you might check an empty checkbox with rx and move around tabulations efficiently with >> or <<. In fact, this should really have been called tml, as in tab markup language, but unfortunately, that resembled too much TOML, dammit you Tom!!
Install this with pip3 install vml-parser.
import it with from vml_parser import vml, so you that you can access the vml.parse(s : list[str]) -> list[Element] method. A list of Elements gives you a middleware representation of what's in your vml. You might, vice versa, build up programmatically your list of Elements, and vml.dump(obj: list[Element]) -> list[str] for a later use. You now can also dump a list of JSON strings to a vml-formatted list of lines with vml.dumps(lines: list[str]) -> list[str].
You will also get the vml command line script for free! (it pairs neatly with the jq cli). You can pipe it to stdout or you can pass it any number of filenames for it to read, and with -d you can use the included JSON to vml dumper. Have fun with it laying crazy pipes like ... | vml | vml -d | vml | vml -d | ...!! When passing multiple files, this trick is actually useful, as it will merge all the files into one vml file or dump all json data from different files in one big vml. Now there is also a -m or --markdown option to convert vml to markdown. This is to be compliant with extended markdown. When passing a single file, top level elements will be converted to a h1 header, and subelements to h2 headers. When passing multiple files, each file name will be a h1 header, where _ and - are replaced with . All other sub elements will be converted to list items, indented accordingly.
With pandoc, when converting to html or pdf, latex math works (with -s and --mathjax) with elements that are surrounded by $ like $\exp{x}$ and footnotes also work with [^1] and [^1]:.

tools suggested for optimal experience

  • vscode
  • python3
  • pandoc
  • GNU make
  • jq

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

vml-parser-0.0.15.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

vml_parser-0.0.15-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file vml-parser-0.0.15.tar.gz.

File metadata

  • Download URL: vml-parser-0.0.15.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for vml-parser-0.0.15.tar.gz
Algorithm Hash digest
SHA256 03a6723770336bb16f4c34f28039ba741cbb2316ea47bd8a57b53d1253e43ce1
MD5 5ba100ddc54102cb8977ac52185762a2
BLAKE2b-256 741396a588eda73d71a6735621e5f766118721e2741232a98c0a0e27d9b7f75b

See more details on using hashes here.

File details

Details for the file vml_parser-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: vml_parser-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for vml_parser-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 92423275329ae544056a768067be54ff38aaa477f2e591bd3be458867af06406
MD5 dbcbc11b5625fa299fd907c0f470d105
BLAKE2b-256 b13a437f553ea2935d3d876a11693c2650286da5ff48e86b6cf543463d308406

See more details on using hashes here.

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