Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_pandoc_multilink(strings, refs):
inlines = [[pf.Str(str(s))] for s in strings]
targets = [(r, "") for r in refs]
links = [pf.Link(inline, target)
for inline, target in zip(inlines, targets)]
return join_items(links)
else:
pre, label, post = value
rtype = self.references[label]['type']
n = self.references[label]['id']
text = self.replacements[rtype].format(n)
if format in self.formats:
link = link_styles[format][rtype].format(text=text,
label=label,
pre=pre,
post=post)
return RawInline(format, link)
else:
link = pf.Link([pf.Str(text)], ('#' + label, ''))
return [pf.Str(pre), link, pf.Str(post)]
def _filter(key, value, format, meta):
# remove HTML specific stuff
if key == "Link":
# remove relative path prefix and .html suffix
internal, [href, text] = value
if href.endswith(".html"):
href = href[:-5]
# FIXME: this stupid detection will not work
# or just leave the full path?
# if href.startswith("./"):
# href = href[2:]
# elif href.startswith("../"):
# href = href[3:]
return pandocfilters.Link(internal, [href, text])
def create_pandoc_multilink(strings, refs):
inlines = [[pf.Str(str(s))] for s in strings]
targets = [(r, "") for r in refs]
links = [pf.Link(inline, target)
for inline, target in zip(inlines, targets)]
return join_items(links)
def transform_url(key, value, format, meta):
if key != 'Link':
return None
# Then value has the following form:
# [[{'t': 'Str', 'c': 'Contributing'}], ['docs/contributing.md', '']]
# Extract the URL.
url = value[1][0]
new_url = convert_url(url)
if new_url is None:
return None
log.info("converting URL:\n"
" %s\n"
"-->%s" % (url, new_url))
value[1][0] = new_url
return Link(*value)
return transform_url
if format == 'latex' and self.autoref:
link = u'{pre}\\autoref{{{label}}}{post}'.format(pre=prefix,
label=label,
post=suffix)
return pf.RawInline('latex', link)
elif format == 'latex' and not self.autoref:
link = u'{pre}\\ref{{{label}}}{post}'.format(pre=prefix,
label=label,
post=suffix)
return pf.RawInline('latex', link)
else:
link_text = '{}{}{}'.format(prefix, text, suffix)
link = pf.Link([pf.Str(link_text)], ('#' + label, ''))
return link