Menu

#56 :key:value not caught as badly formed option, but rather taken as an argument

Default
open
nobody
None
5
2017-10-17
2017-10-13
No

If your mistype your reST directive like this:

.. directive:: argument
:key:value (note the lack of a space between ":" and "v")

docutils interprests this as a directive with two arguments (argument, :key:value) instead on one argument and an option key value pair. It seems like it would be nice if there was a check for the final argument given (if more than one argument is given) along the lines of:

_emptystr, key, _emptystr, value = re.split(r"^\:(.?)\:(.?)", arg)
if key in self.option_spec and key not in self.options:
RAISE WARNING

Discussion

  • Günter Milde

    Günter Milde - 2017-10-17

    Thank you for the suggestion. Howerver, this is a feature request, not a bug. You may reopen it under https://sourceforge.net/p/docutils/feature-requests/ or start a thread in the docutils-devel list.

    You may experiment with the code in parsers/rst/states.py around line 2170 and the parse_directive_options method at line 2191.
    Tested patches are welcome.

    BTW: The interpretation of the given example depends on the directive, it could be one multi-line argument as in

    .. admonition:: test
          :me:not
    
          Content
    

    or just content as in

    .. hint:: some directives have
          :no:arguments.
    
     
  • Günter Milde

    Günter Milde - 2017-10-17

    Ticket moved from /p/docutils/bugs/330/

     

Log in to post a comment.