| Ticket UUID: | 1008619 | |||
| Title: | htmlparse::2tree gets the HTML Doc structure wrong | |||
| Type: | Bug | Version: | None | |
| Submitter: | nobody | Created on: | 2004-08-13 10:39:39 | |
| Subsystem: | htmlparse | Assigned To: | andreas_kupries | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2026-11-21 08:42:16 | |
| Resolution: | Fixed | Closed By: | serhiy.storchaka | |
| Closed on: | 2026-11-21 08:42:16 | |||
| Description: |
The following shows how to repeat the bug.
$ cat wrong.tcl
package require htmlparse
set indent 0
set t [struct::tree]
set html
{<html><head></head><body><h1>heading</h1><p>ayaken!</p></body></html>}
proc painter {tree act node} {
global indent
if {$act == "enter"} then {
incr indent
puts ">[string repeat - [expr
{$indent-1}]][$tree get $node type]"
} else {
puts "<[string repeat - [expr
{$indent-1}]][$tree get $node type]"
incr indent -1
}
}
htmlparse::2tree $html $t
$t walk root -order both -type dfs {act node} {painter
$t $act $node}
$ tclsh wrong.tcl
>root
>-hmstart
>--html
>---head
<---head
>---body
>----h1
>-----PCDATA
<-----PCDATA
>-----p
>------PCDATA
<------PCDATA
<-----p
<----h1
<---body
<--html
<-hmstart
<root
You can see the p element is wrong in the hierarchy, it
got sorted as a child of the h1 element, not, as it
should be, as its sibling.
I assume it's htmlparse innards which get it wrong, not
2tree only, just a guess though.
If there's need to contact me, I'm reachable at
Ephaeton (at) gmx (dot) net.
| |||
| User Comments: |
serhiy.storchaka added on 2026-11-21 08:42:16:
The tree reordering pass moved the under the preceding . It was made less aggressive in [ab08ecbe1c] (SF patch 953854, tcllib 1.9). Verified with the ticket's script: the parent check-in nests p in h1, trunk makes it a sibling. | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki