-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from openzim/populate_search_indexes
Index pages for suggestions and full-text search
- Loading branch information
Showing
4 changed files
with
63 additions
and
12 deletions.
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,17 @@ | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
def get_soup(content: str) -> BeautifulSoup: | ||
"""Return a BeautifulSoup soup from HTML content | ||
This is a utility function to ensure same parser is used in the whole codebase | ||
""" | ||
return BeautifulSoup(content, "lxml") | ||
|
||
|
||
def get_text(content: str) -> str: | ||
"""Return text data from HTML content | ||
This is typically meant to extract content to index in the ZIM | ||
""" | ||
return get_soup(content).getText("\n", strip=True) |
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