Skip to content

Commit

Permalink
Merge pull request #8 from tomerha/markdown-paths
Browse files Browse the repository at this point in the history
added ` as a path delimit character for quickcopy and updated regexes
  • Loading branch information
CrispyConductor authored Dec 6, 2021
2 parents 289e186 + 8f24223 commit 0705681
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions _regex_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def make_path_regexes():
# paths with at least 3 elements, and never in the first or last element. There cannot
# be more than one consecutive space, and it cannot be at the beginning or end of the
# element.
edge_delimiters = r'[][\s:=,#$"{}<>()' + "'" + ']'
edge_delimiters_w_slash = r'[][\s:=,#$"{}<>()/' + "'" + ']'
edge_delimiters = r'[][\s:=,#$"{}<>()`' + "'" + ']'
edge_delimiters_w_slash = r'[][\s:=,#$"{}<>()`/' + "'" + ']'
leader = r'(?:^|' + edge_delimiters + ')'
leader_w_slash = r'(?:^|' + edge_delimiters_w_slash + ')'
follower = r'(?:$|' + edge_delimiters + ')'
Expand Down
6 changes: 3 additions & 3 deletions copytk.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def find_command_path(c):
# matches common types of urls and things that look like urls
'urls': r'(?:^|[][\s:=,#"{}()'+"'"+r'])([a-zA-Z][a-zA-Z0-9]{1,5}://(?:[a-zA-Z0-9_]+(?::[a-zA-Z0-9_-]+)?@)?(?:(?:[a-zA-Z0-9][\w-]*\.)*[a-zA-Z][\w-]*|(?:[0-2]?[0-9]{1,2}\.){3}[0-2]?[0-9]{1,2})(?::[0-9]{1,5})?(?:/(?:[\w.~%/&-]+|(?:[\w.~%/&-]*\([\w.~%/&-]*\)[\w.~%/&-]*)+)?/?)?(?:\?(?:(?:[\w.~%/&-]+|(?:[\w.~%/&-]*\([\w.~%/&-]*\)[\w.~%/&-]*)+)+(?:=(?:[\w.~%/&-]+|(?:[\w.~%/&-]*\([\w.~%/&-]*\)[\w.~%/&-]*)+)?)?&)*(?:(?:[\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A-Z0-9_-]{1,80}|\.|\.\.)[\\/]?)|(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)[\\/](?:(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)[\\/]?|(?:(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)|[a-zA-Z0-9_-]{1,60}\\? [a-zA-Z0-9_-]{1,60})\.[a-zA-Z0-9]{1,6})|(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)[\\/](?:(?:(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)|[a-zA-Z0-9_-]{1,60}\\? [a-zA-Z0-9_-]{1,60})[\\/])+(?:(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)[\\/]?|(?:(?:[a-zA-Z0-9_-]{1,80}|\.|\.\.)|[a-zA-Z0-9_-]{1,60}\\? [a-zA-Z0-9_-]{1,60})\.[a-zA-Z0-9]{1,6})))(?:$|[][\s:=,#$"{}<>()`'+"'"+r'])',
# Isolated filenames without paths
'filenames': r'(?:^|[][\s:=,#$"{}<>()/'+"'"+r'])([a-zA-Z0-9_-]{1,80}\.[a-zA-Z][a-zA-Z0-9]{0,5})(?:$|[][\s:=,#$"{}<>()'+"'"+r'])'
'filenames': r'(?:^|[][\s:=,#$"{}<>()`/'+"'"+r'])([a-zA-Z0-9_-]{1,80}\.[a-zA-Z][a-zA-Z0-9]{0,5})(?:$|[][\s:=,#$"{}<>()`'+"'"+r'])',
}


Expand Down

0 comments on commit 0705681

Please sign in to comment.