feat(remote_text shortcode): support line ranges (#399)

This commit is contained in:
welpo 2024-09-22 15:06:38 +02:00
parent 90c1da1ddb
commit 008b976e06
No known key found for this signature in database
GPG key ID: A2F978CF4EC1F5A6
4 changed files with 59 additions and 1 deletions

View file

@ -207,6 +207,14 @@ dist/
Embed text from a remote URL or a local file. To display the path or URL on the code block, see the [show source or path shortcode](#show-source-or-path).
The shortcode accepts three parameters:
- `src`: The source URL or file path (required)
- `start`: First line to display (optional, starts at 1)
- `end`: The ending line number (optional, defaults to 0, meaning the last line)
{{ admonition(type="info", text="`start` and `end` are inclusive. `start=3, end=3` will display only the third line.") }}
**Important**:
- **Remote VS local files**: If `src` starts with "http", it will be treated as a remote file. Otherwise, it assumes a local file path.
@ -229,6 +237,12 @@ Displaying text from a local file:
{{/* remote_text(src="path/to/file.txt") */}}
```
Display lines 3 to 7 (both inclusive) of a local file:
```
{{/* remote_text(src="path/to/file.txt", start=3, end=7) */}}
```
### Admonitions
Bring attention to information with these admonition shortcodes. They come in five `type`s: `note`, `tip`, `info`, `warning`, and `danger`.