dskinner / damsel-python

Markup Language featuring html outlining via css-selectors, embedded python, and extensibility.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Pretty Source Formatting

opened this issue · comments

Dmsl generates some nastily formatted HTML output. Sensible newlines would be nice.

From the template:

%html
    %head
        %title Headshots Backend API Manager
    %body
        %h2 Overview
        %p This is the webservice to manage images stored within S3.
        %h2 Submit a New Thumbnail Request
        %form[action="/create"][method="post"]
            %label[for="create_form_url"] Url 
            %input[id="create_form_url"][type="text"][name="url"]
            %input[id="create_form_submit"][type="submit"][name="submit"]

DMSL generates:

<!DOCTYPE html><html><head><title>Headshots Backend API Manager</title></head><body><h2>Overview</h2><p>This is the webserive to manage images stored within S3.</p><h2>Submit a New Thumbnail Request</h2><form action="/create" method="post"><label for="create_form_url">Url</label><input id="create_form_url" type="text" name="url"></input><input id="create_form_submit" type="submit" name="submit"></input></form></body></html>

I would like for it to generate:

<!DOCTYPE html>
<html>
    <head>
        <title>Headshots Backend API Manager</title>
    </head>
    <body>
        <h2>Overview</h2>
        <p>This is the webserive to manage images stored within S3.</p>
        <h2>Submit a New Thumbnail Request</h2>
        <form action="/create" method="post">
            <label for="create_form_url">Url</label>
            <input id="create_form_url" type="text" name="url"></input>
            <input id="create_form_submit" type="submit" name="submit"></input>
        </form>
    </body>
</html>

This was possible back when dmsl relied on lxml since it had the option to pretty print, though lxml pprint wouldn't have resulted in the example given, but close enough to look nice.

I'll have to give this some thought. On one hand, I could pursue some rudimentary pretty printing in the cdoc.pyx file. On the other, I could bake in support for a popular pretty print library if its available and throw up warnings if trying to pretty print if said lib isn't installed.

I agree though, having a pretty print option is a nice sanity check when visually inspecting.