0

I am defining my custom role that allows :ref: markups to be inside of it. The role is to be used as follows:

myrole:`some_text |SUBS| more_text`

A function replaces |SUBS| by

:ref:`some_target`

so I end up with the following string

some_text :ref:`some_target` more_text

My python code is below in which I am not sure what to set the lineno, memo and parent argument to the inliner.parse() function

from docutils import nodes
from docutils.parsers.rst import Directive
from sphinx import addnodes

def myrole(role, rawtext, text, lineno, inliner, options={}, content=[]):

    app=inliner.document.settings.env.app
    #the below function replaces |SUBS| with the :ref: markup

    new_string=process_subs(text)
    
    nodelist,_=inliner.parse(new_string,lineno,memo,parent)

    return nodelist, []

    
def setup(app):
    app.add_role('myrole', myrole)

0 Answers0