Skip to content

Commit

Permalink
Create task and dependency parser
Browse files Browse the repository at this point in the history
  • Loading branch information
smy20011 committed Sep 2, 2024
1 parent d2286d2 commit a918d76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,3 @@ repos:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.378
hooks:
- id: pyright
17 changes: 6 additions & 11 deletions llmake/markdown.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import re

from dataclasses import dataclass
from re import Pattern
from mistletoe import Document
from enum import StrEnum
from itertools import takewhile
from re import Pattern

from mistletoe.block_token import Heading, token
from mistletoe.html_renderer import HtmlRenderer
from mistletoe import Document
from mistletoe.block_token import Heading
from mistletoe.span_token import Link, RawText, SpanToken, add_token, remove_token
from mistletoe.token import Token
from collections import deque


class LinkType(StrEnum):
Expand All @@ -32,7 +28,7 @@ class Task:
start: int
end: int
context: list[Context]
dependency : list[str]
dependency: list[str]


@dataclass
Expand Down Expand Up @@ -85,14 +81,13 @@ def parse_markdown(markdown: str):
tasks = []
for start, end in zip(task_lines, task_lines[1:]):
links = get_context_links(lines[start:end])
dependency = [l.target for l in links if l.context_type == LinkType.HEAD_LINK]
context = [l for l in links if l.context_type != LinkType.HEAD_LINK]
dependency = [link.target for link in links if link.context_type == LinkType.HEAD_LINK]
context = [link for link in links if link.context_type != LinkType.HEAD_LINK]
if not dependency:
dependency = [t.name for t in tasks]
name = lines[start][2:].lstrip()
tasks.append(Task(name, start, end, context, dependency))


return Project(lines, tasks)


Expand Down

0 comments on commit a918d76

Please sign in to comment.