This package allows you to get an HTML string from the richtext field of Storyblok.
pip install storyblok-richtext
Instantiate the Richtext
class:
from storyblok_richtext import Richtext
resolver = Richtext()
Use the function render()
to get the html string from your richtext field.
# code below ...
data = {
'type': 'doc',
'content': [{
'type': 'horizontal_rule'
}]
}
resolver.render(data) # renders a html string: '<hr />'
Make a copy of the default schema storyblok_richtext/html_schema.py and add your own schema as parameter to the Richtext class.
resolver = Richtext(your_custom_schema)
Before the testing, we advise you to use an environment virtualization tool, for example, virtualenv:
# use virtualenv to create the environment
virtualenv -p python3 .
# activate the environment
source bin/activate
# you can execute the tests!
# to desactivate the environment
deactivate
We use unittest module for tests. You can execute the following task to run the tests:
$ python -m unittest discover storyblok_richtext/tests -v
Fork me on Github