Esempio n. 1
0
def href(children, data):
    """Wrap text into a href.

    >>> print(href ['www.test.org', 'important'].format().render_as('html'))
    <a href="www.test.org">important</a>
    >>> print(sentence ['ready', 'set', href ['www.test.org', 'go']].format().render_as('html'))
    ready, set, <a href="www.test.org">go</a>.
    """
    parts = _format_list(children, data)
    return richtext.HRef(*parts)
Esempio n. 2
0
def href(children, data):
    """Wrap text into a href.

    >>> import pybtex.backends.html
    >>> html = pybtex.backends.html.Backend()
    >>> print(href ['www.test.org', 'important'].format().render(html))
    <a href="www.test.org">important</a>
    >>> print(sentence ['ready', 'set', href ['www.test.org', 'go']].format().render(html))
    Ready, set, <a href="www.test.org">go</a>.
    """
    parts = _format_list(children, data)
    return richtext.HRef(*parts)
Esempio n. 3
0
def href(children, data, url=None, external=False):
    """Wrap text into a href.

    >>> print(href('www.test.org') ['important'].format().render_as('html'))
    <a href="www.test.org">important</a>
    >>> print(sentence ['ready', 'set', href('www.test.org') ['go']].format().render_as('html'))
    ready, set, <a href="www.test.org">go</a>.
    >>> print(href('www.test.org', external=True) ['important'].format().render_as('html'))
    <a href="www.test.org" target="_blank">important</a>
    >>> print(href('www.test.org', external=True) ['important'].format().render_as('latex'))
    \\href[pdfnewwindow]{www.test.org}{important}
    """
    parts = _format_list(children, data)
    if url is None:
        warnings.warn(
            'href [url, text] is deprecated since 0.24: use uref(url) [text] instead',
            DeprecationWarning,
            stacklevel=2)
        url, *parts = parts
    return richtext.HRef(_format_data(url, data), external, *parts)