-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen.cpp
More file actions
30 lines (30 loc) · 697 Bytes
/
gen.cpp
File metadata and controls
30 lines (30 loc) · 697 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("template.md","r",stdin);
freopen("body.tex","w",stdout);
string s;
while(getline(cin,s))
{
if(s.size()>=3&&s[0]=='#'&&s[1]=='#'&&s[2]=='#')
{
cout<<"\\subsection{";
for(int i=4;i<s.size();++i) cout<<s[i];
cout<<"}"<<endl;
}
else if(s.size()>=2&&s[0]=='#'&&s[1]=='#')
{
cout<<"\\section{";
for(int i=3;i<s.size();++i) cout<<s[i];
cout<<"}"<<endl;
}
else if(s=="```cpp")
cout<<"\\begin{lstlisting}[language={C++}]"<<endl;
else if(s=="```")
cout<<"\\end{lstlisting}"<<endl;
else cout<<s<<endl;
}
freopen("con","w",stdout);
system("xelatex main.tex");
}