<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/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 &gt; output.tex

while(&lt;&gt;){
	s| "| &lt;&lt;|g;
	s|^"|&lt;&lt;|g;
	s|\t"|\t&lt;&lt;|g;
	s|\("|\(&lt;&lt;|g;
	s|\["|\[&lt;&lt;|g;
	s|="|=&lt;&lt;|g;
	s|"|&gt;&gt;|g;
	s|``|&lt;&lt;|g;
	s|''|&gt;&gt;|g;
	s|`|&lt;&lt;|g;
	s|'([^\w])|&gt;&gt;$1|g;
	s| - | --- |g;
	s| ---$| ---|g;
	s|^--- |--* |g;
	s|\\|BACKSLASH|g;
	s|&amp;|\\&amp;|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|&lt;&lt;|\\&lt;|g;
	s|&gt;&gt;|\\&gt;|g;
print;
}

BEGIN {
print &lt;&lt;END_OF_BEGIN
\\documentclass{article}
% add more oprions here
\\usepackage[ru]{qqru}

\\begin{document}

END_OF_BEGIN
}

END{
print &lt;&lt;END_OF_END

\\end{document}
END_OF_END
}

#</pre></body></html>