From ece249bca639115a0937b4eb979e88ce8664c9e8 Mon Sep 17 00:00:00 2001 From: eric zubriski Date: Wed, 12 Jun 2019 21:33:56 -0700 Subject: [PATCH 1/3] Adding section for code snippets. --- book-example/src/format/mdbook.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/book-example/src/format/mdbook.md b/book-example/src/format/mdbook.md index 4c3cac0515..d6b020efb1 100644 --- a/book-example/src/format/mdbook.md +++ b/book-example/src/format/mdbook.md @@ -25,6 +25,7 @@ Will render as # } ``` + ## Including files With the following syntax, you can include files into your book: @@ -53,6 +54,21 @@ the file are omitted. The third command includes all lines from line 2, i.e. the first line is omitted. The last command includes the excerpt of `file.rs` consisting of lines 2 to 10. +## Including files as code snippets + +mdBook interpolates file contents as markdown unless the include command is +part of a code block. + +Wrap the include statement with ```` ``` ```` to display the +contents without interpolating them. + +```` +``` +\{{#include example.rs}} +``` +```` + + ## Inserting runnable Rust files With the following syntax, you can insert runnable Rust files into your book: From c527c97f10b4a036884c76900358191d18700910 Mon Sep 17 00:00:00 2001 From: eric zubriski Date: Wed, 12 Jun 2019 22:14:44 -0700 Subject: [PATCH 2/3] Reformatting sections. --- book-example/src/format/mdbook.md | 32 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/book-example/src/format/mdbook.md b/book-example/src/format/mdbook.md index d6b020efb1..49da47753d 100644 --- a/book-example/src/format/mdbook.md +++ b/book-example/src/format/mdbook.md @@ -36,10 +36,20 @@ With the following syntax, you can include files into your book: The path to the file has to be relative from the current source file. -Usually, this command is used for including code snippets and examples. In this -case, oftens one would include a specific part of the file e.g. which only -contains the relevant lines for the example. We support four different modes of -partial includes: +mdBook will interpret included files as markdown. Since the include command +is usually used for inserting code snippets and examples, you will often +wrap the command with ```` ``` ```` to display the file contents without +interpretting them. + +````hbs +``` +\{{#include file.rs}} +``` +```` + +## Including portions of a file +Often you only need a specific part of the file e.g. relevant lines for an +example. We support four different modes of partial includes: ```hbs \{{#include file.rs:2}} @@ -54,20 +64,6 @@ the file are omitted. The third command includes all lines from line 2, i.e. the first line is omitted. The last command includes the excerpt of `file.rs` consisting of lines 2 to 10. -## Including files as code snippets - -mdBook interpolates file contents as markdown unless the include command is -part of a code block. - -Wrap the include statement with ```` ``` ```` to display the -contents without interpolating them. - -```` -``` -\{{#include example.rs}} -``` -```` - ## Inserting runnable Rust files From 0e6652870231fb0ca4cb115a1ddfe9119c726f5a Mon Sep 17 00:00:00 2001 From: Eric Zubriski Date: Wed, 12 Jun 2019 22:33:18 -0700 Subject: [PATCH 3/3] Update mdbook.md --- book-example/src/format/mdbook.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/book-example/src/format/mdbook.md b/book-example/src/format/mdbook.md index 49da47753d..bbac372347 100644 --- a/book-example/src/format/mdbook.md +++ b/book-example/src/format/mdbook.md @@ -25,7 +25,6 @@ Will render as # } ``` - ## Including files With the following syntax, you can include files into your book: @@ -64,7 +63,6 @@ the file are omitted. The third command includes all lines from line 2, i.e. the first line is omitted. The last command includes the excerpt of `file.rs` consisting of lines 2 to 10. - ## Inserting runnable Rust files With the following syntax, you can insert runnable Rust files into your book: