fediverse_pasture_inputs.utils¶
fediverse_pasture_inputs.utils ¶
app_to_profile_map
module-attribute
¶
Maps app to profile used to generate details and support tables
escape_markdown ¶
Escapes markdown characters, necessary to display markdown (as done for firefish)
Source code in fediverse_pasture_inputs/utils.py
format_as_json ¶
Displays a dictionary as pretty printed json.
>>> format_as_json({"x": 1})
['<pre
style="line-height:1;">{</pre><pre
style="line-height:1;"> "x": 1</pre><pre
style="line-height:1;">}</pre>']
Parameters:
Name | Type | Description | Default |
---|---|---|---|
small
|
If true sets font-size to 75%. |
False
|
Source code in fediverse_pasture_inputs/utils.py
pre_format ¶
Escapes html text to pre formatted markdown
>>> pre_format(True)
['true']
>>> pre_format('<b>bold</b>\n<i>italic</i>')
['<pre><b>bold</b></pre><pre><i>italic</i></pre>']
Source code in fediverse_pasture_inputs/utils.py
pre_wrapped ¶
safe_first_element ¶
Returns the first element of a list, otherwise None
Source code in fediverse_pasture_inputs/utils.py
value_from_dict_for_app ¶
Returns the value corresponding to app from dictionary
by performing a lookup in app_to_profile_map and assuming mastodon
is the default
value.
>>> dictionary = {"known": "known",
... "mastodon": "mastodon",
... "firefish": "firefish"}
>>> value_from_dict_for_app(dictionary, "unknown")
'mastodon'
>>> value_from_dict_for_app(dictionary, "known")
'known'
>>> value_from_dict_for_app(dictionary, "misskey")
'firefish'
Source code in fediverse_pasture_inputs/utils.py
with_tooltip ¶
>>> with_tooltip("content", "tooltip")
"<span data-tooltip='tooltip' display='inline'>content</span>"