I have google this error and find no-one else encounter this ValueError before. You could see from the traceback log below that the error is triggered by my code line
bg_color = run.font.highlight_color
I guess python-docx library encounter some weird case that it cannot handle? Maybe it's some WD_COLOR_INDEX value that contain in the docx that python-docx do not recognize.
If python-docx meet and place where there's no font.hightlight_color, it should just return a None to me instead trying to get a translation value from some xml mapping.
How could I fixed this?
Traceback (most recent call last):
File "XXX.py", line 377, in <module>
main()
...
bg_color = run.font.highlight_color
File "/home/xxx/.local/lib/python3.8/site-packages/docx/text/font.py", line 139, in highlight_color
return rPr.highlight_val
File "/home/xxx/.local/lib/python3.8/site-packages/docx/oxml/text/font.py", line 183, in highlight_val
return highlight.val
File "/home/xxx/.local/lib/python3.8/site-packages/docx/oxml/xmlchemy.py", line 254, in get_attr_value
return self._simple_type.from_xml(attr_str_value)
File "/home/xxx/.local/lib/python3.8/site-packages/docx/enum/base.py", line 64, in from_xml
raise ValueError(f"{cls.__name__} has no XML mapping for '{xml_value}'")
ValueError: WD_COLOR_INDEX has no XML mapping for 'none'