def _post_process(self, target): with codecs.open(target,'r',encoding='utf8') as f: soup = BeautifulSoup(f, 'html.parser') for link in soup.find_all('a', href=ADOC_LINK): link['href'] = noext(link['href']) + '.html' with open(target, 'w') as f: f.write(soup.encode('utf-8'))
def _post_process(self, target): with codecs.open(target, 'r', encoding='utf8') as f: soup = BeautifulSoup(f) for link in soup.find_all('a', href=ADOC_LINK): link['href'] = noext(link['href']) + '.html' with open(target, 'w') as f: f.write(soup.encode('utf-8'))
def _add_suggest_edits_link(self, links): for f in self.list_files('*.partial'): basename = noext(path.basename(f)) links.append({ 'filter': basename, 'url': CREATE_GITHUB_ISSUE_URL.format( urllib.quote( path.join(*(self._context['path'] + [basename])) ) ), 'name': '<i class=\"fa fa-pencil-square-o fa-lg\"></i> Suggest Edits' })
def _add_suggest_edits_link(self, links): for f in self.list_files('*.partial'): basename = noext(path.basename(f)) links.append({ 'filter': basename, 'url': CREATE_GITHUB_ISSUE_URL.format( urllib.quote( path.join(*(self._context['path'] + [basename])))), 'name': '<i class=\"fa fa-pencil-square-o fa-lg\"></i> Suggest Edits' })
def _add_suggest_edits_link(self, variables): for f in self.list_files('*.partial'): basename = noext(path.basename(f)) filename = path.join(*(self._context['path'] + [basename])) urlname = re.sub("/index$", "/", filename) variables.append({ 'filter': basename, 'values': { 'sidelinks': [{ 'url': CREATE_GITHUB_ISSUE_URL.format( filename=urllib.quote(filename), urlname=urllib.quote(urlname), ), 'name': '<i class=\"fa fa-pencil-square-o fa-lg\"></i> Suggest Edits' }] } })
def _run(self): for item in self.list_files(['*.adoc', '*.asciidoc', '*.txt']): target = noext(item) + '.partial' self._convert(item, target) self._post_process(target)