Skip to content

Commit bee5711

Browse files
committed
Add {{#shiftinclude}} to L/R shift on include
Syntax is the same as {{#include}} except with a shift value and colon before the remaining arguments, e.g. {{#include -2:somefile.rs:myanchor}} A positive value for the shift prepends spaces to each line. A negative value for the shift removes chars from the beginning of each line (including non-whitespace chars, although this will emit an error log). Possibly helpful/relevant for: - rust-lang#1564: #include with indented - rust-lang#1601: option to remove indentation of included file snippets
1 parent 5a35144 commit bee5711

File tree

7 files changed

+1115
-537
lines changed

7 files changed

+1115
-537
lines changed

guide/src/format/mdbook.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ This is the full file.
211211

212212
Lines containing anchor patterns inside the included anchor are ignored.
213213

214+
## Including a file but changing its indentation
215+
216+
Sometimes it is useful to include a file or part of a file but with the indentation shifted,
217+
using the following syntax:
218+
219+
```hbs
220+
\{{#shiftinclude -2:file.rs}}
221+
```
222+
223+
A positive number for the shift will prepend spaces to all lines; a negative number will remove
224+
the corresponding number of characters from the beginning of each line.
225+
214226
## Including a file but initially hiding all except specified lines
215227

216228
The `rustdoc_include` helper is for including code from external Rust files that contain complete

0 commit comments

Comments
 (0)