Compare commits
No commits in common. "9b550ed2eaf7a79f2d00b648bd03f4c5eba00107" and "3da2ab066cc5cf2dc9fa94d2b900dfe1c03ba936" have entirely different histories.
9b550ed2ea
...
3da2ab066c
@ -46,10 +46,8 @@ class Text:
|
||||
|
||||
|
||||
class ListItem:
|
||||
def __init__(self, tag, content, orig=None):
|
||||
self.tag = tag
|
||||
def __init__(self, content):
|
||||
self.content = content
|
||||
self.orig = orig
|
||||
|
||||
|
||||
class BlockNode:
|
||||
|
@ -176,37 +176,6 @@ def get_links_from_content(content):
|
||||
else:
|
||||
link_value.append(tok)
|
||||
|
||||
def text_to_dom(tokens, item):
|
||||
in_link = False
|
||||
in_description = False
|
||||
link_value = []
|
||||
link_description = []
|
||||
|
||||
contents = []
|
||||
|
||||
for tok in tokens:
|
||||
if isinstance(tok, LinkToken):
|
||||
if tok.tok_type == LinkTokenType.OPEN_LINK:
|
||||
in_link = True
|
||||
open_link_token = tok
|
||||
elif tok.tok_type == LinkTokenType.OPEN_DESCRIPTION:
|
||||
in_description = True
|
||||
elif tok.tok_type == LinkTokenType.CLOSE:
|
||||
rng = RangeInRaw(item, open_link_token, tok)
|
||||
contents.append(Link(
|
||||
"".join(link_value),
|
||||
"".join(link_description) if in_description else None,
|
||||
rng,
|
||||
))
|
||||
elif isinstance(tok, str) and in_link:
|
||||
if in_description:
|
||||
link_description.append(tok)
|
||||
else:
|
||||
link_value.append(tok)
|
||||
else:
|
||||
contents.append(tok)
|
||||
|
||||
return contents
|
||||
|
||||
def get_line(item):
|
||||
if isinstance(item, Text):
|
||||
@ -354,8 +323,7 @@ class Headline:
|
||||
print("Parent: {}\nValue: {}".format(current_node, line))
|
||||
assert type(current_node) in NON_FINISHED_GROUPS
|
||||
current_node = None
|
||||
contents = []
|
||||
tree.append(dom.Text(text_to_dom(line.contents, line)))
|
||||
tree.append(dom.Text(line))
|
||||
|
||||
elif isinstance(line, ListItem):
|
||||
if current_node is None:
|
||||
@ -373,7 +341,7 @@ class Headline:
|
||||
c
|
||||
for c in indentation_tree[-1].children
|
||||
if isinstance(c, dom.ListItem)
|
||||
][-1].orig.indentation
|
||||
][-1].content.indentation
|
||||
)
|
||||
< len(line.indentation)
|
||||
):
|
||||
@ -389,7 +357,7 @@ class Headline:
|
||||
c
|
||||
for c in indentation_tree[-1].children
|
||||
if isinstance(c, dom.ListItem)
|
||||
][-1].orig.indentation
|
||||
][-1].content.indentation
|
||||
)
|
||||
> len(line.indentation)
|
||||
):
|
||||
@ -401,7 +369,7 @@ class Headline:
|
||||
else:
|
||||
current_node = indentation_tree[-1]
|
||||
|
||||
node = dom.ListItem(line.tag, text_to_dom(line.content, line), orig=line)
|
||||
node = dom.ListItem(line)
|
||||
current_node.append(node)
|
||||
|
||||
elif (
|
||||
|
Loading…
Reference in New Issue
Block a user