Parse Markdown form and generate useful templates and data.
Project description
mdform
An extension for python-markdown to generate parse a form in Markdown based document.
This document:
Please fill this form:
name* = ___
email = @
And also this important question:
Do you like this = () YES () NO
will generate the following jinja template:
Please fill this form:
{{ form.name }}
{{ form.email }}
And also this important question:
{{ form.do_you_like_this }}
and this dict:
that you can consume to generate a form.
Installation
pip install mdform
Usage
Syntax
The syntax is strongly based on this wmd fork.
Text fields
name = ___
or:
name = ___[50]
Exactly 3 underscores will be matched. Any more will be handled as standard underline directives.
Text area
name = |||
or:
name = |||[50]
Exactly 3 slashes will be matched.
Check boxes
phones = [] Android [x] iPhone [x] Blackberry
The option with an x will be the default.
Drop down
city = {BOS, SFO, (NYC)}
Or with user-friendly labels:
city = {BOS -> Boston, SFO -> San Francisco, (NYC -> New York City)}
city = {BOS, SFO, (NYC -> New York City)}
The option in parenthesis will be the default.
File Field
name = ...
or:
name = ...[png]
name = ...[png,jpg]
name = ...[png,jpg;Only image files]
Required fields
To flag a field as required, just add an asterisk after the name.
zip code* = ___
Sections
In certain cases is useful to create a named section.
[section:university]
name = ___
[section:school]
name = ___
will render as:
{{ form.university_name }} {{ form.school_name }}
and:
{'university_name': {'type': 'StringField',
'required': True,
'length': None
},
'school_name': {'type': 'StringField',
'required': True,
'length': None
}
}
Collapsable parts
In certain cases is useful to create a part of the form which collapses based on the value of a dropdown box. Just use the modifier [c] for the dropdown item that will collapse the part of the html and enclose the collapsable part as shown:
extra = {Yes, (No[c])}
[collapse:extra]
name = ___
[endcollapse]
The extra in the collapse tag indicates which dropdown box is used as control.
See AUTHORS for a list of the maintainers.
To review an ordered list of notable changes for each version of a project, see CHANGES
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 mdform-0.2.tar.gz.
File metadata
- Download URL: mdform-0.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaedafdf9343c989a059d1effbead1fbc8642887eae1f8e30fd975a5b57368f0
|
|
| MD5 |
82824483739addf6b9f146a600f0c4f8
|
|
| BLAKE2b-256 |
410b281941e7a8cc8d095ed8f0ff2e41f5be46edf0e3ad35621b7ae65d1466b3
|
File details
Details for the file mdform-0.2-py2.py3-none-any.whl.
File metadata
- Download URL: mdform-0.2-py2.py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07501a5adff4c3772f8a4256f3aef2fa28be7aa17e93b574d8b42d4153bb69ec
|
|
| MD5 |
b12c9052f9f5cb6a3d81bc6ffdfcb27d
|
|
| BLAKE2b-256 |
1b1c2b6a208ab85fb5137d4390258a3c90bc61f646d45fb76cdabc4542442863
|