#include<iostream>
#include<vector>
using namespace std;
vector<string>v;
void clj(int l,int r,string s){
int flag=1;
string tx;
string wz;
int i=l+1;
while(s[i]!=']')i++;
string str=s.substr(l+1,i-1-l);
for(int i=0;i<str.size();i++){
if(str[i]=='_'){
if(flag)tx+="<em>";
else tx+="</em>";
flag^=1;
}else tx+=str[i];
}
//i+1,r-1
wz=s.substr(i+2,r-i-2);
cout<<"<a href=\""<<wz<<"\">"<<tx<<"</a>";
}
void fun(int l,int r,string s){
int flag=1;
for(int i=l;i<=r;i++){
if(s[i]=='_'){
if(flag)cout<<"<em>";
else cout<<"</em>";
flag^=1;
}else if(s[i]=='['){
int j=i+1;
while(s[j]!=')')j++;
clj(i,j,s);
i=j;
}else cout<<s[i];
}
}
void qk(int l,int r){
if(v[l][0]=='#'){
int i=1;
while(v[l][i]=='#')i++;
int t=i;
cout<<"<h"<<t<<'>';
while(v[l][i]==' ')i++;
fun(i,v[l].size()-1,v[l]);
cout<<"</h"<<t<<'>';
}else if(v[l][0]=='*'){
cout<<"<ul>"<<endl;
for(int i=l;i<=r;i++){
int j=1;
while(v[i][j]==' ')j++;
cout<<"<li>";
fun(j,v[i].size()-1,v[i]);
cout<<"</li>"<<endl;
}
cout<<"</ul>";
}else{
cout<<"<p>";
for(int i=l;i<r;i++){
fun(0,v[i].size()-1,v[i]);
cout<<endl;
}
fun(0,v[r].size()-1,v[r]);
cout<<"</p>";
}
cout<<endl;
}
int main(){
string s;
while(getline(cin,s))v.push_back(s);
for(int i=0;i<v.size();i++){
if(v[i].empty())continue;
int j=i;
while(j<v.size()&&v[j].size())j++;
qk(i,j-1);
i=j;
}
}
Markdown
最新推荐文章于 2024-10-25 15:02:57 发布