#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; const int maxn=1e2+2; char str[maxn]; void line(int l,int r){ int i=l; while(str[i]=='#'||str[i]=='*'||str[i]==' ') i++; while(i<=r){ if(str[i]=='_'){ i++; int x,y; x=i; while(str[i]!='_') y=i,i++; i++; printf("<em>"); line(x,y); printf("</em>"); }else if(str[i]=='['){ i++; int l1,r1,l2,r2; l1=i; while(str[i]!=']') r1=i,i++; i+=2; l2=i; while(str[i]!=')') r2=i,i++; i++; printf("<a href=""); line(l2,r2); printf("">"); line(l1,r1); printf("</a>"); }else{ printf("%c",str[i]); i++; } } } void title(){ int len=strlen(str); len--; int i; for(i=0;i<len;i++){ if(str[i]!='#') break; } printf("<h%d>",i); line(0,strlen(str)-2); printf("</h%d> ",i); } void unlist(){ printf("<ul> "); printf("<li>"); line(0,strlen(str)-2); printf("</li> "); while(fgets(str,maxn,stdin)!=NULL){ if(str[0]==' ') break; printf("<li>"); line(0,strlen(str)-2); printf("</li> "); } printf("</ul> "); } void para(){ printf("<p>"); line(0,strlen(str)-2); while(fgets(str,maxn,stdin)!=NULL){ if(str[0]==' '){ break; } printf(" "); line(0,strlen(str)-2); } printf("</p> "); } int main(){ while(fgets(str,maxn,stdin)!=NULL){ if(str[0]==' ') continue; if(str[0]=='#'){ title(); }else if(str[0]=='*'){ unlist(); }else{ para(); } } return 0; }