Example #1
0
def test_input_line_markdown_various():
    inp = "**bold* bold *bital etc* bold **bold** * *italic*"
    formatted = Formatted.from_input_line(inp)
    assert "<strong>bold* bold </strong>" \
           "<em><strong>bital etc</strong></em><strong> bold **bold</strong>" \
           " * <em>italic</em>" \
           == formatted.to_html()
Example #2
0
def matrix_me_command_cb(data, buffer, args):
    for server in SERVERS.values():
        if buffer in server.buffers.values():

            if not server.connected:
                message = ("{prefix}matrix: you are not connected to "
                           "the server").format(prefix=W.prefix("error"))
                W.prnt(server.server_buffer, message)
                return W.WEECHAT_RC_ERROR

            room_id = key_from_value(server.buffers, buffer)

            if not args:
                return W.WEECHAT_RC_OK

            formatted_data = Formatted.from_input_line(args)
            message = MatrixEmoteMessage(server.client,
                                         room_id=room_id,
                                         formatted_message=formatted_data)

            server.send_or_queue(message)

            return W.WEECHAT_RC_OK

        elif buffer == server.server_buffer:
            message = ("{prefix}matrix: command \"me\" must be "
                       "executed on a Matrix channel buffer").format(
                           prefix=W.prefix("error"))
            W.prnt("", message)
            return W.WEECHAT_RC_OK
Example #3
0
def test_normalize_spaces_in_inline_code():
    """Normalize spaces in inline code blocks.

    Strips leading and trailing spaces and compress consecutive infix spaces.
    """
    valid_result = '\x1b[0m* a *\x1b[00m'

    formatted = Formatted.from_input_line('`   *    a   *   `')
    assert formatted.to_weechat() == valid_result
Example #4
0
def test_input_line_markdown_bold():
    formatted = Formatted.from_input_line("**Hello**")
    assert "\x1b[01mHello\x1b[021m" == formatted.to_weechat()
    assert "<strong>Hello</strong>" == formatted.to_html()
Example #5
0
def test_input_line_markdown_emph():
    formatted = Formatted.from_input_line("*Hello*")
    assert "\x1b[03mHello\x1b[023m" == formatted.to_weechat()
    assert "<em>Hello</em>" == formatted.to_html()
Example #6
0
def test_input_line_underline():
    formatted = Formatted.from_input_line("\x1FHello")
    assert "\x1b[04mHello\x1b[024m" == formatted.to_weechat()
    assert "<u>Hello</u>" == formatted.to_html()
Example #7
0
def test_input_line_color():
    formatted = Formatted.from_input_line("\x0304Hello")
    assert "\x1b[038;5;9mHello\x1b[039m" == formatted.to_weechat()
    assert "<font data-mx-color=#ff0000>Hello</font>" == formatted.to_html()
Example #8
0
def test_unpaired_prefix_asterisk_without_space_is_literal(text):
   """An unpaired asterisk at the beginning of the line, without a space
   after it, is considered literal.
   """
   formatted = Formatted.from_input_line(text)
   assert text.strip() == formatted.to_weechat()
Example #9
0
def test_conversion():
    formatted = Formatted.from_input_line("*Hello*")
    formatted2 = Formatted.from_html(formatted.to_html())
    formatted.to_weechat() == formatted2.to_weechat()
Example #10
0
 def convert(s): return Formatted.from_input_line(s).to_html()
 assert "pre <em>italic* ital</em> norm" == convert("pre *italic\\* ital* norm")
Example #11
0
def test_input_line_markdown_various2():
    inp = "norm** `code **code *code` norm `norm"
    formatted = Formatted.from_input_line(inp)
    assert "norm** <code>code **code *code</code> norm `norm" \
           == formatted.to_html()
Example #12
0
 def convert(s):
     return Formatted.from_input_line(s).to_html()