Skip to main content

Verify HTML code submissions and auto-generate meaningful feedback messages.

Project description

htmlwhat

htmlwhat is a Python module that provides feedback on incorrect HTML code submissions. It's often used in educational platforms where students submit HTML code as part of their assignments or exercises.

Installation

# latest stable version from PyPi
pip install htmlwhat

# latest development version from GitHub
pip install git+https://github.com/arlarse/htmlwhat

Quick Start

from htmlwhat.test_exercise import test_exercise

userhtml = """
<!DOCTYPE html>
<html>
    <head>
        <title>Title</title>
    </head>
    <body class="hello">
        <h1>My First Heading</h1>
    </body>
</html>
"""

solutionhtml = """
<!DOCTYPE html>
<html>
    <head>
        <title>Title</title>
    </head>
    <body class="example">
        <h1>My First Heading</h1>
    </body>
</html>
"""

test = "Ex().check_body().has_equal_attr()"

print(test_exercise(
    test,
    userhtml,
    solutionhtml,
))

Output:

{'correct': False, 'message': 'Inspect the <code>&lt;body&gt;</code> tag. Expected attribute <code>class</code> to be <code>"example"</code>, but found <code>"hello"</code>.'}

Problems after installation

htmlwhat built over protowhat which uses jinja2==2.11.3, and jinja uses MarkupSafe==2.0.1. Hence you will face this error

ImportError: cannot import name 'soft_unicode' from 'markupsafe'

so install the latest version of jinja2 using the following command:

pip install --upgrade jinja2

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

htmlwhat-1.0.1.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

htmlwhat-1.0.1-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page