Skip to content

Commit 80c72bc

Browse files
authored
fix: Ignore contents of <script> tags
PR-40: #40
1 parent b681aa3 commit 80c72bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mkdocs_spellcheck/_internal/words.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@ def __init__(self, ignore_code: bool = True) -> None: # noqa: FBT001,FBT002
2121
self.text = StringIO()
2222
self.ignore_code = ignore_code
2323
self.in_code_tag = False
24+
self.in_script_tag = False
2425
self.in_guard = False
2526

2627
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: # noqa: ARG002
2728
if tag == "code":
2829
self.in_code_tag = True
30+
if tag == "script":
31+
self.in_script_tag = True
2932
self.text.write(" ")
3033

3134
def handle_endtag(self, tag: str) -> None:
3235
if tag == "code":
3336
self.in_code_tag = False
37+
if tag == "script":
38+
self.in_script_tag = False
3439

3540
def handle_comment(self, data: str) -> None:
3641
data = data.strip()
@@ -45,6 +50,9 @@ def handle_data(self, data: str) -> None:
4550
if self.ignore_code and self.in_code_tag:
4651
return
4752

53+
if self.in_script_tag:
54+
return
55+
4856
if self.in_guard:
4957
return
5058

0 commit comments

Comments
 (0)