forked from kenkeiras/org-rw
Support get_raw_contents of list groups.
This commit is contained in:
parent
440f0bd4b7
commit
28ddd3e44f
@ -7,7 +7,6 @@ class DrawerNode:
|
|||||||
|
|
||||||
|
|
||||||
class PropertyDrawerNode(DrawerNode):
|
class PropertyDrawerNode(DrawerNode):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Properties: {}>".format(len(self.children))
|
return "<Properties: {}>".format(len(self.children))
|
||||||
|
|
||||||
@ -38,6 +37,9 @@ class ListGroupNode:
|
|||||||
def append(self, child):
|
def append(self, child):
|
||||||
self.children.append(child)
|
self.children.append(child)
|
||||||
|
|
||||||
|
def get_raw(self):
|
||||||
|
return '\n'.join([c.get_raw() for c in self.children])
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<List: {}>".format(len(self.children))
|
return "<List: {}>".format(len(self.children))
|
||||||
|
|
||||||
@ -64,6 +66,9 @@ class Text:
|
|||||||
def __init__(self, content):
|
def __init__(self, content):
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
||||||
|
def get_raw(self):
|
||||||
|
return ''.join(self.content.get_raw())
|
||||||
|
|
||||||
|
|
||||||
class ListItem:
|
class ListItem:
|
||||||
def __init__(self, tag, content, orig=None):
|
def __init__(self, tag, content, orig=None):
|
||||||
@ -71,6 +76,9 @@ class ListItem:
|
|||||||
self.content = content
|
self.content = content
|
||||||
self.orig = orig
|
self.orig = orig
|
||||||
|
|
||||||
|
def get_raw(self):
|
||||||
|
return get_raw_contents(self.orig)
|
||||||
|
|
||||||
|
|
||||||
class BlockNode:
|
class BlockNode:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -92,3 +100,5 @@ class CodeBlock(BlockNode):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Code: {}>".format(len(self.lines))
|
return "<Code: {}>".format(len(self.lines))
|
||||||
|
|
||||||
|
from .utils import get_raw_contents
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from .org_rw import (Bold, Code, Headline, Italic, Line, RawLine, Strike, Text,
|
from .org_rw import (Bold, Code, Headline, Italic, Line, RawLine, ListItem, Strike, Text,
|
||||||
Underlined, Verbatim)
|
Underlined, Verbatim)
|
||||||
|
|
||||||
|
from .org_rw import dump_contents
|
||||||
|
|
||||||
|
|
||||||
def get_hl_raw_contents(doc: Headline) -> str:
|
def get_hl_raw_contents(doc: Headline) -> str:
|
||||||
lines = []
|
lines = []
|
||||||
@ -36,6 +38,8 @@ def get_raw_contents(doc) -> str:
|
|||||||
return "".join([get_raw_contents(chunk) for chunk in doc])
|
return "".join([get_raw_contents(chunk) for chunk in doc])
|
||||||
if isinstance(doc, (Text, Bold, Code, Italic, Strike, Underlined, Verbatim)):
|
if isinstance(doc, (Text, Bold, Code, Italic, Strike, Underlined, Verbatim)):
|
||||||
return doc.get_raw()
|
return doc.get_raw()
|
||||||
|
if isinstance(doc, ListItem):
|
||||||
|
return dump_contents(doc)[1]
|
||||||
print("Unhandled type: " + str(doc))
|
print("Unhandled type: " + str(doc))
|
||||||
raise NotImplementedError("Unhandled type: " + str(doc))
|
raise NotImplementedError("Unhandled type: " + str(doc))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user