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. The syntax is strongly based on this wmd fork.
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
Text fields
name = ___
or:
name = ___[50]
Exactly 3 underscores will be matched. Any more will be handled as standard underline directives.
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.
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
}
}
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.