MCPcopy Create free account
hub / github.com/KLayout/klayout / xml2html

Function xml2html

scripts/extract_user_doc.rb:4–25  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

2# Produces the documentation text from within KLayout
3
4def 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
25end
26
27title = "KLayout "
28title += ($klayout_version || "$version") + " "

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected