### Start a Hatch Development Shell Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Enter an isolated virtual environment managed by Hatch, which automatically installs all project dependencies, including development tools. ```bash hatch shell ``` -------------------------------- ### Install Hatch for Development Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Install the Hatch build tool, which is required for development and adherence to project conventions. This is typically done using pip. ```bash pip install hatch ``` -------------------------------- ### Install Pre-commit Git Hook Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Set up the pre-commit Git hook to automatically run linters and formatters before each commit, ensuring code quality and consistency. ```bash pre-commit install ``` -------------------------------- ### Install Alpine Dependencies Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Install system dependencies for zimscraperlib on Alpine Linux using apk. Required packages are ffmpeg, gifsicle, libmagic, wget, and cairo. ```bash apk add ffmpeg gifsicle libmagic wget cairo ``` -------------------------------- ### Install APT Dependencies on Linux Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Install required system packages for zimscraperlib on Debian-based Linux distributions using apt. This includes libmagic, wget, ffmpeg, gifsicle, and libcairo. ```bash sudo apt install libmagic1 wget ffmpeg gifsicle libcairo2 ``` -------------------------------- ### Install zimscraperlib Package Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Install the zimscraperlib package using pip, specifying a version range. Ensure to reference it with a version code as the API is subject to frequent changes. ```bash pip install zimscraperlib>=1.1,<1.2 ``` -------------------------------- ### Install Homebrew Dependencies on macOS Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Install necessary system dependencies for zimscraperlib on macOS using Homebrew. These include libmagic, wget, ffmpeg, gifsicle, and cairo. ```bash brew install libmagic wget ffmpeg gifsicle cairo ``` -------------------------------- ### Example of Rewriting Absolute URL in HTML Source: https://github.com/openzim/python-scraperlib/blob/main/docs/functional_architecture.md Demonstrates how an absolute image URL in an HTML document is rewritten to a relative URL for use within a ZIM. This is necessary because openZIM prohibits absolute URLs for reader compatibility. ```html ``` -------------------------------- ### JavaScript for Wombat URL Information Source: https://github.com/openzim/python-scraperlib/blob/main/src/zimscraperlib/rewriting/templates/head_insert.html This snippet executes within the browser to capture the current URL, process it with Wombat setup functions, and initialize Wombat if the environment is detected. It relies on server-side variables for original host, scheme, and URL. ```html {% autoescape false %} {% set urlsplit = url | urlsplit %} // Get the current url we are serving from. // We cannot know it at zim creation as it depends of our server. const current_url = (function () { var href = new URL(window.location.href); href.hash = ''; return href.toString(); })(); const wbinfo = wombatSetup.getWombatInfo( current_url, '{{ orig_host }}', '{{ orig_scheme }}', '{{ orig_url }}', current_url.substring(0, current_url.length - '{{ path }}'.length), ); if (window && window._WBWombatInit) { window._WBWombatInit(wbinfo); } {% endautoescape %} ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/openzim/python-scraperlib/blob/main/README.md Execute the project's test suite and generate a coverage report using the 'invoke' task runner. This helps in assessing test completeness. ```bash invoke coverage ``` -------------------------------- ### Run JavaScript Tests Source: https://github.com/openzim/python-scraperlib/blob/main/docs/technical_architecture.md Executes the test suite for the JavaScript components of the project. ```bash cd javascript && yarn test ``` -------------------------------- ### Generate Fuzzy Rules Source: https://github.com/openzim/python-scraperlib/blob/main/docs/technical_architecture.md Regenerates Python and JavaScript files from fuzzy rules defined in rules.yaml. This command must be run after updating the fuzzy rules. ```bash python rules/generateRules.py ``` -------------------------------- ### Bundle JavaScript Source: https://github.com/openzim/python-scraperlib/blob/main/docs/technical_architecture.md Bundles the JavaScript code for production using rollup. This command is used after updating fuzzy rules or JavaScript code. ```bash cd javascript && yarn build-prod ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.