Skip to content

Commit 6b8edfc

Browse files
enkerewpoJonathan Corbet
authored andcommitted
docs: automarkup.py: Skip common English words as C identifiers
The automarkup extension incorrectly recognizes common English words as C identifiers when they follow struct/union/enum/typedef keywords, causing normal text like "... (a simple) struct that" (in `workqueue.rst`) to be rendered as code blocks. This patch adds Skipidentifiers list to filter out these words. Signed-off-by: Yulong Han <wheatfox17@icloud.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20260125124450.2005006-1-wheatfox17@icloud.com>
1 parent a592a36 commit 6b8edfc

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Documentation/sphinx/automarkup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
#
4747
Skipnames = [ 'for', 'if', 'register', 'sizeof', 'struct', 'unsigned' ]
4848

49+
#
50+
# Common English words that should not be recognized as C identifiers
51+
# when following struct/union/enum/typedef keywords.
52+
# Example: "a simple struct that" in workqueue.rst should not be marked as code.
53+
#
54+
Skipidentifiers = [ 'that', 'which', 'where', 'whose' ]
4955

5056
#
5157
# Many places in the docs refer to common system calls. It is
@@ -163,6 +169,10 @@ def markup_c_ref(docname, app, match):
163169
if c_namespace:
164170
possible_targets.insert(0, c_namespace + "." + base_target)
165171

172+
# Skip common English words that match identifier pattern but are not C code.
173+
if base_target in Skipidentifiers:
174+
return target_text
175+
166176
if base_target not in Skipnames:
167177
for target in possible_targets:
168178
if not (match.re == RE_function and target in Skipfuncs):

0 commit comments

Comments
 (0)