This repository was archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetexmd
More file actions
30 lines (28 loc) · 1.26 KB
/
detexmd
File metadata and controls
30 lines (28 loc) · 1.26 KB
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
#!/bin/sh
# Purpose here is to get all of the lines that are between '@l' tokens
# into their own tex file. This will then be '\input'ed into the file
# generated by lowdown
# count and file are the varaibles that we need to keep track of.
# this is what is responsible for handling the @l tokens, and latex
# code in between them
count=0; file=l.md; cp ${file} copy-${file}; sed -n "/^@l$/=" ${file} | awk '{if (NR % 2 == 0) {print $1} else {printf $1 "\t" }}' | while read LINE; \
do \
start=$(echo $LINE | cut -d' ' -f1); \
end=$(echo $LINE | cut -d' ' -f2); \
sed -n "${start},${end}p" ${file} > ${count}-${file}.tex; \
sed -i "/@l/d" ${count}-${file}.tex; \
sed "${start},${end}s/.*/@input{${count}-${file}.tex}/g" copy-${file} > copy-${count}-${file}; \
mv copy-${count}-${file} copy-${file} ; \
count=$((count + 1)); \
done
# Now we are on to the @m tokens
count=0; file=l.md; sed -n "/@m/=" ${file} | while read LINE; \
do \
sed -n "${LINE}p" ${file} > ${count}-math-${file}.tex; \
sed -i -e "s=^[^@]*@m=@m=" -e "s/@m/$/g" ${count}-math-${file}.tex; \
sed "${LINE}s/@m.*@m/@input{${count}-math-${file}.tex}/" copy-${file} > copy-${count}-${file}; \
mv copy-${count}-${file} copy-${file} ; \
count=$((count + 1)); \
done
uniq copy-${file} > detex-${file}
rm copy-${file}