MCPcopy
hub / github.com/pandas-dev/pandas / _render_href

Function _render_href

pandas/io/formats/style_render.py:1954–1965  ·  view source on GitHub ↗

uses regex to detect a common URL pattern and converts to href tag in format.

(x, format)

Source from the content-addressed store, hash-verified

1952
1953
1954def _render_href(x, format):
1955 """uses regex to detect a common URL pattern and converts to href tag in format."""
1956 if isinstance(x, str):
1957 if format == "html":
1958 href = '<a href="{0}" target="_blank">{0}</a>'
1959 elif format == "latex":
1960 href = r"\href{{{0}}}{{{0}}}"
1961 else:
1962 raise ValueError("``hyperlinks`` format can only be 'html' or 'latex'")
1963 pat = r"((http|ftp)s?:\/\/|www.)[\w/\-?=%.:@]+\.[\w/\-&?=%.,':;~!@#$*()\[\]]+"
1964 return re.sub(pat, lambda m: href.format(m.group(0)), x)
1965 return x
1966
1967
1968def _maybe_wrap_formatter(

Callers 1

_maybe_wrap_formatterFunction · 0.85

Calls 2

subMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected