New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add automatic hashtag parsing from note-like posts #57
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
527c8f0
Add admin namespaces to venues.jinja2
LanaCoyote 4338a98
Hashtags in non-articles are now parsed to links
LanaCoyote 1180149
Added some tests for hashtag parsing
LanaCoyote d164c2f
Fixed hashtag parser vs. non-strings
LanaCoyote bb9bec7
More test cases!!!
LanaCoyote 76b7391
Confirm post content exists before parsing tags
LanaCoyote 5751203
Fixed missing comma in hashtag test cases
LanaCoyote bf565d9
Update regex for hashtags to #(\w\w+)
LanaCoyote e38adce
More test cases and some fixes to parsing issues
LanaCoyote e076204
Removed excess white space in tests
LanaCoyote 15b7b56
Moved bs4_sub to toplevel and added to parser
LanaCoyote 3694273
Exclude hashtags from change in format_as_text
LanaCoyote File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -141,3 +141,55 @@ def simple_name_marker(contact, name, soup): | |
assert out == util.autolink( | ||
inp, person_processor=simple_name_marker, | ||
url_processor=None) | ||
|
||
|
||
def test_parsing_hashtags(): | ||
"""Exercise the #-tag matching regex | ||
""" | ||
|
||
test_cases = [ | ||
('#hashtag should be linked', | ||
'<a href="/tags/hashtag">#hashtag</a> should be linked', | ||
['hashtag']), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heh, I wonder if this will fix the problem where markdown thinks a # at the beginning of a note means it should be a header. |
||
('hashtag should not be linked', | ||
'hashtag should not be linked', | ||
[]), | ||
('match #hashtags in the middle', | ||
'match <a href="/tags/hashtags">#hashtags</a> in the middle', | ||
['hashtags']), | ||
('match a tag at the #end', | ||
'match a tag at the <a href="/tags/end">#end</a>', | ||
['end']), | ||
('#1 should not be linked', | ||
'#1 should not be linked', | ||
[]), | ||
('#12345 should be linked', | ||
'<a href="/tags/12345">#12345</a> should be linked', | ||
['12345']), | ||
('#.foobar should not be linked', | ||
'#.foobar should not be linked', | ||
[]), | ||
('#foo.bar should be partially linked', | ||
'<a href="/tags/foo">#foo</a>.bar should be partially linked', | ||
['foo']), | ||
('capital letters in #HashTags will be lowercased', | ||
'capital letters in <a href="/tags/hashtags">#HashTags</a> will be lowercased', | ||
['hashtags']), | ||
('duplicate #hashtags should parse both #hashtags fine', | ||
'duplicate <a href="/tags/hashtags">#hashtags</a> should parse both <a href="/tags/hashtags">#hashtags</a> fine', | ||
['hashtags','hashtags']), | ||
('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt aliquam sem, in tempus elit lacinia vel. Integer accumsan cursus purus et euismod. Nullam ultricies nunc sit amet ante consequat porta. Pellentesque et porta odio. Sed et neque cursus, iaculis lorem nec, laoreet odio. Donec molestie volutpat vestibulum. Curabitur rhoncus elit ut massa pretium luctus. #Nullam sollicitudin ligula vitae tincidunt suscipit. Maecenas in neque porta, scelerisque metus at, mollis nunc. Fusce accumsan imperdiet velit, in tincidunt tellus aliquam ac. Nullam iaculis vel urna sed vulputate. Aliquam erat volutpat. Etiam et tortor turpis. Vivamus mattis enim lacus, in aliquet nulla blandit.', | ||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent tincidunt aliquam sem, in tempus elit lacinia vel. Integer accumsan cursus purus et euismod. Nullam ultricies nunc sit amet ante consequat porta. Pellentesque et porta odio. Sed et neque cursus, iaculis lorem nec, laoreet odio. Donec molestie volutpat vestibulum. Curabitur rhoncus elit ut massa pretium luctus. <a href="/tags/nullam">#Nullam</a> sollicitudin ligula vitae tincidunt suscipit. Maecenas in neque porta, scelerisque metus at, mollis nunc. Fusce accumsan imperdiet velit, in tincidunt tellus aliquam ac. Nullam iaculis vel urna sed vulputate. Aliquam erat volutpat. Etiam et tortor turpis. Vivamus mattis enim lacus, in aliquet nulla blandit.', | ||
['nullam']), | ||
('this hash#tag will not be parsed', | ||
'this hash#tag will not be parsed', | ||
[]), | ||
('http://example.com/path#fragment', | ||
'http://example.com/path#fragment', | ||
[]), | ||
] | ||
|
||
for inp, out, tags in test_cases: | ||
res, ts = util.parse_hashtags(inp) | ||
assert out == res | ||
assert tags == ts |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks so much for adding test cases! could you add a couple more :)
inside a larger string
http://example.com/path#fragment
)