|        | |||||||||||
| 
 | 
Introduction
This example of an up-translate program converts RTF (Rich Text Format) into SGML.
The program does the following:
In practice, preamble material (style sheets) will need to be skipped over, and other styles and paragraph commands (such as "\par") will need to be recognized.
  up-translate
  find "\s23" lookahead ! digit
     output "<p>"
  find "\" letter [letter | digit | "-"]* | ; RTF command
       "\" any |                            ; other RTF code
       ["{}"]                               ; RTF grouping
     ; output nothing for these.
  find "\" ["{}\"] => protected-character
     output protected-character ; some characters are protected by \
  find "\'" any {2} => hex-code ; some characters are in hexadecimal
     local counter character-value
     set character-value to hex-code base 16
     output "&#%d(character-value);"
  find "<"
     output "<<!>" ; "<" often needs protecting in the SGML
  find "&"
     output "&<!>" ; likewise "&"
| Related Concepts Up-translation: translating documents into XML/SGML | 
| ---- |