Issue #1550 wontfix

json add_node

Andrea Cassioli
created an issue

Hi, I am customizing the mathbase module to overcome some cross-referencing issue. I'd like to modify the way the json builder generate links for equation by the eqref role. I try to add a function handler for the json builder as

    latex=(latex_visit_eqref, None),
    text=(text_visit_eqref, None),
    man=(man_visit_eqref, None),
    texinfo=(texinfo_visit_eqref, None),
    html=(html_visit_eqref, html_depart_eqref),
    json=(json_visit_eqref, json_depart_eqref),

but it seems Sphinx just ignore it. From the docs it looks like json builder is supported via the html one. Is there any way it can be considered too?

Comments (5)

  1. Takayuki Shimizukawa
    • changed status to open


    As you mentioned, 'json' can't be used to Sphinx.add_node.

    Virtually, 'json' builder is a part of 'html' builder (as like as 'singlehtml' or 'pickle'). Each builders have 'name' and 'format' attribute. In this case, html_visit_eqref function can refer the attribute as:

    def html_visit_eqref(self, node):
        if == 'json':
        else:  # for html
  2. Andrea Cassioli reporter

    Hi, many thanks for the quick reply. I understand the point. Maybe it should be more clear in the docs to begin with. But I think it would be good to handle json explicitly.

  3. Georg Brandl repo owner

    The JSON builder is meant to store the HTML output as would be generated. Therefore its builder base is HTML.

    If you really need to override behavior for the json case, please use the solution provided by Takayuki.

  4. Log in to comment