Compare commits
No commits in common. "b70baa0eb8e8238b0e4f8981b83522391ad10321" and "5019b44dd50f080ff499f8c74c6bef5bc6d537d8" have entirely different histories.
b70baa0eb8
...
5019b44dd5
@ -882,12 +882,6 @@ class Headline:
|
||||
sections = []
|
||||
arguments = None
|
||||
|
||||
names_by_line = {}
|
||||
for kw in self.keywords:
|
||||
if kw.key == 'NAME':
|
||||
names_by_line[kw.linenum] = kw.value
|
||||
|
||||
name = None
|
||||
for delimiter in self.delimiters:
|
||||
if (
|
||||
delimiter.delimiter_type == DelimiterLineType.BEGIN_BLOCK
|
||||
@ -896,12 +890,6 @@ class Headline:
|
||||
line_start = delimiter.linenum
|
||||
inside_code = True
|
||||
arguments = delimiter.arguments
|
||||
|
||||
name_line = line_start - 1
|
||||
if name_line in names_by_line:
|
||||
name = names_by_line[name_line]
|
||||
else:
|
||||
name = None
|
||||
elif (
|
||||
delimiter.delimiter_type == DelimiterLineType.END_BLOCK
|
||||
and delimiter.type_data.subtype.lower() == "src"
|
||||
@ -972,6 +960,7 @@ class Headline:
|
||||
|
||||
results = []
|
||||
for section in sections:
|
||||
name = None
|
||||
content = section["content"]
|
||||
code_result = section.get("result", None)
|
||||
arguments = section.get("arguments", None)
|
||||
@ -2349,7 +2338,7 @@ class OrgDoc:
|
||||
yield hl
|
||||
|
||||
def get_code_snippets(self):
|
||||
for headline in self.getAllHeadlines():
|
||||
for headline in self.headlines:
|
||||
yield from headline.get_code_snippets()
|
||||
|
||||
# Writing
|
||||
|
@ -9,7 +9,6 @@
|
||||
:CREATED: [2020-01-01 Wed 01:01]
|
||||
:END:
|
||||
|
||||
#+NAME: first-code-name
|
||||
#+BEGIN_SRC shell :results verbatim
|
||||
echo "This is a test"
|
||||
echo "with two lines"
|
||||
|
@ -480,10 +480,6 @@ class TestSerde(unittest.TestCase):
|
||||
|
||||
snippets = list(doc.get_code_snippets())
|
||||
self.assertEqual(len(snippets), 3)
|
||||
self.assertEqual(
|
||||
snippets[0].name,
|
||||
'first-code-name'
|
||||
)
|
||||
self.assertEqual(
|
||||
snippets[0].content,
|
||||
'echo "This is a test"\n'
|
||||
@ -498,10 +494,6 @@ class TestSerde(unittest.TestCase):
|
||||
"This is a test\n" + "with two lines",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
snippets[1].name,
|
||||
None
|
||||
)
|
||||
self.assertEqual(
|
||||
snippets[1].content,
|
||||
'echo "This is another test"\n'
|
||||
@ -512,10 +504,6 @@ class TestSerde(unittest.TestCase):
|
||||
snippets[1].result, "This is another test\n" + "with two lines too"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
snippets[2].name,
|
||||
None
|
||||
)
|
||||
self.assertEqual(
|
||||
snippets[2].content,
|
||||
"/* This code has to be escaped to\n"
|
||||
|
Loading…
Reference in New Issue
Block a user