summaryrefslogtreecommitdiff
path: root/pygments/token.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/token.py')
-rw-r--r--pygments/token.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/pygments/token.py b/pygments/token.py
index 7ec93262..bbbcc648 100644
--- a/pygments/token.py
+++ b/pygments/token.py
@@ -57,6 +57,15 @@ Comment = Token.Comment
Generic = Token.Generic
+def is_token_subtype(ttype, other):
+ """Return True if ``ttype`` is a subtype of ``other``."""
+ while ttype is not None:
+ if ttype == other:
+ return True
+ ttype = ttype.parent
+ return False
+
+
# Map standard token types to short names, used in CSS class naming.
# If you add a new item, please be sure to run this file to perform
# a consistency check for duplicate values.