MAJOR=7
MINOR=0
DEVNAME=loop0
DEVTYPE=disk
DISKSEQ=5
  6   ˆl–äY>””Ð;Ê�jãMÜêbÑ¿�þY”7+®•–Ý,’ÏÎƒ ÷ÍÅ¿Ê ð    import pytest

from ..nanorst import rst_to_text


def test_inline():
    assert rst_to_text('*foo* and ``bar``.') == 'foo and bar.'


def test_inline_spread():
    assert rst_to_text('*foo and bar, thusly\nfoobar*.') == 'foo and bar, thusly\nfoobar.'


def test_comment_inline():
    assert rst_to_text('Foo and Bar\n.. foo\nbar') == 'Foo and Bar\n.. foo\nbar'


def test_inline_escape():
    assert rst_to_text('Such as "\\*" characters.') == 'Such as "*" characters.'


def test_comment():
    assert rst_to_text('Foo and Bar\n\n.. foo\nbar') == 'Foo and Bar\n\nbar'


def test_directive_note():
    assert rst_to_text('.. note::\n   Note this and that') == 'Note:\n   Note this and that'


def test_ref():
    references = {
        'foo': 'baz'
    }
    assert rst_to_text('See :ref:`fo\no`.', references=references) == 'See baz.'


def test_undefined_ref():
    with pytest.raises(ValueError) as exc_info:
        rst_to_text('See :ref:`foo`.')
    assert 'Undefined reference' in str(exc_info.value)
     ˆÉÈÍ589Ç¿Ê M    ‹      Õ–_oÚ0Åßû)<?ì.ÿº2uih”¢–iš¦	Û‹ÄŽì›Röéç�lÐ´í¡•òÛ×'ñù�X‰ƒ7Ñípþu6"ç72ûüa2Ú øÒDó¨œè5[m€Ñ”#f}€ívÛÜv›Æ®a~1¦IZÅ±)PÐð"(já	bÉ„oI€
Žµ��Ä¬˜�²™50¶^Øp2Y�5Áíð„9Jg9–×VÕôûŽ[“$‰áòAqù{Fçé¾œ™­´”Ëz#P9	–Fì
ƒí×7ã×ÜGÁ–{OE×†Æä�%j­MFÃ@¥kâ,PPÜhË„éMs­V”°ôÛxxûÝë¼Ñâî0`Ä;^èûá`zu;ˆh8e©€�ÖÜxÍ5'Ì!I�P+%ÅYñ})¾W?Î?0*5‘ôI¨•Ñ)xÄcTn—1Ïzé	b{¬*%âoi0þ$ŒÙõÝh:�Æwe$¢xÄÁÝ‹¿ZÎ˜•I¤¬ähì®b/�¼ÕK—]ý’ŠÌªuŒ4$¤AN*ÿ#Ž\o´ÙêãD|Ú'³`n§9÷Í±Ég®:­Î»F»Ýè´H§Ûo]rFè¿Ÿ^Ó~ŽÆå.“Z,„LØn‘:Os¢ZC8¯G¿ÕhXujˆ`s�*•ÆQ=ÈÅF	ÿzNë�Vôÿ@+ú5F“ºø+‰VU¨1’C†ùÑ,Çu*¿sR<Û�Oë5Ì[qí‡/�ó�§¨Îmì��”gÜŸú}ØF    5   ˆl–Ãa¾”Ò~êqAãoÜJbÑ¿�þB gdlm4ÈwùÏƒh¹ÎÀË      1280
  5   ˆl–Ãa¾”Ò~êqAà_¸ ©‹Fÿ�þB gq’06BÏÐƒh¹ÏÁÌ      1
  8   ˆl–äY>”J_)%+€zà@¦-ÿ�þ_zGÖl²È	^$Ž8ð?ŸÑ„eð‰ÿÐÈÂÍ ?÷     # helpers.py
import html.entities
import re
import typing

from . import __diag__
from .core import *
from .util import _bslash, _flatten, _escape_regex_range_chars


#
# global helpers
#
def delimited_list(
    expr: Union[str, ParserElement],
    delim: Union[str, ParserElement] = ",",
    combine: bool = False,
    min: typing.Optional[int] = None,
    max: typing.Optional[int] = None,
    *,
    allow_trailing_delim: bool = False,
) -> ParserElement:
    """Helper to define a delimited list of expressions - the delimiter
    defaults to ','. By default, the list elements and delimiters can
    have intervening whitespace, and comments, but this can be
    overridden by passing ``combine=True`` in the constructor. If
    ``combine`` is set to ``True``, the matching tokens are
    returned as a single token string, with the delimiters included;
    otherwise, the matching tokens are returned as a list of tokens,
    with the delimiters suppressed.

    If ``allow_trailing_delim`` is set to True, then the list may end with
    a delimiter.

    Example::

        delimited_list(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc']
        delimited_list(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
    """
    if isinstance(expr, str_type):
        expr = ParserElement._literalStringClass(expr)

    dlName = "{expr} [{delim} {expr}]...{end}".format(
        expr=str(expr.copy().streamline()),
        delim=str(delim),
        end=" [{}]".format(str(delim)) if allow_trailing_delim else "",
    )

    if not combine:
        delim = Suppress(delim)

    if min is not None:
        if min < 1:
            raise ValueError("min must be greater than 0")
        min -= 1
    if max is not None:
        if min is not None and max <= min:
            raise ValueError("max must be greater than, or equal to min")
        max -= 1
    delimited_list_expr = expr + (delim + expr)[min, max]

    if allow_trailing_delim:
        delimited_list_expr += Opt(delim)

    if combine:
        return Combine(delimited_list_expr).set_name(dlName)
 