blob: bcdd5a005892af8bad00bbe78fb6849f5b514cf9 (
plain)
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
|
#!/usr/bin/perl -w
# Author: Alexey Shipunov, dactylorhiza@gmail.com
# Version 1.01, 20191002
# Simple text to LaTeX converter, uses 'qqru' package to define "universal" (Russian or English) quotes
# Usage: perl ./txt2qq.pl input.txt > output.tex
while(<>){
s| "| <<|g;
s|^"|<<|g;
s|\t"|\t<<|g;
s|\("|\(<<|g;
s|\["|\[<<|g;
s|="|=<<|g;
s|"|>>|g;
s|``|<<|g;
s|''|>>|g;
s|`|<<|g;
s|'([^\w])|>>$1|g;
s| - | --- |g;
s| ---$| ---|g;
s|^--- |--* |g;
s|\\|BACKSLASH|g;
s|&|\\&|g;
s|\{|\\\{|g;
s|\}|\\\}|g;
s|\$|\\\$|g;
s|\#|\\\#|g;
s|%|\\%|g;
s|BACKSLASH|\$\\backslash\$|g;
s@\|@\$\\mid\$@g;
s|_(.+?)_|\\textit\{$1\}|g;
s|\*(.+?)\*|\\textbf\{$1\}|g;
s| +| |g;
s|<<|\\<|g;
s|>>|\\>|g;
print;
}
BEGIN {
print <<END_OF_BEGIN
\\documentclass{article}
% add more oprions here
\\usepackage[ru]{qqru}
\\begin{document}
END_OF_BEGIN
}
END{
print <<END_OF_END
\\end{document}
END_OF_END
}
#
|