| 2 | # Produces the documentation text from within KLayout |
| 3 | |
| 4 | def xml2html(t) |
| 5 | |
| 6 | # strip XML processing instructions and DTD |
| 7 | t = t.sub(/^.*<body>/m, "") |
| 8 | t = t.sub(/<\/body>.*$/m, "") |
| 9 | |
| 10 | # insert title in front of navigator |
| 11 | t = t.sub(/<p class="navigator">/, "<p class=\"navigator\"><b>KLayout Documentation (Qt #{$qt}): </b>") |
| 12 | |
| 13 | # replace .xml references in hrefs |
| 14 | t = t.gsub(/href=\"(.*?)\.xml\"/) { "href=\"#{$1}.html\""; } |
| 15 | t = t.gsub(/href=\"(.*?)\.xml#(.*?)\"/) { "href=\"#{$1}.html##{$2}\""; } |
| 16 | |
| 17 | # replace simplified XML tags with an opening/closing tag |
| 18 | t = t.gsub(/<(\w+)([^<>]*?)\/>/) { "<#{$1}#{$2}></#{$1}>" } |
| 19 | |
| 20 | # replace some closing tags which are not allowed |
| 21 | t = t.gsub(/<\/br>/, "").gsub(/<\/img>/, "") |
| 22 | |
| 23 | t |
| 24 | |
| 25 | end |
| 26 | |
| 27 | title = "KLayout " |
| 28 | title += ($klayout_version || "$version") + " " |