mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-05-17 21:30:25 -04:00
Handle first-char escape properly. Fixes #67.
This commit is contained in:
parent
c35f6418a2
commit
b6e4d8441a
1 changed files with 9 additions and 4 deletions
|
@ -73,8 +73,9 @@ def markup_to_attrmaps(markup, url_delegate = None):
|
||||||
|
|
||||||
return attrmaps
|
return attrmaps
|
||||||
|
|
||||||
|
import RNS
|
||||||
def parse_line(line, state, url_delegate):
|
def parse_line(line, state, url_delegate):
|
||||||
|
pre_escape = False
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
first_char = line[0]
|
first_char = line[0]
|
||||||
|
|
||||||
|
@ -88,6 +89,7 @@ def parse_line(line, state, url_delegate):
|
||||||
# Check if the command is an escape
|
# Check if the command is an escape
|
||||||
if first_char == "\\":
|
if first_char == "\\":
|
||||||
line = line[1:]
|
line = line[1:]
|
||||||
|
pre_escape = True
|
||||||
|
|
||||||
# Check for comments
|
# Check for comments
|
||||||
elif first_char == "#":
|
elif first_char == "#":
|
||||||
|
@ -142,7 +144,7 @@ def parse_line(line, state, url_delegate):
|
||||||
else:
|
else:
|
||||||
return [urwid.Padding(urwid.Divider(divider_char), left=left_indent(state), right=right_indent(state))]
|
return [urwid.Padding(urwid.Divider(divider_char), left=left_indent(state), right=right_indent(state))]
|
||||||
|
|
||||||
output = make_output(state, line, url_delegate)
|
output = make_output(state, line, url_delegate, pre_escape)
|
||||||
|
|
||||||
if output != None:
|
if output != None:
|
||||||
text_only = True
|
text_only = True
|
||||||
|
@ -425,7 +427,7 @@ def make_style(state):
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def make_output(state, line, url_delegate):
|
def make_output(state, line, url_delegate, pre_escape=False):
|
||||||
output = []
|
output = []
|
||||||
if state["literal"]:
|
if state["literal"]:
|
||||||
if line == "\\`=":
|
if line == "\\`=":
|
||||||
|
@ -434,8 +436,10 @@ def make_output(state, line, url_delegate):
|
||||||
else:
|
else:
|
||||||
part = ""
|
part = ""
|
||||||
mode = "text"
|
mode = "text"
|
||||||
escape = False
|
escape = pre_escape
|
||||||
skip = 0
|
skip = 0
|
||||||
|
|
||||||
|
RNS.log(f"Line [ESC {escape}] [MODE {mode}: {line}")
|
||||||
for i in range(0, len(line)):
|
for i in range(0, len(line)):
|
||||||
c = line[i]
|
c = line[i]
|
||||||
if skip > 0:
|
if skip > 0:
|
||||||
|
@ -666,6 +670,7 @@ def make_output(state, line, url_delegate):
|
||||||
part = ""
|
part = ""
|
||||||
else:
|
else:
|
||||||
part += c
|
part += c
|
||||||
|
escape = False
|
||||||
|
|
||||||
if i == len(line)-1:
|
if i == len(line)-1:
|
||||||
if len(part) > 0:
|
if len(part) > 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue