Dewikilinker

=== Funktion ===
* Entfernen von Wikilinks innerhalb Weblinks im ANR
=== Source 1.2 ===
set fl [open wiw.out r]
set data [read $fl]
close $fl
set offset [dict get [lindex [dict values [join [regexp -all -inline -line -- {^edit.*?$} $data]]] end] title]
if [string match {*end of task*} $data] {
 set fl [open wiw.out w+]
 close $fl
 set offset 0
}
puts \nOffset:[expr {[empty offset]?[set offset 0]:$offset}]
cont {ret1 {
 foreach item [allpages $ret1] {
 dict with item {
 set content_orig [contents id $pageid x]
 set contents [string map {& \\&} $content_orig]
 set weblinks_mask [regexp -all -inline -- {\[http.*?\]} [string map {[[ <<<< ]] >>>>} $contents]]
 foreach weblink_mask $weblinks_mask {
 if [string match *<<<<* $weblink_mask] {
 set webwikilink [string map {<<<< [[ >>>> ]]} $weblink_mask]
 regsub -all -- {<<<<(?:.*?\|)?(.*?)>>>>(.*?)<<<<(?:.*?\|)?(.*?)>>>>} $weblink_mask \\1\\2\\3 weblink
 regsub -all -- {<<<<(?:.*?\|)?(.*?)>>>>} $weblink \\1 weblink
 set weblink [string map {{ ]} ]} $weblink]
 regsub -all -- (?q)$webwikilink $contents $weblink contents
 }
 }
 set contents [string map {\\& &} $contents]
 if {[string match *<<<<* $contents] || [string match *>>>>* $contents]} {
 puts "====\nFehler: $item\n===="
 continue
 }
 if {$contents ne $content_orig} {
 puts [edid $pageid {Wikilink aus Weblink entfernt} $contents]
 puts "newoffset \{$title\}"
 }
 }
 }
}} {*}$allpages / apnamespace 0 / apfilterredir nonredirects / apfrom $offset
puts {end of task}
=== Source 1.1 ===
set fl [open wiw.out r]
set data [read $fl]
close $fl
set offset [dict get [lindex [dict values [join [regexp -all -inline -line -- {^edit.*?$} $data]]] end] title]
if [string match {*end of task*} $data] {
 set fl [open wiw.out w+]
 close $fl
 set offset 0
}
puts \nOffset:[expr {[empty offset]?[set offset 0]:$offset}]
cont {ret1 {
 foreach item [allpages $ret1] {
 dict with item {
 set content_orig [contents id $pageid x]
 set contents [string map {& \\&} $content_orig]
 set weblinks_mask [regexp -all -inline -- {\[http.*?\]} [string map {[[ <<<< ]] >>>>} $contents]]
 foreach weblink_mask $weblinks_mask {
 if [string match *<<<<* $weblink_mask] {
 set webwikilink [string map {<<<< [[ >>>> ]]} $weblink_mask]
 regsub -all -- {<<<<(?:.*?\|)?(.*?)>>>>(.*?)<<<<(?:.*?\|)?(.*?)>>>>} $weblink_mask \\1\\2\\3 weblink
 regsub -all -- {<<<<(?:.*?\|)?(.*?)>>>>} $weblink \\1 weblink
 regsub -all -- (?q)$webwikilink $contents $weblink contents
 }
 }
 set contents [string map {\\& &} $contents]
 if {[string match *<<<<* $contents] || [string match *>>>>* $contents]} {
 puts "====\nFehler: $item\n===="
 continue
 }
 if {$contents ne $content_orig} {
 puts [edid $pageid {Wikilink aus Weblink entfernt} $contents]
 puts "newoffset \{$title\}"
 }
 }
 }
}} {*}$allpages / apnamespace 0 / apfilterredir nonredirects / apfrom $offset
puts {end of task}
=== Source 1.0 ===
cont {ret1 {
 foreach item [allpages $ret1] {
 dict with item {
 set content_orig [contents id $pageid x]
 set contents [string map {& \\&} $content_orig]
 set weblinks_mask [regexp -all -inline -- {\[http.*?\]} [string map {[[ <<<< ]] >>>>} $contents]]
 foreach weblink_mask $weblinks_mask {
 if [string match *<<<<* $weblink_mask] {
 set webwikilink [string map {<<<< [[ >>>> ]]} $weblink_mask]
 regsub -all -- {<<<<(?:.*?\|)?(.*?)>>>>(.*?)<<<<(?:.*?\|)?(.*?)>>>>} $weblink_mask \\1\\2\\3 weblink
 regsub -all -- {<<<<(?:.*?\|)?(.*?)>>>>} $weblink \\1 weblink
 regsub -all -- (?q)$webwikilink $contents $weblink contents
 }
 }
 set contents [string map {\\& &} $contents]
 if {$contents ne $content_orig} {puts [edid $pageid {Wikilink aus Weblink entfernt} $contents]}
 }
 }
}} {*}$allpages / apnamespace 0 / apfilterredir nonredirects