tldr-pages / tldr-python-client

Python command-line client for tldr pages
https://pypi.org/project/tldr/
MIT License
596 stars 93 forks source link

improve handling of tokens ending with braces #185

Closed MasterOdin closed 2 years ago

MasterOdin commented 2 years ago

Fixes #184

Tokens may contain any character, including a } at its end. The current parser to detect tokens greedily picks up the sequence }}, which does not include any number of trailing } which would actually end the token. For example, given {{{ a }}}, the parser would detect the token as { a, and leave a trailing } on the line, when the actual token is { a }.

This PR modifies our regex so that we include any number of } characters greedily before our final }} that closes the token, so that we force the final }} as our token closure. This looks like it handles both examples given in #184 as expected, and a quick look did not show any pages as looking abnormal.