Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when captioning multiple figures that are produced by code #374

Open
mmcky opened this issue Nov 12, 2021 · 0 comments
Open

Issue when captioning multiple figures that are produced by code #374

mmcky opened this issue Nov 12, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@mmcky
Copy link
Member

mmcky commented Nov 12, 2021

Describe the problem

When using caption and labels in the cell metadata, there is an issue when there is more than one figure in a single document

self = <document: <section "formatting code outputs"...>>, node = <figure "fun-fish2": <image...><caption...>>, id = 'fun-fish2'
msgnode = <figure "fun-fish2": <image...><caption...>>, explicit = True

    def set_name_id_map(self, node, id, msgnode=None, explicit=None):
        """
        `self.nameids` maps names to IDs, while `self.nametypes` maps names to
        booleans representing hyperlink type (True==explicit,
        False==implicit).  This method updates the mappings.
    
        The following state transition table shows how `self.nameids` ("ids")
        and `self.nametypes` ("types") change with new input (a call to this
        method), and what actions are performed ("implicit"-type system
        messages are INFO/1, and "explicit"-type system messages are ERROR/3):
    
        ====  =====  ========  ========  =======  ====  =====  =====
         Old State    Input          Action        New State   Notes
        -----------  --------  -----------------  -----------  -----
        ids   types  new type  sys.msg.  dupname  ids   types
        ====  =====  ========  ========  =======  ====  =====  =====
        -     -      explicit  -         -        new   True
        -     -      implicit  -         -        new   False
        None  False  explicit  -         -        new   True
        old   False  explicit  implicit  old      new   True
        None  True   explicit  explicit  new      None  True
        old   True   explicit  explicit  new,old  None  True   [#]_
        None  False  implicit  implicit  new      None  False
        old   False  implicit  implicit  new,old  None  False
        None  True   implicit  implicit  new      None  True
        old   True   implicit  implicit  new      old   True
        ====  =====  ========  ========  =======  ====  =====  =====
    
        .. [#] Do not clear the name-to-id map or invalidate the old target if
           both old and new targets are external and refer to identical URIs.
           The new target is invalidated regardless.
        """
        for name in node['names']:
            if name in self.nameids:
                self.set_duplicate_name_id(node, id, name, msgnode, explicit)
            else:
                self.nameids[name] = id
>               self.nametypes[name] = explicit
E               TypeError: 'dict_items' object does not support item assignment

MyST-NB/.tox/py38-sphinx4/lib/python3.8/site-packages/docutils/nodes.py:1465: TypeError

Link to your repository or website

#373

Steps to reproduce

Added a test case

#373

The version of Python you're using

No response

Your operating system

No response

Versions of your packages

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant