diff options
author | Justin Turner Arthur <justinarthur@gmail.com> | 2021-08-20 03:38:30 -0500 |
---|---|---|
committer | Justin Turner Arthur <justinarthur@gmail.com> | 2021-08-21 00:20:04 -0500 |
commit | adcda091d968d25e83a3c69c13388c667ff5edcb (patch) | |
tree | 47fb1041923dc6984a9b8138caa5c6ae784eeeb1 /sphinx/util/nodes.py | |
parent | b174b77a14b19cc94d48c6cdef0dc49068dbf086 (diff) | |
download | sphinx-git-adcda091d968d25e83a3c69c13388c667ff5edcb.tar.gz |
Check complete ancestry of text nodes for smartquotes eligibility.
Fixes sphinx-doc/sphinx#9564.
Diffstat (limited to 'sphinx/util/nodes.py')
-rw-r--r-- | sphinx/util/nodes.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 7ce0933c6..78663e4c7 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -589,14 +589,16 @@ NON_SMARTQUOTABLE_PARENT_NODES = ( def is_smartquotable(node: Node) -> bool: """Check whether the node is smart-quotable or not.""" - if isinstance(node.parent, NON_SMARTQUOTABLE_PARENT_NODES): - return False - elif node.parent.get('support_smartquotes', None) is False: - return False - elif getattr(node, 'support_smartquotes', None) is False: + for pnode in traverse_parent(node.parent): + if isinstance(pnode, NON_SMARTQUOTABLE_PARENT_NODES): + return False + elif pnode.get('support_smartquotes', None) is False: + return False + + if getattr(node, 'support_smartquotes', None) is False: return False - else: - return True + + return True def process_only_nodes(document: Node, tags: "Tags") -> None: |