Skip to content

pdf-builder fails with "KeyError: 'icon_name'" when in conf.py 'sd_fontawesome_latex = True' is set #87

Closed

Description

@koeppe-at-pdtec

Describe the bug

context
Using fontawesom inline icons breaks pdf builder.

expectation
PDF is build correctly

Error Message

resolving references...
done
writing... failed
Exception occurred while building, starting debugger:
Traceback (most recent call last):
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\cmd\build.py", line 277, in build_main    app.build(args.force_all, filenames)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\application.py", line 349, in build   
    self.builder.build_update()
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\builders\__init__.py", line 298, in build_update
    self.build(['__all__'], to_build)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\builders\__init__.py", line 367, in build
    self.write(docnames, list(updated_docnames), method)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\builders\latex\__init__.py", line 301, in write
    docwriter.write(doctree, destination)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\docutils\writers\__init__.py", line 78, in write
    self.translate()
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\writers\latex.py", line 86, in translate
    self.document.walkabout(visitor)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\docutils\nodes.py", line 227, in walkabout   
    if child.walkabout(visitor):
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\docutils\nodes.py", line 227, in walkabout   
    if child.walkabout(visitor):
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\docutils\nodes.py", line 227, in walkabout   
    if child.walkabout(visitor):
  [Previous line repeated 2 more times]
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\docutils\nodes.py", line 219, in walkabout   
    visitor.dispatch_visit(self)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx\util\docutils.py", line 563, in dispatch_visit
    method(node)
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\sphinx_design\icons.py", line 211, in visit_fontawesome_latex
    self.body.append(f"\\faicon{{{node['icon_name']}}}")
  File "C:\Users\<username>\.virtualenvs\SDM-Ii3b-2T0\lib\site-packages\docutils\nodes.py", line 652, in __getitem__ 
    return self.attributes[key]
KeyError: 'icon_name'
> c:\users\<username>\.virtualenvs\sdm-ii3b-2t0\lib\site-packages\docutils\nodes.py(652)__getitem__()
-> return self.attributes[key]
(Pdb) 

Reproduce the bug

settings in conf.py:
html_css_files = ["https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css"] sd_fontawesome_latex = True html_theme = "sphinx_rtd_theme"

add examples from documention to the index.rst:
`

  • An icon :fas:spinner;sd-text-primary, some more text.
  • An icon :fab:github, some more text.
  • An icon :fab:gitkraken;sd-text-success fa-xl, some more text.
  • An icon :fas:skull;sd-text-danger, some more text.
    `

run make pdf

List your environment

Python Version 3.10.3
sphinx-rtd-theme==1.0.0
sphinx-design==0.2.0

Activity

  1. added
    bug
    on Aug 15, 2022
  2. welcome commented on Aug 15, 2022

    @welcome

    Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

    If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

    If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

    Welcome to the EBP community! 🎉

  3. koeppe-at-pdtec commented on Aug 15, 2022

    @koeppe-at-pdtec
    Author

    can be fixed by:

    self.body.append(f"\\faicon{{{node['icon_name']}}}")

    .. --- self.body.append(f"\faicon{{{node['icon_name']}}}")
    .. +++ self.body.append(f"\faicon{{{node['icon']}}}")

    At least it fixed the issue for me, but i'm unsure if this is the correct fix here.

  4. chrisjsewell commented on Aug 15, 2022

    @chrisjsewell
    Member

    cheers for the report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions