home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / asci2htm.zip / htm2asci.cmd < prev   
OS/2 REXX Batch file  |  2002-09-27  |  2KB  |  62 lines

  1. /* HTML to ASCII (852) converter */
  2.  
  3. '@echo off'
  4. parse arg input output maradek
  5.  
  6. if input = '' | output = '' | maradek <> '' then
  7.         do
  8.                 say 'HTML to ASCII (852) converter'
  9.                 exit
  10.         end
  11.  
  12. 'del 'output' >NUL 2>>&1'
  13.  
  14. accented_table  = "á╡éÉí╓óαöÖΣσúΘüÜûΩ"
  15. htmltag.1       = "á"  /* á */
  16. htmltag.2       = "Á"  /* ╡ */
  17. htmltag.3       = "é"  /* é */
  18. htmltag.4       = "É"  /* É */
  19. htmltag.5       = "í"  /* í */
  20. htmltag.6       = "Í"  /* ╓ */
  21. htmltag.7       = "ó"  /* ó */
  22. htmltag.8       = "Ó"  /* α */
  23. htmltag.9       = "ö"    /* ö */
  24. htmltag.10      = "Ö"    /* Ö */
  25. htmltag.11      = "ô"   /* Σ */
  26. htmltag.12      = "Ô"   /* σ */
  27. htmltag.13      = "ú"  /* ú */
  28. htmltag.14      = "Ú"  /* Θ */
  29. htmltag.15      = "ü"    /* ü */
  30. htmltag.16      = "Ü"    /* Ü */
  31. htmltag.17      = "û"   /* û */
  32. htmltag.18      = "Û"   /* Ω */
  33.  
  34. do while lines(input)
  35.         line = linein(input)
  36.         do tag_num = 1 to 18
  37.                 tag = htmltag.tag_num
  38.                 do until tag_pos = 0
  39.                         tag_pos = pos(tag,line)
  40.                         if tag_pos <> 0 then
  41.                                 do
  42.                                         acc_char = substr(accented_table, tag_num, 1)
  43.                                         if tag_pos = 1 then
  44.                                                 head = ''
  45.                                         else
  46.                                                 head = left(line, tag_pos-1)
  47.                                         if tag_pos = length(line) - length(tag) + 1 then
  48.                                                 tail = ''
  49.                                         else
  50.                                                 tail = substr(line, tag_pos+length(tag))
  51.                                         line = head || acc_char || tail
  52.                                 end
  53.                 end
  54.         end
  55.         rc = lineout(output, line)
  56. end
  57.  
  58. rc = lineout(input)
  59. rc = lineout(output)
  60.  
  61. exit
  62.