summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--convert.py35
-rw-r--r--example.md8
3 files changed, 46 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f90f825
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.idea
+out*
+*.iml \ No newline at end of file
diff --git a/convert.py b/convert.py
new file mode 100644
index 0000000..2c1d7d5
--- /dev/null
+++ b/convert.py
@@ -0,0 +1,35 @@
+#!/bin/env python
+import re
+from sys import argv
+
+path = argv[1]
+data = [line.rstrip("\n") for line in open(path)]
+latex = [
+ "\\documentclass[11pt]{article}",
+ "\\usepackage[utf8]{inputenc}",
+ "\\begin{document}"
+]
+rules = {
+ "(# )(.*)": "\\section{input}", # Caption 1
+ "(## )(.*)": "\\subsection{input}", # Caption 2
+ "(### )(.*)": "\\subsubsection{input}", # Caption 3
+}
+
+for i, line in enumerate(data):
+ print(line)
+ matched = False
+ new_line = line
+ for rule in rules:
+ match = re.match(rule, new_line)
+ if match:
+ print(match.groups())
+ matched = True
+ new_line = rules[rule].replace("input", match.groups()[1])
+ if new_line[-2:] == " ":
+ new_line = new_line[:-2]
+ new_line += "\\\\"
+ latex.append(new_line)
+
+latex.append("\\end{document}")
+open("output.tex", "w").write("\n".join(latex))
+print(latex)
diff --git a/example.md b/example.md
new file mode 100644
index 0000000..c242426
--- /dev/null
+++ b/example.md
@@ -0,0 +1,8 @@
+# Hello World!
+## Hello World!
+### Hello World!
+* I'm a dot
+* Another dot
+
+1. Wooohoo
+2. Testibus \ No newline at end of file