Re: [Feature/Bug] If a role content is empty, it's never called?

Guenter Milde <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2016-05-20, Anil Lakhman wrote:
> Hi,

> I'm not subscribed to the mailing list, please CC me if possible on the
> issue.

> I have filed a github issue here replicating the issue:

> https://github.com/sphinx-doc/sphinx/issues/2562

> Basically, If I add a custom role and pass an empty string within the
> backticks, the role is never called, so I don't have a chance to show a
> warning or error message. 

This is the same for standard roles::

  das ist `interpreted`

  das ist ` ` nichts

becomes ::

   <paragraph>
        das ist 
        <title_reference>
            interpreted
    <paragraph>
        das ist ` ` nichts

and is a consequence of the ``rST inline markup recognition rules`__

__ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules


> For example the :download: role shows a warning
> message if we pass an empty string or space within the backticks.

Really? Then parsing happens somehow differently from Docutils
implementation of rst.

> Am I missing something or is this not possible? (I'm using sphinx)

...

> # Now say I forget to pass through some text or empty space
> # (accidently deleted, forget I had it, etc..)
>:icon:``    # No text
>:icon:` `   # Space empty text

> #= :icon:``
> #= :icon:` `

> # Notice how it just outputs the role raw, it doesn't seem to even
> call `icon_role`
> # so I don't have a chance to check the value (and throw a warning)

> If the content with backticks is empty, I would like to decide what to do
> with the role (output a empty node, throw a warning, place a default icon).

> Am I missing something?

> The :download: role does this, but I'm finding it confusing as to who it's
> implemented. It throws the following error if you pass an empty string.

> # Throws an error: WARNING: Inline literal start-string without end-string.
>:download:``

Does this really happen with

 :download:``

It usually happens if there is no end string (and also nothing else), e.g.

 :math:`
 
but not with

 :funny:` more text

> # Just outputs the raw role text (I don't have a chance to do anything)
>:icon:``

Yes, this is not recognized as rST markup (just like e.g. ::

  x*y* or :math:` x+2 `

)

I am afraid this is an issue to stay, as it concerns defines rST rules.
You may file an enhancement ticket for recognition of
:something:`` or :something` ` but there is no chance of a quick fix
unfortunately.

Günter



------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.