-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 09.06.2010 16:07, schrieb Viktoras:
> Hi,
> 
> Would you consider it a worthwhile feature to warn about bad indentation 
> for list items? I find myself doing a mistake like this sometimes 
> (indenting everyting with tabs):
> 
> * watertight eyeball-eyelid contact
>      can be solved with precise blendshapes/skinning
> 
> ..instead of
> 
> * watertight eyeball-eyelid contact
>    can be solved with precise blendshapes/skinning
> 
> This leads to <dl> html being created inside <li>. While this shows up 
> just fine in Firefox, in Eclipse's built-in html viewer this does not 
> show list item bullet. This all not counting the unintended term 
> definition list being created.
> 
> I can image someone would eventually need that kind of markup 
> (definition list in list item), but in my case, it's just a typing error 
> in most cases, as there's a specific indentation needed (required amount 
> of tabs for current indentation level + 2 spaces). Is it possible to 
> issue a warning when such thing is encountered by writting a custom 
> plugin (never looked into the APIs of Sphinx actually) or does more 
> hacking with the Sphinx iteself would be needed?

Hi Viktoras,

yes, it would be possible to do this as an extension, it would look like
this:

def warn_unintended_dls(app, doctree):
    from docutils.nodes import list_item, definition_list
    for li in doctree.traverse(list_item):
        if len(li) == 1 and isinstance(li[0], definition_list):
            app.env.warn(app.env.docname, 'definition list inside list item',
                         li[0].line)

def setup(app):
    app.connect('doctree-read', warn_unintended_dls)


(Note that you can also put this in conf.py if it's intended for a single
project.)

Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)

iEUEARECAAYFAkwTsEAACgkQN9GcIYhpnLA7aQCfeFOYXufGB3elwraxCL0jv+RJ
hKkAli5S1mbYrtHFmNCEDxuULv4Yd9c=
=F8+S
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to