User-friendly markdown and text "compiler" to use imports, variables and comments
To use TexImpRes pull this repository and install Python3 (version 3.10 recommended).
Create text/markdown file/-s (for example main.md
) that is using some keywords.
With the following command you select the main.md
as entry-file and result.md
as "compiled" output file:
python3 src/main.py main.md result.md
With import`s you can copy the content of a file and paste them at the selected position.
Imports are used like this:
@import "the_file_you_want_to_import.txt"
Example:
File: main.txt
1
2
3
@import "number_4_to_6.txt"
7
8
9
File: number_4_to_6.txt
4
5
6
If you run python3 src/main.py main.txt output.txt
and then open output.txt
you see this:
1
2
3
4
5
6
7
8
9
With variables you can dynamically add values to you files.
You can define variables like this:
@var my_name = "John Doe"
@var NUMBER_PI = "3.141592"
and use them like this:
Hey $my_name nice to meet you!
Did you already know that pi is $NUMBER_PI?
Example:
File: main.txt
@import "person_1.txt"
$name ist $age years old!
@import "person_2.txt"
$name ist $age years old!
File: person_1.txt
@var name = "Paul"
@var age = "19"
File: person_2.txt
@var name = "Alice"
@var age = "32"
If you run python3 src/main.py main.txt output.txt
and then open output.txt
you see this:
Paul ist 19 years old!
Alice ist 32 years old!
With comments you can document lines of code, these comments will later be removed from the output file!
You can define comments like this:
@comment lorem ipsum...
Example:
File: main.txt
Pi is 3.141592...
@comment this text will not be removed in the output file :D
@comment sure!
Did you know this fact?
If you run python3 src/main.py main.txt output.txt
and then open output.txt
you see this:
Pi is 3.141592...
Did you know this fact?
You find some examples here.