roundabout,
created on Sunday, 31 March 2024, 09:06:00 (1711875960),
received on Wednesday, 31 July 2024, 06:54:43 (1722408883)
Author identity: vlad <vlad.muntoiu@gmail.com>
362293afd8b552642a5ad1cbcb3888202aab96bf
markdown.py
@@ -302,7 +302,6 @@ def tokenise(source):
i = 0
while i < len(lines):
line = lines[i]
print(i, line)
if not line.strip():
# Void block
@@ -366,6 +365,13 @@ def tokenise(source):
i += 1 # prevent a new block from beginning with the closing fence
current_block = CodeBlock(content, language=language)
elif only_chars(lines[i+1].strip(), "=") or only_chars(lines[i+1].strip(), "-"):
tokens.append(current_block)
content = line.strip()
current_block = Heading(content, 1 if lines[i+1].startswith("=") else 2)
i += 2
else:
if not isinstance(current_block, Paragraph):
# Create a paragraph, if there is no other specifier
@@ -425,29 +431,23 @@ if __name__ == '__main__':
# Generate an AST from a markdown file
ast = tokenise(
r"""
> This is a blockquote
> that spans multiple lines
> and contains a list:
>
> - Item 1
> - Item 2
> - Item 3
> - Subitem 1
> - Subitem 2
>
> And some more text
>
Does it also support that bullet?
Or continuation lines?
> What about a code block?
> ```python
> print("Hello, world!")
> ```
* * *
* Alternatively, this is a list
* That uses asterisks
Hello World
===========
Lorem
ipsum
dolor
sit
amet.
1. Test
2. Test
3. Test
* Lorem
ipsum
* Test
* Test
"""
)
# for i in ast: