Convert an RTF file to HTML and display the code on the webpage.

Source: Internet
Author: User
Tags ereg
It works like this to convert an RTF file into HTML and display the code on the webpage. it uploads an RTF file and converts it to HTML for display. the code is a bit complicated, teaman needs to study it well, as if the Chinese version is a bit problematic. & Nbsp; & lt; html & gt; & nbsp; & lt; b. convert an RTF file to HTML and display the code on the webpage.
This is how it works. it uploads an RTF file and converts it to HTML for display. the code is a bit complicated and teaman needs to study it well, as if the Chinese version is a bit problematic.



If (! ($ Userfile )){
?>



Exit;
}
Function ProcessTags ($ tags, $ line ){
$ Html = "";
Global $ color;
Global $ size;
Global $ bullets;
// Remove spaces.
$ Tags = trim ($ tags );
// Found the beginning of the bulleted l
// Ist.
If (ereg ("\ pnindent", $ tags )){
$ Html. ="
  • ";
    $ Bullets + = $ line;
    $ Tags = ereg_replace ("\ par", "", $ tags );
    $ Tags = ereg_replace ("\ (tab)", "", $ tags );
    }
    If ($ line-$ bullets = 0 ){
    $ Tags = ereg_replace ("\ par", "", $ tags );
    }
    Elseif ($ line-$ bullets = 1 ){
    If (ereg ("\ pntext", $ tags )){
    $ Html. ="
  • ";
    $ Tags = ereg_replace ("\ par", "", $ tags );
    $ Tags = ereg_replace ("\ (tab)", "", $ tags );
    $ Bullets ++;
    }
    Else {
    $ Html. ="
";
$ Bullets = 0;
}
}
// Convert Bold.
If (ereg ("\ 0", $ tags) {$ html. ="";}
Elseif (ereg ("\", $ tags) {$ html. =" ";}
// Convert Italic.
If (ereg ("\ i0", $ tags) {$ html. ="";}
Elseif (ereg ("\ I", $ tags) {$ html. ="";}
// Convert Underline.
If (ereg ("\ ulnone", $ tags) {$ html. ="";}
Elseif (ereg ("\ ul", $ tags) {$ html. ="";}
// Convert Alignments.
If (ereg ("\ pard \ qc", $ tags) {$ html. = "";}
Elseif (ereg ("\ pard \ qr", $ tags) {$ html. = "";}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.