Custom interface using static html

Cannot render checkbox using custom html. It works fine if rendering text only.
view_id is set to ‘html’

def add_multilabels(stream):
    html_render = <input type="checkbox" value="test"> Test #Show syntax error (html hidden refer to image attached)
    html_render = "<strong>test</strong>" #works fine (html hidden refer to image attached)
    for task in stream:
        task['html'] = html_render
        yield task

File “recipe_multi_labeling.py”, line 31
html_render = " Test"
^
SyntaxError: invalid syntax

Hi! I hope I understand your question correctly. A SyntaxError in your own script normally means that there’s invalid code in there that Python cannot interpret – so this is unlikely to be a problem in Prodigy.

I think in your case, the problem is here:

html_render = <input type="checkbox" value="test"> Test

html_render is supposed to be a string containing HTML markup, but it’s missing the quotation marks around it:

html_render = '<input type="checkbox" value="test"> Test'

Alternatively (and if you’re writing JSON), you could also escape the double quotes with a backslash, e.g. type=\"checkbox\".

If you want to use checkboxes, you might also want to try the choice interface? See here for an example recipe. The question and each option can all take "html" instead of "text", so you can also use custom formatting there. For example, a choice task could look like this:

{
    "html": "<strong>The question</strong>",
    "options": [
        {"id": 0, "html": "<span style=\"color: red\">an option</span>"}
    ]
}