File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Beautiful chapter
2
+
3
+ Here is a nice included snippet :
4
+
5
+ ``` c
6
+ {{ included.c }}
7
+ ```
8
+
9
+ ----
10
+
11
+ An exercise using includes
12
+
13
+ ```c
14
+ {{ included.c }}
15
+
16
+ Remove this extra code at the end
17
+ ```
18
+
19
+ ``` c
20
+ {{ included.c }}
21
+ ```
22
+
23
+ ```c
24
+ {{ included.c }}
25
+
26
+ This validation code is wrong but who cares ?
27
+ ```
28
+
29
+ ----
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ int main (int argc , char * argv []) {
4
+ printf ("All is well\n" );
5
+
6
+ return 0 ;
7
+ }
Original file line number Diff line number Diff line change
1
+ var fs = require ( 'fs' ) ;
2
+ var path = require ( 'path' ) ;
3
+ var assert = require ( 'assert' ) ;
4
+
5
+ var page = require ( '../' ) . parse . page ;
6
+
7
+ var FIXTURES_DIR = path . join ( __dirname , './fixtures/' ) ;
8
+
9
+ function loadPage ( name , options ) {
10
+ var CONTENT = fs . readFileSync ( FIXTURES_DIR + name + '.md' , 'utf8' ) ;
11
+ return page ( CONTENT , options ) ;
12
+ }
13
+
14
+
15
+ describe ( 'Code includes' , function ( ) {
16
+
17
+ var LEXED = loadPage ( 'INCLUDES' , {
18
+ 'dir' : FIXTURES_DIR ,
19
+ } ) ;
20
+
21
+ var INCLUDED_C = fs . readFileSync ( path . join ( FIXTURES_DIR , 'included.c' ) , 'utf8' ) ;
22
+
23
+ it ( 'should work for snippets' , function ( ) {
24
+ assert . equal ( LEXED [ 0 ] . type , 'normal' ) ;
25
+ // Has replaced include
26
+ assert . equal (
27
+ LEXED [ 0 ] . content . indexOf ( '{{ included.c }}' ) ,
28
+ - 1
29
+ ) ;
30
+ } ) ;
31
+
32
+ it ( 'should work for exercises' , function ( ) {
33
+ assert . equal ( LEXED [ 1 ] . type , 'exercise' ) ;
34
+
35
+ // Solution is trimmed version of source
36
+ assert . equal ( LEXED [ 1 ] . code . solution , INCLUDED_C . trim ( ) ) ;
37
+ } ) ;
38
+ } ) ;
You can’t perform that action at this time.
0 commit comments