rustyphoenixlecture 1.3.0

This project aims to provide a simple a powerfull lecture compilation to generate html web sites
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

use std::fs;
use std::path::PathBuf;

use crate::phighlighter::{
	PFileParser, PHighlighter, PHighlighterManager, PLocation
};
use crate::pcontent::{
	PContentDetail,
	PContentParagraph,
	PLabeler,
	PContent,
	PContentParser,
	PContentReference,
	PContentUrl,
	PContentFootnote,
	PContentTitle,
	PContentText,
	PMediaType,
	PContentEnvironment,
	PContentFormula,
	PItemType, PContentItem,
	PContentCell, PContentRow, PContentTable,
	PContentEnvList,
	PContentType,
	PVecContent
};

use crate::ptimetable::create_content_timetable;

use crate::ptimetable::load_vec_speaker;

use crate::plectureparser::{
	pressourcefile::PRessourceFile,
	pressourcearchive::PRessourceArchive,
	plecturedata::PLectureData,
	penvironmentmanager::PEnvironmentManager
};

///Get tje extension of a file
/// # Parameters
/// - `media_url` : file we want to get the extension
/// # Returns
/// Corresponding extension, or empty string if there is no extension
fn get_file_extension(media_url: &String) -> String{
	let media_file = PathBuf::from(media_url);
	//If the media file has an extension, we can check
	match media_file.extension() {
		Some(ext) => match ext.to_str() {
			Some(s) => String::from(s),
			None => String::from("")
		},
		None => String::from("")
	}
}

///Make the beginning of a lecture comment
/// # Parameters
/// - `begin_comment` : beginning of a classic comment of the given language
/// # Returns
/// Corresponding lecture comment for this language, or empty string if the given begin_comment is empty
fn make_lecture_comment(begin_comment: &String) -> String{
	if begin_comment.is_empty() {
		return String::from("");
	}
	return String::from(format!("{}{{", begin_comment));
}

///Parser of a lecture file
pub struct PLectureParser{
	///Output path where to generate the lecure website
	p_output_path: PathBuf,
	///Manager of all the highlighting of the lecture
	p_highligher_manager: PHighlighterManager,
	///Manager of all the environement of the lecture
	p_environement_manager: PEnvironmentManager,
	///Vector of environment which could be highlighted by the PHighlighterManager
	p_vec_highlighter: Vec<String>,
}


impl PLectureParser{
	///Constructor of a PLectureParser
	/// # Parameters
	/// - `output_path` : output path where to sate the website
	/// - `vec_config_directory` : vector of directories where to get all configuration of all PHighlighter to be used
	/// - `vec_env_directory` : vector of directories where to get all configuration of all environment to be used
	pub fn new(output_path: &PathBuf, vec_config_directory: &Vec<PathBuf>, vec_env_directory: &Vec<PathBuf>) -> Self{
		let mut other = PLectureParser {
			p_output_path: output_path.clone(),
			p_highligher_manager: PHighlighterManager::new(vec_config_directory),
			p_environement_manager: PEnvironmentManager::new(vec_env_directory),
			p_vec_highlighter: vec![],
		};
		other.p_vec_highlighter = other.p_highligher_manager.get_vec_highlighter_name().clone();
		other.p_environement_manager.write_css(&output_path.join(&PathBuf::from("book/environment.css")));
		return other;
	}
	///Get the output path of the lecture
	/// # Returns
	/// Output path of the lecture
	pub fn get_output_path(&self) -> &PathBuf{
		&self.p_output_path
	}
	///Parse the given file iterator
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True on success, false otherwise
	pub fn parse(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		//let's parse the entire file
		while !data.get_file_iter().is_end_of_file() {
			if self.parse_content(content, data) {}
			else {	//We have to increment the current char
				data.increment_current_char();
			}
		}
		data.play_text(content);
		return true;
	}
	///Parse the given file iterator
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True on success, false otherwise
	pub fn parse_content(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		//let's parse the entire file
		if self.parse_section_title(content, data, &String::from("##### "), 5) {}
		else if self.parse_section_title(content, data, &String::from("#### "), 4) {}
		else if self.parse_section_title(content, data, &String::from("### "), 3) {}
		else if self.parse_section_title(content, data, &String::from("## "), 2) {}
		else if self.parse_section_title(content, data, &String::from("# "), 1) {}
		else if self.parse_inline_formula(content, data) {}
		else if self.parse_label(content, data) {}
		else if self.parse_archive(content, data) {}
		else if self.parse_speaker(content, data) {}
		else if self.parse_timetable(content, data) {}
		else if self.parse_envlist(content, data) {}
		else if self.parse_media_highlight(content, data) {}
		else if self.parse_bold(content, data) {}
		else if self.parse_italic(content, data) {}
		else if self.parse_environment(content, data) {}
		else if self.parse_code_snipet(content, data) {}
		else if self.parse_comment(content, data) {}
		else if self.parse_auto_url(content, data, &String::from("https://")) {}
		else if self.parse_auto_url(content, data, &String::from("http://")) {}
		else if self.parse_url(content, data) {}
		else if self.parse_reference(content, data) {}
		else if self.parse_item_list(content, data) {}
		else if self.parse_table(content, data) {}
		else if self.parse_environement_example(content, data) {}
		else if self.parse_parser_example(content, data) {}
		else{
			match self.p_highligher_manager.get_highlighter_by_name(&String::from("lecture_keyword")) {
				Some(highligher) => {
					let highligh_result: String = highligher.highlight_iter(data.get_file_iter());
					//We just remember the text and we will flush it at some point
					data.add_text(content, &highligh_result);
					return true;
				},
				None => {}
			}
			return false;
		}
		return true;
	}
	///Parse a section title
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// - `section_token` : token which defined the section
	/// - `section_level` : level of the section (1: part, 2: chapter, 3: section, 4: subsection, etc)
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_section_title(&self, content: &mut PVecContent, data: &mut PLectureData, section_token: &String, section_level: usize) -> bool{
		let current_indentation: Option<usize> = data.get_file_iter().get_indentation_level().clone();
		// If there is no indentation, this is not a title because the # is in the middle of a paragraph
		if current_indentation == None {
			return false;
		}
		if !data.get_file_iter().is_match(section_token) {
			return false;
		}
		data.play_text(content);
		let mut section: PContentTitle = PContentTitle::new(section_level, data.is_numbered_title_enable(), &data.get_file_iter().get_location());
		//Now, we have to parse the title itself
		self.parse_content_sequence(&mut section.get_title_mut(), data, &String::from(""), &String::from("\n"), false);
		let id = data.get_current_id();
		data.add_child(content, &PContentType::Title(PLabeler::new(id, &section)));
		return true;
	}
	
	///Parse an inline formula
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_inline_formula(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("$")) {
			return false;
		}
		if data.get_file_iter().is_match(&String::from("{")) {
			data.add_text(content, &String::from("${"));
			return false;
		}
		data.play_text(content);
		let location: PLocation = data.get_file_iter().get_location().clone();
		let formula: String = data.get_file_iter().get_until(&String::from("$"));
		let trim_formula: String = String::from(formula.trim());
		if !trim_formula.is_empty() {
			let id = data.get_current_id();
			data.add_child(content, &PContentType::Formula(PLabeler::new(id, &PContentFormula::new(&String::from(format!("${}$", trim_formula)), true, &location))));
		}else{
			//If the formula is empty, it should be a single $ (where $$ -> $)
			data.add_text(content, &String::from("$"));
		}
		return true;
	}
	///Parse a label (some #label)
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_label(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("#")) {
			return false;
		}
		let label: String = data.get_file_iter().get_str_of(&String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"));
		if !data.add_label(content, &label) {
			panic!("PLectureParser::add_label : Error at {}\n\tCannot create label '{}'", data.get_parser_location(), label);
		}
		// data.play_text(content);
		return true;
	}
	///Parse a reference (some @label)
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_reference(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		//First we don't want to be in some characters
		if data.get_file_iter().is_current_char_in_charset(&String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")) {
			return false;
		}
		//Now, we can heck if the next char is a @
		if !data.get_file_iter().is_match(&String::from("@")) {
			return false;
		}
		let location = data.get_file_iter().get_location().clone();	//We get the location at the @ char
		let reference: String = data.get_file_iter().get_str_of(&String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"));
		if reference.is_empty() {
			panic!("PLectureParser::parse_reference : Error at {}\n\tReference cannot be empty", data.get_file_iter().get_location());
		}
		data.play_text(content);
		let id = data.get_current_id();
		if data.get_file_iter().is_match(&String::from("::")) {	//If we have a name space, this is a reference to an other lecture
			let other_lecture_reference: String = data.get_file_iter().get_str_of(&String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"));
			data.add_child(content, &PContentType::Reference(PLabeler::new(id, &PContentReference::from_other_lecture(&other_lecture_reference, &reference))));
			data.add_lecture_reference(&reference, &other_lecture_reference, &location);
		}else{
			data.add_child(content, &PContentType::Reference(PLabeler::new(id, &PContentReference::new(&reference))));
			data.add_reference(&reference, &location);
		}
		return true;
	}
	///Parse an item list
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_item_list(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		let current_indentation: Option<usize> = data.get_file_iter().get_indentation_level().clone();
		match current_indentation {
			Some(indentation_level) => {
				if !data.get_file_iter().is_match(&String::from("- ")) {
					return false;
				}
				//TODO : create a add the PContentItem at the right place
				let id = data.get_current_id();
				// println!("PLectureParser::parse_item_list : Add item at indentation {}", indentation_level);
				data.add_child(content, &PContentType::ListItem(PLabeler::new(id, &PContentItem::new(indentation_level, &PItemType::Item))));
				return true;
			},
			None => false
		}
	}
	///Parse an item list
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_table(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("|")){
			return false;
		}
		//We found a table
		let mut add_new_line: bool = true;
		let table_location: PLocation = data.get_file_iter().get_location().clone();
		let mut table = PContentTable::new();
		let table_id = data.get_current_id();
		//Let's parse the entire table
		while !data.get_file_iter().is_end_of_file() {
			if add_new_line {
				table.get_vec_row_mut().push(PContentRow::new());
				add_new_line = false;
			}
			//We parse the current cell until a |
			let mut current_cell = PContentCell::new();
			self.parse_content_sequence(&mut current_cell.get_content_mut(), data, &String::from(""), &String::from("|"), true);
			//Let's save the current cell in the last row of the table
			table.add_cell_in_last_row(&current_cell);
			//if we get \n\n this is the end of the table
			if data.get_file_iter().is_match(&String::from("\n\n")){
				break;
			}
			//if we get \n| this is the end of the row and a new row begins
			if data.get_file_iter().is_match(&String::from("\n|")){
				add_new_line = true;
			}
		};
		//Now we have to check if the table is coherent
		if !table.check_table(){
			panic!("PLectureParser::parse_table : Error at {}\n\tThe number of columns are not coherent!", table_location)
		}
		content.add_child(&PContentType::Table(PLabeler::new(table_id, &table)));
		return true;
	}
	
	///Parse an archive
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_archive(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("![archive](")) {
			return false;
		}
		data.play_text(content);
		//Let's get the name of the directory to archive
		let directory_name = PathBuf::from(data.get_file_iter().get_until(&String::from(")")));
		
		let archive_ressource = PRessourceArchive::new(&directory_name, data.get_file_iter().get_location(), &self.p_output_path);
		//We can already create the link to the archive and hope we wil be able to make it later
		let mut content_url = PContentUrl::new();
		let url_id = data.get_current_id();
		content_url.get_text_mut().add_child(&PContentType::Text(PLabeler::new(data.get_current_id(), &PContentText::new(&archive_ressource.get_archive_file_name()))));
		content_url.set_url(&String::from(archive_ressource.get_relative_output_archive_file().to_str().unwrap()));
		data.add_child(content, &PContentType::Url(PLabeler::new(url_id, &content_url)));
		data.add_archive(&archive_ressource);
		return true;
	}
	///Parse a speaker configuration
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_speaker(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("![speaker](")) {
			return false;
		}
		data.play_text(content);
		let location = data.get_parser_location().clone();
		
		//Let's get the name of the directory to archive
		let config_name = PathBuf::from(data.get_file_iter().get_until(&String::from(")")));
		let input_speaker_config: PathBuf = location.get_filename().parent().unwrap().join(PathBuf::from(config_name));
		let vec_speaker = match load_vec_speaker(&PathBuf::from(input_speaker_config)) {
			Ok(value) => value,
			Err(err) => panic!("PLectureParser::parse_speaker : Error at {}\n\tError {}", location, err)
		};
		
		let mut full_speaker_part = PContentTitle::new(1, true, &location);
		full_speaker_part.get_title_mut().add_child(&PContentType::from_text(data.get_current_id(), &String::from("Speakers")));
		content.add_child(&PContentType::Title(PLabeler::new(data.get_current_id(), &full_speaker_part)));
		data.add_label(content, &String::from("sec_full_speakers"));
		
		data.add_text(content, &String::from("Here you can find all speakers."));
		
		for speaker in vec_speaker.speaker.iter() {
			let mut speaker_part = PContentTitle::new(2, true, &location);
			speaker_part.get_title_mut().add_child(&PContentType::from_text(data.get_current_id(), &speaker.name));
			content.add_child(&PContentType::Title(PLabeler::new(data.get_current_id(), &speaker_part)));
			data.add_label(content, &speaker.label);
			
			content.add_child(&PContentType::from_textbf(data.get_id_mut(), &String::from("Speaker : ")));
			let mut speaker_name = String::from("");
			if !speaker.title.is_empty() {
				speaker_name += &format!("{} ", speaker.title);
			}
			speaker_name += &speaker.name;
			content.add_child(&PContentType::from_text(data.get_current_id(), &speaker_name));
			content.add_child(&PContentType::NewLine);
			
			content.add_child(&PContentType::from_textbf(data.get_id_mut(), &String::from("Affiliation : ")));
			content.add_child(&PContentType::from_text(data.get_current_id(), &speaker.affiliation));
			content.add_child(&PContentType::NewLine);
			
			content.add_child(&PContentType::from_textbf(data.get_id_mut(), &String::from("Function : ")));
			content.add_child(&PContentType::from_text(data.get_current_id(), &speaker.function));
			content.add_child(&PContentType::NewLine);
			
			let trim_description = speaker.description.trim();
			if !trim_description.is_empty() {
				let mut bio_title = PContentTitle::new(3, false, &location);
				bio_title.get_title_mut().add_child(&PContentType::from_text(data.get_current_id(), &&String::from("Bio")));
				content.add_child(&PContentType::Title(PLabeler::new(data.get_current_id(), &bio_title)));
			
				let parser: PFileParser = PFileParser::from_content(&String::from(format!("{}\n", trim_description)));
				let mut lecture_data = PLectureData::new(data.get_current_id(), &parser);
				self.parse(content, &mut lecture_data);
				//Now we have to update the id of the source_data to avoid overlap
				data.set_current_id(lecture_data.get_current_id());
			}
		}
		return true;
	}
	///Parse a speaker configuration
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_timetable(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("![timetable](")) {
			return false;
		}
		data.play_text(content);
		let location = data.get_parser_location().clone();
		//Let's get the name of the directory to archive
		let config_name = PathBuf::from(data.get_file_iter().get_until(&String::from(")")));
		let input_timetable_config: PathBuf = location.get_filename().parent().unwrap().join(PathBuf::from(config_name));
		create_content_timetable(content, data, self, &input_timetable_config);
		return true;
	}
	///Parse an environment list
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_envlist(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("![list_env](")) {
			return false;
		}
		data.play_text(content);
		let environment_name = data.get_file_iter().get_until(&String::from(")"));
		//We have to add it in the PSearchEnvironment
		let current_location = data.get_parser_location().clone();
		if !self.p_environement_manager.get_map_environment().contains_key(&environment_name) {
			panic!("PLectureParser::parse_envlist : Error at {}\n\tNo environement named '{}'\n\tPossible values are {:?}", current_location, environment_name, self.p_environement_manager.get_vec_env_name());
		}
		let env_list = PContentEnvList::new(&environment_name);
		let id = data.get_current_id();
		data.get_search_environment_mut().add_env(&environment_name, content.get_vec_child().len(), &current_location);
		//Then, we add the PContentEnvList in the main content
		data.add_child(content, &PContentType::EnvList(PLabeler::new(id, &env_list)));
		return true;
	}
	
	///Parse a environment example
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_environement_example(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("__all_environment_example__")){
			return false;
		}
		//Then, we can loop on all environment and make some examples :
		let example_text = String::from("Patricia mon petit, je ne voudrais pas te paraître vieux jeu et encore moins grossier.\nL'homme de la pampa parfois rude reste toujours courtoit mais l'honneteté m'oblige à te le dire :\nton Antoine commence à me les briser menu !");
		content.add_child(&PContentType::NewLine);
		for env_name in self.p_environement_manager.get_vec_env_name().iter(){
			let env = self.p_environement_manager.get_map_environment().get(env_name).unwrap();
			let mut full_text_env = PContent::new();
			let full_text_env_content = full_text_env.get_content_mut();
			full_text_env_content.add_child(&PContentType::NewLine);
			full_text_env_content.add_child(&PContentType::from_text(data.get_current_id(), &String::from("Example of the environment ")));
			
			full_text_env_content.add_child(&PContentType::from_textbf(data.get_id_mut(), &env.name));
			if env.balise == String::from("pre") {
				//Here we add a warning because the dynamic word wrap is not supported
				full_text_env_content.add_child(&PContentType::from_text(data.get_current_id(), &String::from(" (")));
				full_text_env_content.add_child(&PContentType::from_text_style(data.get_id_mut(), &String::from("text_warning"), &String::from("dynamic word wrap is not supported !")));
				full_text_env_content.add_child(&PContentType::from_text(data.get_current_id(), &String::from(")")));
			}
			full_text_env_content.add_child(&PContentType::from_text(data.get_current_id(), &String::from(" :")));
			
			content.add_child(&PContentType::Content(PLabeler::new(data.get_current_id(), &full_text_env)));
			
			//The text example to put in the environment :
			let mut environment: PContentEnvironment = PContentEnvironment::new(&env.name, &env.balise, &env.image, &PLocation::new(&PathBuf::from("generated file"), 0, 0));
			let environment_content = environment.get_content_mut();
			environment_content.add_child(&&PContentType::from_text(data.get_current_id(), &example_text));
			content.add_child(&PContentType::Environment(PLabeler::new(data.get_current_id(), &environment)));
		}
		return true;
	}
	///Parse a parser example
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_parser_example(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("__all_parser_example__")){
			return false;
		}
		let mut vec_highlighter_name = self.p_highligher_manager.get_vec_highlighter_name();
		
		if vec_highlighter_name.len() == 0 {	//If there is no highlighter, we do nothing
			data.add_text(content, &String::from("Sorry, but there is no parser available in this configuration."));
			return true;
		}
		//Let's sort the values, otherwise people will go crasy in the documentation
		vec_highlighter_name.sort();
		//Let's add a dedicated part
		let section_level: usize = 2;	//Let's use a chapter for now
		let mut example_title = PContentTitle::new(section_level, true, data.get_parser_location());
		example_title.get_title_mut().add_child(&&PContentType::from_text(data.get_current_id(), &String::from("All Parsers of lecture")));
		content.add_child(&PContentType::Title(PLabeler::new(data.get_current_id(), &example_title)));
		assert!(data.add_label(content, &String::from("secAllParserExample")));
		data.add_text(content, &String::from("This section contains all examples from all parsers available in this lecture."));
		
		//Let's iterate on all parser
		for parser_name in vec_highlighter_name.iter(){
			let mut parser_title = PContentTitle::new(section_level + 1, true, data.get_parser_location());
			parser_title.get_title_mut().add_child(&PContentType::from_text(data.get_current_id(), &String::from(format!("Parser : {}", parser_name))));
			
			content.add_child(&PContentType::Title(PLabeler::new(data.get_current_id(), &parser_title)));
			assert!(data.add_label(content, &String::from(format!("secAllParserExample{}", parser_name))));
			
			data.add_text(content, &String::from("This is an example of the '"));
			let text_bold = PContentType::from_text_style(data.get_id_mut(), &String::from("program_language"), &String::from(format!("{}", parser_name)));
			data.add_child(content, &text_bold);
			data.add_text(content, &String::from("' parser available in this lecture."));
			
			match self.p_highligher_manager.get_highlighter_by_name(parser_name) {
				Some(highlighter) => {
					let highlighted_code = highlighter.highlight_example();
					let id = data.get_current_id();
					data.add_child(content, &PContentType::Parser(PLabeler::new(id, &PContentParser::new(&highlighted_code, highlighter.get_language().get_is_line_number(), true))));
				},
				None => {}	//Impossible
			};
		}
		return true;
	}
	///Parse a work in progress environment
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_environment(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool {
		if !data.get_file_iter().is_match(&String::from("```")) {
			return false;
		}
		data.play_text(content);
		//We get an environment, and we have to determine its type
		let environment_name: String = data.get_file_iter().get_str_of(&String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"));
		if environment_name.is_empty() {
			panic!("PLectureParser::parse_environment : Error at {}\n\tMissing environment name. Possible values are :\n\t- footnote, formula, detail\n\t- environment : {:?}\n\t- parser : {:?}", data.get_parser_location(), self.p_environement_manager.get_vec_env_name(), self.p_highligher_manager.get_vec_highlighter_name());
		}
		//no, let's check if we know the environment
		if environment_name == String::from("footnote") {
			let mut footnote: PContentFootnote = PContentFootnote::new();
			let mut footnote_content = footnote.get_content_mut();
			
			self.parse_content_sequence(&mut footnote_content, data, &String::from(""), &String::from("```\n"), false);
			let id = data.get_current_id();
			data.add_child(content, &PContentType::FootNote(PLabeler::new(id, &footnote)));
			return true;
		}else if environment_name == String::from("formula") {
			let location: PLocation = data.get_file_iter().get_location().clone();
			let text_formula = data.get_file_iter().get_until(&String::from("```\n"));
			let id = data.get_current_id();
			data.add_child(content, &PContentType::Formula(PLabeler::new(id, &PContentFormula::new(&text_formula, false, &location))));
			return true;
		}else if environment_name == String::from("detail") {
			let mut detail = PContentDetail::new();
			self.parse_content_sequence(detail.get_content_mut(), data, &String::from(""), &String::from("```\n"), true);
			let id = data.get_current_id();
			data.add_child(content, &PContentType::Detail(PLabeler::new(id, &detail)));
			return true;
		}else{
			//Let's check if it is one of the highlighted environments
			if self.highlight_plain_language(content, data, &environment_name) {
				return true;
			}else{
				match self.p_environement_manager.get_map_environment().get(&environment_name) {
					Some(env) => {
						let location: PLocation = data.get_parser_location().clone();
						let mut environment: PContentEnvironment = PContentEnvironment::new(&env.name, &env.balise, &env.image, &location);
						let mut environment_content = environment.get_content_mut();
						self.parse_content_sequence(&mut environment_content, data, &String::from(""), &String::from("```\n"), env.is_paragraph_allowed);
						let id = data.get_current_id();
						data.add_child(content, &PContentType::Environment(PLabeler::new(id, &environment)));
						return true;
					},
					None => {
						//If there is no environment name, we should add a default terminal environment
						panic!("PLectureParser::parse_environment : Error at {}\n\tMissing defined environment after ```\n\tPossible values = {:?}", data.get_parser_location(), self.p_vec_highlighter);
					}
				}
			}
		}
	}
	///Parse the `![media](file.ext)` markdown
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_media_highlight(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("![")) {
			return false;
		}
		data.play_text(content);
		//Let's get the content of the [ ]
		let hook_content: String = data.get_file_iter().get_until(&String::from("]"));
		if !data.get_file_iter().is_match(&String::from("(")) {
			//If we don't get he ( ) maybe we could create an other PContentType, but I don"t have it yet
			return false;
		}
		let is_figure: bool = hook_content == String::from("figure");
		let media_width: usize = match hook_content.parse() {
			Ok(value) => value,
			Err(_) => 0
		};
		let media_url: String = data.get_file_iter().get_until(&String::from(")"));
		let media_file = PathBuf::from(&media_url);
		let media_extension: String = get_file_extension(&media_url);
		//If the url is a http / https url
		if media_url.starts_with("https://") || media_url.starts_with("http://") {
			//We determine the extention to link to the ressource
			//If we get a known extension, it is OK, otherwise we just create an url
			let id = data.get_current_id();
			match media_extension.as_str() {
				"mp4" => data.add_child(content, &PContentType::from_media(id, &media_file, media_width, &PMediaType::Video, true)),
				"png" => data.add_child(content, &PContentType::from_media(id, &media_file, media_width, &PMediaType::Image, is_figure)),
				"jpg" => data.add_child(content, &PContentType::from_media(id, &media_file, media_width, &PMediaType::Image, is_figure)),
				"svg" => data.add_child(content, &PContentType::from_media(id, &media_file, media_width, &PMediaType::Image, is_figure)),
				_ => panic!("PLectureParser::parse_media_highlight : Error at {}\n\tUnknown extension '{}' with media_url = '{}'", data.get_parser_location(), media_extension, media_url)
			};
			return true;
		}
		//Here, we will have to copy the files into the ressource directory of the output website
		// - Single original file for mp4 of png
		// - Modified file for cpp, rust, etc because of the strip of the lecture embeded comment
		match media_extension.as_str() {
			"mp4" => self.copy_media_file(content, data, &media_file, media_width, &PMediaType::Video, true),
			"png" => self.copy_media_file(content, data, &media_file, media_width, &PMediaType::Image, is_figure),
			"jpg" => self.copy_media_file(content, data, &media_file, media_width, &PMediaType::Image, is_figure),
			"svg" => self.copy_media_file(content, data, &media_file, media_width, &PMediaType::Image, is_figure),
			//Then, we have languages (C++, Rust, Fortran, Python, CMake, Toml, Markdown, etc)
			_ => {
				//Here we have to manage a generic file call, or maybe an error just to start
				if !self.highlight_file_language(content, data, &media_file){
					//If the file extension/language is not known, maybe we just want verbatim text
					panic!("PLectureParser::parse_media_highlight : error at {}\n\tcannot highlight file {:?}", data.get_parser_location(), media_file);
				}
			}
		};
		return true;
	}
	
	///Parse an automatic url
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// - `url_start` : how the url is supposed to start
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_auto_url(&self, content: &mut PVecContent, data: &mut PLectureData, url_start: &String) -> bool{
		if !data.get_file_iter().is_match(url_start) {
			return false;
		}
		data.play_text(content);
		let mut url = PContentUrl::new();
		let text_url: String = String::from(format!("{}{}", url_start,
			data.get_file_iter().get_str_of(&String::from(".-_/?%&@:#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"))));
		url.set_url(&text_url);
		url.get_text_mut().add_child(&&PContentType::from_text(data.get_current_id(), &text_url));
		let id = data.get_current_id();
		data.add_child(content, &PContentType::Url(PLabeler::new(id, &url)));
		return true;
	}
	///Parse a url
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_url(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("[")) {
			return false;
		}
		//TODO : could be also a CheckBox but I don't know what to do with it right now
		data.play_text(content);
		let mut url = PContentUrl::new();
		let mut url_text_content = url.get_text_mut();
		self.parse_content_sequence(&mut url_text_content, data, &String::from(""), &String::from("]"), false);
		//Then, we want the link
		if !data.get_file_iter().is_match(&String::from("(")) {
			panic!("PLectureParser::parse_url : Error at {}\n\tmissing link of url, should be [text](https://some/url)", data.get_parser_location());
		}
		let url_link: String = data.get_file_iter().get_until(&String::from(")"));
		url.set_url(&url_link);
		let id = data.get_current_id();
		data.add_child(content, &PContentType::Url(PLabeler::new(id, &url)));
		return true;
	}
	
	///Parse bold in the lecture (**: no ambiguities with file names and underscores)
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_bold(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("**")) {
			return false;
		}
		data.play_text(content);
		let mut bold_content = PVecContent::new();
		self.parse_content_sequence(&mut bold_content, data, &String::from(""), &String::from("**"), false);
		let id = data.get_current_id();
		data.add_child(content, &PContentType::TextBf(PLabeler::new(id, &bold_content)));
		return true;
	}
	///Parse italic in the lecture (*: no ambiguities with file names and underscores)
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_italic(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("*")) {
			return false;
		}
		data.play_text(content);
		let mut italic_content = PVecContent::new();
		self.parse_content_sequence(&mut italic_content, data, &String::from(""), &String::from("*"), false);
		let id = data.get_current_id();
		data.add_child(content, &PContentType::TextIt(PLabeler::new(id, &italic_content)));
		return true;
	}
	///Parse code snipet in the lecture
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_code_snipet(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("`")) {
			return false;
		}
		data.play_text(content);
		let mut code_snipet_content = PVecContent::new();
		self.parse_content_sequence(&mut code_snipet_content, data, &String::from(""), &String::from("`"), false);
		let id = data.get_current_id();
		data.add_child(content, &PContentType::TextCode(PLabeler::new(id, &code_snipet_content)));
		return true;
	}
	///Parse a comment in the lecture
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// # Returns
	/// True if the corresponding section was parsed, false if not
	fn parse_comment(&self, content: &mut PVecContent, data: &mut PLectureData) -> bool{
		if !data.get_file_iter().is_match(&String::from("<!--")) {
			return false;
		}
		data.play_text(content);
		data.get_file_iter().get_until(&String::from("-->"));
		return true;
	}
	
	///Parse a sequence of content
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// - `begin_pattern` : pattern to start the sequence with (if it is not empty)
	/// - `end_pattern` : pattern to end the sequence with
	/// - `is_paragraph_allowed` : true if the paragraph are allowed in this sequence of PContent
	/// # Returns
	/// True if the corresponding content was parsed, false if not
	fn parse_content_sequence(&self, content: &mut PVecContent, data: &mut PLectureData, begin_pattern: &String, end_pattern: &String, is_paragraph_allowed: bool) -> bool{
		if !is_paragraph_allowed{
			data.disable_paragraph();
		}
		data.disable_numbered_title();
		if !begin_pattern.is_empty() {
			if !data.get_file_iter().is_match(begin_pattern) {
				return false;
			}
		}
		//let's parse the content until we found the end pattern
		while !data.get_file_iter().is_end_of_file() && !data.get_file_iter().is_match(end_pattern) {
			if self.parse_content(content, data) {}
			else {	//We have to increment the current char
				data.increment_current_char();
			}
		}
		data.play_text(content);
		if !is_paragraph_allowed{
			data.enable_paragraph();
		}
		data.enable_numbered_title();
		return true;
	}
	
	///Copy a file in the ressource direcotry of the generated website
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// - `media_file` : file to the media to be copied
	/// - `media_width` : width of the media in the html
	/// - `media_type` : type of the media
	/// - `is_figure` : true if the current media is a figure
	fn copy_media_file(&self, content: &mut PVecContent, data: &mut PLectureData, media_file: &PathBuf, media_width: usize, media_type: &PMediaType, is_figure: bool){
		// Let's get the absolute path of the input media_file
		let ressource_file = PRessourceFile::new(media_file, data.get_file_iter().get_location(), &self.p_output_path);
		ressource_file.copy_to_output_dir();
		//Then we can add it
		let id = data.get_current_id();
		data.add_child(content, &&PContentType::from_media(id, &ressource_file.get_relative_output_file(), media_width, media_type, is_figure));
	}
	///Perform the highlighting of a file from a given language
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// - `source_file` : source file to be highlighted
	/// # Returns
	/// True if the source file has been parsed correctly, false otherwise
	fn highlight_file_language(&self, content: &mut PVecContent, data: &mut PLectureData, source_file: &PathBuf) -> bool{
		//Here we fin the proper highlighter if there is one
		match self.p_highligher_manager.get_highlighter_by_file(source_file) {
			Some(highlighter) => {
				self.highlight_file_language_source(content, data, source_file, &highlighter)
			},
			None => {	//No highlighter
				false
			}	
		}
	}
	///Perform the highlighting of a full source file from a given language
	/// # Parameters
	/// - `content` : PVecContent result of the parsing
	/// - `data` : data of the parsing
	/// - `source_file` : source file to be highlighted
	/// - `highlighter` : corresponding PHighlighter to be used
	/// # Returns
	/// True if the source file has been parsed correctly, false otherwise
	fn highlight_file_language_source(&self, content: &mut PVecContent, data: &mut PLectureData, source_file: &PathBuf, highlighter: &PHighlighter) -> bool {
		//TODO : factorize the absolute file and output management because we need it twice for now
		let ressource_file = PRessourceFile::new(source_file, data.get_file_iter().get_location(), &self.p_output_path);
		ressource_file.create_dir_all();
		let output_file = ressource_file.get_absolute_output_file();
		//Here we split the file in several peaces :
		// - language without lecture embeded comment, integrated in lecture by self.highlight_plain_language
		// - full file language without lecture embeded comment
		//First we load the file :
		let parser: PFileParser = PFileParser::from_file(ressource_file.get_absolute_input_file());
		let mut source_data = PLectureData::new(data.get_current_id(), &parser);
		//Here we want to use the source_data to split the lecture into peaces (language only, lecture only, and full source file without lecture embeded comments)
		//We iterate until we get an embeded lecture comment, and then we call the highlighter, and we create a small perser just for the lecture comments
		//If the single comment does exist
		let lecture_single_line_comment: String = make_lecture_comment(highlighter.get_language().get_single_line_comment());
		let lecture_multi_line_comment_begin: String = make_lecture_comment(highlighter.get_language().get_multi_line_comment_begin());
		let lecture_multi_line_comment_end = highlighter.get_language().get_multi_line_comment_end();
		let mut full_source = String::from("");
		//Here the 'TEXT' is the source code, and the rest are the embeded lecture comments
		while !source_data.get_file_iter().is_end_of_file() {
			//If we get an embeded lecture single line comment
			if source_data.get_file_iter().is_match(&lecture_single_line_comment) {
				//We get to the end of the comment and we parse it as a lecture
				let lecture_comment = source_data.get_file_iter().get_until(&String::from("\n"));
				self.highlight_lecture_and_source(content, &mut source_data, &mut full_source, &lecture_comment, highlighter);
			}else if source_data.get_file_iter().is_match(&lecture_multi_line_comment_begin) {
				//We get to the end of the multiline comment and we parse it as a lecture
				let lecture_comment = source_data.get_file_iter().get_until(&lecture_multi_line_comment_end);
				self.highlight_lecture_and_source(content, &mut source_data, &mut full_source, &lecture_comment, highlighter);
			}else{
				source_data.increment_current_char();
			}
		}
		if !full_source.is_empty() {	//If there is a last block of code we display it
			self.highlight_lecture_and_source(content, &mut source_data, &mut full_source, &String::from(""), highlighter);
		}
		//Now we have to update the id of the data with source_data to avoid overlap
		data.set_current_id(source_data.get_current_id());
		//Let's create the source url
		let mut source_url = PContentUrl::new();
		source_url.get_text_mut().add_child(&PContentType::from_text(data.get_current_id(), &String::from(ressource_file.get_relative_output_file().file_name().unwrap().to_str().unwrap())));
		source_url.set_url(&ressource_file.get_relative_output_file().to_str().unwrap().to_string());
		
		//Finally we save the full source :
		if full_source.is_empty() {
			full_source = source_data.flush_text();
		}
		let id = data.get_current_id();
		content.add_child(&PContentType::Paragraph(PLabeler::new(id, &PContentParagraph::new())));
		data.add_text(content, &String::from("Full file "));
		let id = data.get_current_id();
		data.add_child(content, &PContentType::Url(PLabeler::new(id, &source_url)));
		let id = data.get_current_id();
		
		data.add_child(content, &PContentType::from_text(id, &String::from(" : ")));
		
		let highlighted_code = highlighter.highlight(&String::from(full_source.trim_start()));
		let id = data.get_current_id();
		data.add_child(content, &PContentType::Parser(PLabeler::new(id, &PContentParser::new(&highlighted_code, highlighter.get_language().get_is_line_number(), true))));
		match fs::write(&output_file, full_source) {
			Ok(_) => {},
			Err(err) => panic!("PLectureParser::highlight_file_language_source : cannot write source file {:?}\n\tError {}", output_file, err)
		};
		//TODO : finally we can create a link to the generated file
		let id = data.get_current_id();
		data.add_child(content, &PContentType::from_text(id, &String::from("File url : ")));
		let id = data.get_current_id();
		data.add_child(content, &PContentType::Url(PLabeler::new(id, &source_url)));
		return true;
	}
	
	///Parse the lecture comment and the source file
	/// # Parameters
	/// - `content` : PVecContent result of the global lecture parsing
	/// - `source_data` : local data of the parsed source
	/// - `full_source` : full source file without the lecture comment
	/// - `lecture_comment` : lecture comment to be parsed
	/// - `highlighter` : corresponding PHighlighter to be used
	fn highlight_lecture_and_source(&self, content: &mut PVecContent, source_data: &mut PLectureData, full_source: &mut String, lecture_comment: &String, highlighter: &PHighlighter){
		let source_code: String = source_data.flush_text();
		//Let's append the source into the full source
		*full_source += &source_code;
		let trim_code: String = String::from(source_code.trim_start_matches("\n"));
		if !trim_code.is_empty() {
			let highlighted_code = highlighter.highlight(&trim_code);
			//If we have some source to parse, we do it
			let id = source_data.get_current_id();
			source_data.add_child(content, &PContentType::Parser(PLabeler::new(id, &PContentParser::new(&highlighted_code, highlighter.get_language().get_is_line_number(), true))));
		}
		//Now we have to parse the lecture comment
		let trim_lecture_comment: String = String::from(lecture_comment.trim());
		if trim_lecture_comment.is_empty() {
			return;
		}
		let parser: PFileParser = PFileParser::from_content(&trim_lecture_comment);
		let mut lecture_data = PLectureData::new(source_data.get_current_id(), &parser);
		self.parse(content, &mut lecture_data);
		//Now we have to update the id of the source_data to avoid overlap
		source_data.set_current_id(lecture_data.get_current_id());
	}
	
	///Perform the highlighting of a plain language (without lecture embeded comment in it)
	/// # Parameters
	/// - `content` : PVecContent result of the global lecture parsing
	/// - `data` : data of the global lecture parsing
	/// - `source_code` : code to be highlighted
	/// - `language_name` : name of the language to be highlighted
	/// # Returns
	/// True if the highlighter was found, false otherwise
	fn highlight_plain_language(&self, content: &mut PVecContent, data: &mut PLectureData, language_name: &String) -> bool{
		match self.p_highligher_manager.get_highlighter_by_name(language_name) {
			Some(highlighter) => {
				let source_code: String = data.get_file_iter().get_until(&String::from("```"));
				
				let highlighted_code = highlighter.highlight(&String::from(source_code.trim_start()));
				let id = data.get_current_id();
				data.add_child(content, &PContentType::Parser(PLabeler::new(id, &PContentParser::new(&highlighted_code, highlighter.get_language().get_is_line_number(), false))));
				return true;
			},
			None => false
		}
	}
}


#[cfg(test)]
mod tests{
	use super::*;
	use crate::pcontent::{
		PAbstractContent, PLabelId, PStrBackend
	};
	///Test the make_lecture_comment
	#[test]
	fn test_make_begin_comment(){
		assert_eq!(make_lecture_comment(&String::from("")), String::from(""));
		assert_eq!(make_lecture_comment(&String::from("//")), String::from("//{"));
		assert_eq!(make_lecture_comment(&String::from("#")), String::from("#{"));
	}
	
	///Test the parsing of the lecture
	/// # Parameters
	/// - `lecture_parser` : PLectureParser to be used for this test
	/// - `input_content` : input markdown to be parsed
	/// - `expected_output` : expected text output from the parsed PVecContent::to_html with the PStrBackend
	fn test_lecture_parser_content(lecture_parser: &PLectureParser, input_content: &String, expected_output: &String){
		let mut parser: PFileParser = PFileParser::from_content(input_content);
		parser.set_filename(&PathBuf::from("tests/index.md").canonicalize().unwrap());
		let mut data = PLectureData::new(0, &parser);
		let mut vec_content = PVecContent::new();
		assert!(lecture_parser.parse(&mut vec_content, &mut data));
		
		let mut backend = PStrBackend::new();
		vec_content.to_html(&mut backend, &PLabelId::new(0));
		assert_eq!(backend.get_body(), expected_output);
	}
	
	///Test the PLectureParser
	#[test]
	fn test_lecture_parser(){
		let base_output_path = PathBuf::from("target/test_lecture_parser");
		fs::create_dir_all(&base_output_path).unwrap();
		//Let's define the lecture path
		let output_path = base_output_path.canonicalize().unwrap();
		//We have to create the book directory too
		fs::create_dir_all(&output_path.join("book")).unwrap();
		let vec_parser_dir: Vec<PathBuf> = vec![PathBuf::from("tests/parser")];
		let vec_environment_dir: Vec<PathBuf> = vec![PathBuf::from("tests/environment")];
		//Create the lecture which will remain const
		let lecture_parser = PLectureParser::new(&output_path, &vec_parser_dir, &vec_environment_dir);
		
		//Comment
		test_lecture_parser_content(&lecture_parser, &String::from("<!-- Some comment -->"), &String::from(""));
		//Test of title
		test_lecture_parser_content(&lecture_parser, &String::from("# Some title\n"), &String::from("<h1 id=\"1\">Some title</h1>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("## Some title\n"), &String::from("<h2 id=\"1\">Some title</h2>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("### Some title\n"), &String::from("<h3 id=\"1\">Some title</h3>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("#### Some title\n"), &String::from("<h4 id=\"1\">Some title</h4>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("##### Some title\n"), &String::from("<h5 id=\"1\">Some title</h5>\n"));
		//Test of text
		test_lecture_parser_content(&lecture_parser, &String::from("Some text\n"), &String::from("<p id=\"1\">Some text</p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("**Some bold**"), &String::from("<p id=\"2\"><b>Some bold</b></p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("*Some italic*"), &String::from("<p id=\"2\"><em>Some italic</em></p>\n"));
		
		//Test of url
		test_lecture_parser_content(&lecture_parser, &String::from("https://maqao.org"), &String::from("<p id=\"2\"><a id=\"1\" href=\"https://maqao.org\">https://maqao.org</a></p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("http://maqao.org"), &String::from("<p id=\"2\"><a id=\"1\" href=\"http://maqao.org\">http://maqao.org</a></p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("[some url](https://some.url.com/)"), &String::from("<p id=\"2\"><a id=\"1\" href=\"https://some.url.com/\">some url</a></p>\n"));
		
		//Test with automatic replace
		test_lecture_parser_content(&lecture_parser, &String::from("Some maqao usage\n"), &String::from("<p id=\"1\">Some <a class=\"program\" href=\"https://maqao.org/\">maqao</a> usage</p>\n"));
		//Test of code
		test_lecture_parser_content(&lecture_parser, &String::from("`Some code`\n"), &String::from("<p id=\"2\"><span class=\"code_inline\">Some code</span></p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("`${PREFIX_SHARE}`\n"), &String::from("<p id=\"2\"><span class=\"code_inline\">${PREFIX_SHARE}</span></p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("`$$`\n"), &String::from("<p id=\"2\"><span class=\"code_inline\">$</span></p>\n"));
		
		//Image
		test_lecture_parser_content(&lecture_parser, &String::from("![tweety](Images/tb_tweety.png)"), &String::from("<p id=\"1\"><img id=\"0\" src=\"ressource/tests/Images/tb_tweety.png\" alt=\"nothing\" /></p>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("![figure](Images/tb_tweety.png)"), &String::from("<div id=\"0\" class=\"figureStyle\"><img id=\"0\" src=\"ressource/tests/Images/tb_tweety.png\" alt=\"nothing\" /><p><b>Figure 0</b></p></div>\n"));
		//Environment
		test_lecture_parser_content(&lecture_parser, &String::from("```advise some advise ```\n"), &String::from("<div id=\"2\" class=\"advise\"><p id=\"1\"> some advise </p>\n</div>\n"));
		test_lecture_parser_content(&lecture_parser, &String::from("```advise\n some advise\n```warning\nRelated warning ```\n```\n"), &String::from("<div id=\"5\" class=\"advise\"><p id=\"1\">  some advise</p>\n\n<div id=\"4\" class=\"workinprogress\">\n\t<div class=\"workinprogressimage\"><img src=\"book/images/panel_warning.png\" alt=\"wip\" /></div>\n<div id=\"4\" class=\"warning\"><p id=\"3\"> Related warning </p>\n</div>\n</div>\n</div>\n"));
		//List and item
		test_lecture_parser_content(&lecture_parser, &String::from("- some item\n- an other item\n\n"), &String::from("<lu><li><p id=\"3\">some item</p>\n</li>\n<li><p id=\"6\"> an other item</p>\n</li>\n</lu>\n"));
	}
}