|
1 | | -# Quarto Extension Development with Lua in a Devcontainer |
| 1 | +# linkrot <img src="docs/linkrot-animated-logo.svg" align ="right" alt="" width ="150"/> |
2 | 2 |
|
3 | | -This repository houses a devcontainer that setups a [Quarto extension development environment](https://quarto.org/docs/extensions/lua.html). The container is setup to work with [GitHub Codespaces](https://github.com/features/codespaces) to instantly have a cloud-based developer workflow. |
| 3 | +A Quarto extension that automatically checks for broken external links in your documents during rendering. |
4 | 4 |
|
5 | | -You can try out the Codespace by clicking on the following button: |
| 5 | +## Installation |
6 | 6 |
|
7 | | -[](https://codespaces.new/coatless-devcontainer/quarto-extension-dev?quickstart=1) |
| 7 | +To install the `linkrot` Quarto extension, follow these steps: |
8 | 8 |
|
9 | | -**Note:** Codespaces are available to Students and Teachers for free [up to 180 core hours per month](https://docs.github.com/en/education/manage-coursework-with-github-classroom/integrate-github-classroom-with-an-ide/using-github-codespaces-with-github-classroom#about-github-codespaces) through [GitHub Education](https://education.github.com/). Otherwise, you will have [up to 60 core hours and 15 GB free per month](https://github.com/features/codespaces#pricing). |
| 9 | +1. Open your terminal. |
| 10 | +2. Execute the following command: |
10 | 11 |
|
11 | | -The devcontainer contains: |
| 12 | +```sh |
| 13 | +quarto add coatless-quarto/linkrot |
| 14 | +``` |
12 | 15 |
|
13 | | -- The latest [pre-release](https://quarto.org/docs/download/prerelease) version of Quarto. |
14 | | -- [Quarto VS Code Extension](https://marketplace.visualstudio.com/items?itemName=quarto.quarto). |
15 | | -- [Lua LSP VS Code Extension](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) for Lua code intelligence. |
16 | | -- [GitHub copilot VS Code Extension](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot). |
17 | | -- `R` and `Python` |
18 | | -- `knitr` and `jupyter` |
| 16 | +This command will download and install the Quarto extension under the `_extensions` subdirectory of your Quarto project. |
| 17 | +If you are using version control, ensure that you include this directory in your repository. |
19 | 18 |
|
20 | | -## References |
| 19 | +### Requirements |
| 20 | + |
| 21 | +- Quarto >= 1.7.0 |
| 22 | +- `curl` command-line tool: |
| 23 | + - **Linux/macOS**: Usually pre-installed |
| 24 | + - **Windows**: Built-in on Windows 10 (1803+) and Windows 11 |
| 25 | + - **Older Windows**: Install [curl for Windows](https://curl.se/windows/) or use Git Bash which includes curl |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +Add the extension to your document's YAML header: |
| 30 | + |
| 31 | +```yaml |
| 32 | +--- |
| 33 | +title: "My Document" |
| 34 | +filters: |
| 35 | + - linkrot |
| 36 | +--- |
| 37 | +``` |
| 38 | + |
| 39 | +The extension will automatically check all external HTTP/HTTPS links during rendering and report any broken links. |
| 40 | + |
| 41 | +## Configuration |
| 42 | + |
| 43 | +You can configure linkrot's behavior in your document's YAML using the `extensions.linkrot` key: |
| 44 | + |
| 45 | +```yaml |
| 46 | +--- |
| 47 | +title: "My Document" |
| 48 | +filters: |
| 49 | + - linkrot |
| 50 | +extensions: |
| 51 | + linkrot: |
| 52 | + fail-on-error: false # Set to true to fail the build if broken links are found |
| 53 | + timeout: 10 # Timeout in seconds for each URL check |
| 54 | + user-agent: "Quarto-Linkrot/1.0" # User agent string for requests |
| 55 | + cache-results: true # Cache results to avoid checking the same URL multiple times |
| 56 | + debug: false # Enable debug logging |
| 57 | + output-file: null # Write results to a file (e.g., "linkrot-report.txt") |
| 58 | + skip-patterns: # List of regex patterns to skip |
| 59 | + - "example\\.com" |
| 60 | + - "localhost" |
| 61 | +--- |
| 62 | +``` |
| 63 | + |
| 64 | +### Configuration Options |
| 65 | + |
| 66 | +#### fail-on-error** (default: `false`) |
| 67 | + |
| 68 | +- If set to `true`, the build will fail if any broken links are detected. Useful for CI/CD pipelines. |
| 69 | + |
| 70 | +#### timeout (default: `10`) |
| 71 | + |
| 72 | +- Maximum time in seconds to wait for each URL to respond. |
| 73 | + |
| 74 | +#### user-agent (default: `"Quarto-Linkrot/1.0"`) |
| 75 | + |
| 76 | +- User agent string sent with HTTP requests. |
| 77 | + |
| 78 | +#### cache-results (default: `true`) |
| 79 | + |
| 80 | +- Cache URL check results to avoid repeatedly checking the same URL in a document. |
| 81 | + |
| 82 | +#### debug (default: `false`) |
| 83 | + |
| 84 | +- Enable debug logging to see detailed information about what linkrot is doing. |
| 85 | + |
| 86 | +#### output-file (default: `null`) |
| 87 | + |
| 88 | +- Path to a file where results will be written. If not specified, results are only shown in the console. |
| 89 | + |
| 90 | +#### skip-patterns |
| 91 | + |
| 92 | +- List of regex patterns. URLs matching any pattern will be skipped (not checked). |
| 93 | + |
| 94 | +## Example Output |
| 95 | + |
| 96 | +When the extension runs, you'll see output like this in the console: |
| 97 | + |
| 98 | +```default |
| 99 | +=== Linkrot Results === |
| 100 | +Total external links checked: 15 |
| 101 | +Broken links found: 2 |
| 102 | +
|
| 103 | +Broken links: |
| 104 | + 1. [Example Link] https://example.com/broken-page (Status: 404) |
| 105 | + 2. [Another Link] https://nonexistent-site-xyz123.com (Status: timeout/error) |
| 106 | +``` |
| 107 | + |
| 108 | +You can also specify an output file to save the results. |
21 | 109 |
|
22 | | -- [Quarto: Lua API Reference](https://quarto.org/docs/extensions/lua-api.html) |
23 | | -- [Quarto: Lua Development](https://quarto.org/docs/extensions/lua.html) |
24 | | -- [Pandoc: Lua Filters](https://pandoc.org/lua-filters.html) |
25 | | -- [Lua: Manual](https://www.lua.org/manual/5.4/) |
|
0 commit comments