Relativize links
437820
private Element rewriteLinks(final Element src) {
        final Element dst = (Element) src.cloneNode(true);
        for (final Element desc: getChildElements(dst, TOPIC_DESC, true)) {
            for (final Element elem: getChildElements(desc, true)) {
                final Attr href = elem.getAttributeNode(ATTRIBUTE_NAME_HREF);
                final String scope = elem.getAttribute(ATTRIBUTE_NAME_SCOPE);
                if (href != null && !scope.equals(ATTR_SCOPE_VALUE_EXTERNAL)) {
                    final URI abs = baseURI.resolve(href.getValue());
                    final URI rel = getRelativePath(currentFile, abs);
                    href.setValue(rel.toString());
                }
            }
        }
        return dst;
    }
708317
def _relativize_uris(text)
      return text unless _relativize?
      path_to_root= _path_to_root
      text.force_encoding("UTF-8") if text.respond_to? :force_encoding
      text.gsub HTML_MUNGABLE_RE do |match|
        if $5 == '/'
          "#{ $1 }#{ $2 }=#{ $3 }#{ $4 }/"
        else
          "#{ $1 }#{ $2 }=#{ $3 }#{ $4 }#{ path_to_root }"
        end
      end
    end
205097
def link(text, link_func):
    """"""
    def object_formatter(v, c, m, p):
        """Format object view link."""
        return Markup('<a href="{0}">{1}</a>'.format(
            link_func(m), text))
    return object_formatter
849759
function editLinks(data, newPath, oldPath) {
    let newData = data;
    newData = newData.split(oldPath).join(newPath);
    return newData;
}
470886
function link(href, title, text) {

  var reLabelFirst = /^(.*?)\s*\?([^?\s]*)\?(\*?)(X?)(H?)$/;
  var reLabelAfter = /^\?([^?\s]*)\?(\*?)(X?)(H?)\s*(.*)$/;

  var m = text.match(reLabelFirst);
  if (m) return renderInput(m[1], m[2], m[3], m[4], m[5], href, title, true);

  m = text.match(reLabelAfter);
  if (m) return renderInput(m[5], m[1], m[2], m[3], m[4], href, title, false);

  return fallback.link.call(this, href, title, text);
}
364072
def links(cls, page):
    """"""
    for match in cls.HREF_RE.finditer(page):
      yield cls.href_match_to_url(match)
1077440
def _scrub_links(links, name):
    '''
    
    '''
    if isinstance(links, list):
        ret = []
        for l in links:
            ret.append(l.replace('/{0}/'.format(name), '/', 1))
    else:
        ret = links

    return ret
196489
function fixAllLinks(htmlFiles) {
  const writePromises = [];
  htmlFiles.forEach(file => {
    // Update links in each html file to match flattened file structure.
    writePromises.push(fixLinks(`${docPath}/${file}.html`));
  });
  return Promise.all(writePromises);
}
814588
function( url, rez, params ) {
			params = params || '';

			if ( $.type( params ) === "object" ) {
				params = $.param(params, true);
			}

			$.each(rez, function(key, value) {
				url = url.replace( '$' + key, value || '' );
			});

			if (params.length) {
				url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params;
			}

			return url;
		}
188647
def links
      @links ||= @schema.links.map do |link|
        if link.method && link.href
          Link.new(link)
        end
      end.compact
    end
1074559
public static Link link(String href, String rel) {
        return link(href, rel, null, null, null);
    }
703364
def links(self):
        """"""
        ret = []
        linkheader = self.getheader('link')
        if not linkheader:
            return ret
        for i in linkheader.split(','):
            try:
                url, params = i.split(';', 1)
            except ValueError:
                url, params = i, ''
            link = {}
            link['url'] = url.strip('''<> '"''')
            for param in params.split(';'):
                try:
                    k, v = param.split('=')
                except ValueError:
                    break
                link[k.strip(''' '"''')] = v.strip(''' '"''')
            ret.append(link)
        return ret
738942
public function addOneLink($rel, $href, $type = '', $attr = array(), $cond = '')
	{
		$this->addLink(array(array($rel, $href, $type, $attr, $cond)));
	}
1146391
def expand_link(self, **kwargs):
        '''
        '''
        props = self.link.props.copy()
        del props['templated']
        return Link(
            uri=self.expand_uri(**kwargs),
            properties=props,
        )
623801
function normalizeLink(base, input) {
  assert(input.rel, 'links must have a rel');
  assert(input.href, 'links must have an href');

  var ret = clone(input);

  ret.rel = normalizeRel(base, input.rel);
  ret.href = normalizeHref(base, input.href);

  var cls = normalizeClass(input.class);
  if (cls) ret.class = cls;

  return ret;
}
1176139
function findLinks(rootNode, callback)
{
	var attrName,i,link,linkAttrs,numAttrs,url;
	
	walk(rootNode, function(node)
	{
		linkAttrs = maxFilterLevel[node.nodeName];
		
		// If a supported element
		if (linkAttrs != null)
		{
			numAttrs = node.attrs.length;
			
			// Faster to loop through Arrays than Objects
			for (i=0; i<numAttrs; i++)
			{
				attrName = node.attrs[i].name;
				url = null;
				
				// If a supported attribute
				if (linkAttrs[attrName] === true)
				{
					// Special case for `<meta http-equiv="refresh" content="5; url=redirect.html">`
					if (node.nodeName==="meta" && attrName==="content")
					{
						if (node.attrMap["http-equiv"]!=null && node.attrMap["http-equiv"].toLowerCase()==="refresh")
						{
							url = parseMetaRefresh( node.attrMap[attrName] ).url;
						}
					}
					else
					{
						// https://html.spec.whatwg.org/multipage/infrastructure.html#valid-url-potentially-surrounded-by-spaces
						url = node.attrMap[attrName].trim();
					}
					
					if (url != null)
					{
						callback(node, attrName, url);
					}
				}
			}
		}
	});
}
246222
def _relIndexLink(self):
        """"""
        return os.path.join("..", os.path.basename(self.pathname), "index.html")