mirror of https://gitlab.com/QEF/q-e.git
63 lines
1.3 KiB
Tcl
63 lines
1.3 KiB
Tcl
#
|
|
# XML
|
|
#
|
|
proc ::helpdoc::xml_escape_chr {content} {
|
|
# replace xml special characters by escape-characters
|
|
foreach {chr escChr} {
|
|
& {\&}
|
|
< {\<}
|
|
> {\>}
|
|
} {
|
|
regsub -all -- $chr $content $escChr content
|
|
}
|
|
regsub -all -- ' $content {\'} content
|
|
regsub -all -- \" $content {\"} content
|
|
|
|
return $content
|
|
}
|
|
proc ::helpdoc::xml_attr_escape_chr {content} {
|
|
# replace xml special characters by escape-characters
|
|
foreach {chr escChr} {
|
|
& {\&}
|
|
< {\<}
|
|
> {\>}
|
|
} {
|
|
regsub -all -- $chr $content $escChr content
|
|
}
|
|
|
|
return $content
|
|
}
|
|
|
|
|
|
proc ::helpdoc::xml_tag_enter {tag attr content depth} {
|
|
variable fid
|
|
|
|
set indent [indent $depth]
|
|
|
|
set sep ""
|
|
if { $content != "" } {
|
|
if { [llength [split $content \n]] > 1 } {
|
|
set content [trimEmpty $content]
|
|
set sep \n
|
|
} else {
|
|
set sep " "
|
|
}
|
|
}
|
|
|
|
set attr [xml_attr_escape_chr $attr]
|
|
set content [formatString [xml_escape_chr $content]]
|
|
|
|
if { $attr != "" } {
|
|
puts $fid(xml) "${indent}<$tag ${attr}>${sep}${content}"
|
|
} else {
|
|
puts $fid(xml) "${indent}<$tag>${sep}${content}"
|
|
}
|
|
}
|
|
|
|
proc ::helpdoc::xml_tag_leave {tag attr content depth} {
|
|
variable fid
|
|
puts $fid(xml) "[indent $depth]</$tag>"
|
|
}
|
|
|
|
|