-
-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QuickNav Text paragraph navigation (#16031)
Closes #15998 Summary of the issue: Add QuickNav text paragraph navigation Description of user facing changes Added QuickNav gesture p to jump to next/previous text paragraph in browse mode. Description of development approach In BrowseModeTreeInterceptor added function _iterSimilarParagraph that finds next/previous paragraph that satisfies condition defined by a lambda function. I will reuse this function in later PRs to implement vertical navigation. Added a new clause in BrowseModeTreeInterceptor._quickNavScript() that handles text paragraph case and calls function defined in the previous bullet. For text criteria I ended up implementing a user configurable regex. Its initial value is defined in DEFAULT_TEXT_PARAGRAPH_REGEX variable in configSpec.py:11. It is user-configurable in Browse Mode page in NVDA options. The rationale for using a regex instead of plain-text search is to reduce the number of false positives. For example, for period character we check that it follows a word character \w and is followed by space character or end of string. There are a few more rules for edge cases in the code. I don't include comma, colon and semicolon punctuation marks in the regex due to high number of false positives. The regex also accounts for CJK languages by checking for full-width punctuation marks.
- Loading branch information
Showing
8 changed files
with
211 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# A part of NonVisual Desktop Access (NVDA) | ||
# Copyright (C) 2024 NV Access Limited | ||
# This file is covered by the GNU General Public License. | ||
# See the file COPYING for more details. | ||
|
||
DEFAULT_TEXT_PARAGRAPH_REGEX = ( | ||
r"({lookBehind}{optQuote}{punc}{optQuote}{optWiki}{lookAhead}|{punc2}|{cjk})".format( | ||
# Look behind clause ensures that we have a text character before text punctuation mark. | ||
# We have a positive lookBehind \w that resolves to a text character in any language, | ||
# coupled with negative lookBehind \d that excludes digits. | ||
lookBehind=r'(?<=\w)(?<!\d)', | ||
# In some cases quote or closing parenthesis might appear right before or right after text punctuation. | ||
# For example: | ||
# > He replied, "That's wonderful." | ||
optQuote=r'["”»)]?', | ||
# Actual punctuation marks that suggest end of sentence. | ||
# We don't include symbols like comma and colon, because of too many false positives. | ||
# We include question mark and exclamation mark below in punc2. | ||
punc=r'[.…]{1,3}', | ||
# On Wikipedia references appear right after period in sentences, the following clause takes this | ||
# into account. For example: | ||
# > On his father's side, he was a direct descendant of John Churchill.[3] | ||
optWiki=r'(\[\d+\])*', | ||
# LookAhead clause checks that punctuation mark must be followed by either space, | ||
# or newLine symbol or end of string. | ||
lookAhead=r'(?=[\r\n ]|$)', | ||
# Include question mark and exclamation mark with no extra conditions, | ||
# since they don't trigger as many false positives. | ||
punc2=r'[?!]', | ||
# We also check for CJK full-width punctuation marks without any extra rules. | ||
cjk=r'[.!?:;]', | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters