#!/usr/bin/perl # first we find all the possible links, and their scope, from the contents section open(CONTENTS, "contents.xml"); while () { if (m/id="context_([^"]+)/) { $scope = $1; } if (m/href="([^"]+)">([^<]+)) { chomp; chomp; # we only want to autolink in the description sections s/<\/p>/ <\/p>/g; if (m/id="s_scope_([^"]+)/) { $scope = $1; } if (m/name="([^"]+)"/) { $lastseen = $1; } if ($indesc && m/
/) { $indesc--; } if ($indesc || $wholefile) { foreach $word(split(/\s+/, $_)) { $bareword = $word; $prefix = ""; if ($bareword =~ m/(.*)>(.*)/) { $bareword = $2; $prefix = $1 . ">"; } $bareword =~ tr/A-Z//cd; if ($bareword ne "") { # print STDERR "|$bareword|$word\n"; if ($words { $bareword }) { # print "!"; $link = $map { "$scope|$bareword" }; $link ||= $map { $bareword }; if ($wholefile) { $link ||= $map { "GLOBAL|$bareword" }; $link ||= $map { "LINK|$bareword" }; $link ||= $map { "NODE|$bareword" }; } # if ( ($link ne '') && ($lastseen ne "${scope}_${bareword}") ) { if (($link ne '')) { if ($wholefile) { $link = "config-reference.html" . $link; } $word =~ s/^$prefix//; $word = sprintf("%s%s", $prefix, $link, $word); } } } if ($word eq 'targets.html') { $word = 'targets.html'; } print $word . " "; } } else { print $_; } if (m/div class="description"/) { $indesc = 1; } print "\n"; }