def trac_get_reference(env, context, rawtext, target, text): fulltext = target + ' ' + text if text else target link = extract_link(env, context, fulltext) uri = None missing = False if isinstance(link, (Element, Fragment)): linktext = Markup(link).striptags() # the following is a bit hackish, but it takes into account: # - an eventual trailing '?' for missing wiki pages # - space eventually introduced due to split_page_names option if linktext.rstrip('?').replace(' ', '') != target: text = linktext elt = find_element(link, 'href', 'missing') if elt is not None: uri = elt.attrib.get('href', '') missing = 'missing' in elt.attrib.get('class', '').split() else: uri = context.href.wiki(target) missing = not WikiSystem(env).has_page(target) if uri or missing: reference = nodes.reference(rawtext, text or target) reference['refuri'] = uri if missing: reference['classes'].append('missing') return reference
def trac_get_reference(env, context, rawtext, target, text): fulltext = target + ' ' + text if text else target link = extract_link(env, context, fulltext) uri = None missing = False if isinstance(link, (Element, Fragment)): linktext = Markup(link).striptags() # the following is a bit hackish, but it takes into account: # - an eventual trailing '?' for missing wiki pages # - space eventually introduced due to split_page_names option if linktext.rstrip('?').replace(' ', '') != target: text = linktext elt = find_element(link, 'href', 'missing') if elt is not None: uri = elt.attrib.get('href', '') missing = 'missing' in elt.attrib.get('class', '').split() else: uri = context.href.wiki(target) missing = not WikiSystem(env).has_page(target) if uri or missing: reference = nodes.reference(rawtext, text or target) reference['refuri'] = uri if missing: reference['classes'].append('missing') return reference
def trac_get_reference(rawtext, target, text): fulltext = text and target+' '+text or target link = wiki_to_link(fulltext, self.env, req) uri = None missing = False if isinstance(link, Element): linktext = Markup(link).striptags() # the following is a bit hackish, but it takes into account: # - an eventual trailing '?' for missing wiki pages # - space eventually introduced due to split_page_names option if linktext.rstrip('?').replace(' ', '') != target: text = linktext uri = link.attr.get('href', '') missing = 'missing' in link.attr.get('class_', '') else: uri = req.href.wiki(target) missing = not WikiSystem(self.env).has_page(target) if uri: reference = nodes.reference(rawtext, text or target) reference['refuri']= uri if missing: reference.set_class('missing') return reference return None
def trac_get_reference(rawtext, target, text): fulltext = text and target + ' ' + text or target link = wiki_to_link(fulltext, self.env, req) uri = None missing = False if isinstance(link, Element): linktext = Markup(link).striptags() # the following is a bit hackish, but it takes into account: # - an eventual trailing '?' for missing wiki pages # - space eventually introduced due to split_page_names option if linktext.rstrip('?').replace(' ', '') != target: text = linktext uri = link.attr.get('href', '') missing = 'missing' in link.attr.get('class_', '') else: uri = req.href.wiki(target) missing = not WikiSystem(self.env).has_page(target) if uri: reference = nodes.reference(rawtext, text or target) reference['refuri'] = uri if missing: reference.set_class('missing') return reference return None