mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 10:43:17 +02:00
Client: links and images open, line breaks like the web, directory notes setting
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
55ee8e2f23
commit
0513d94c6a
8 files changed
+134
-23
No files matched your search
+13
-3
@@ -22,6 +22,7 @@ from Core import Palette
|
||||
OpenOrClose = re.compile(r"^---\s*$")
|
||||
PropertyLine = re.compile(r"^([^:\s][^:]*?)\s*:\s*(.*)$")
|
||||
TaskLine = re.compile(r"^(\s*(?:[-*+]|\d+[.)])\s+)\[( |x|X)\]")
|
||||
ImageLine = re.compile(r"^\s*!\[([^\]]*)\]\(<?([^)>]+?)>?\)\s*$")
|
||||
BooleanValue = re.compile(r"^(true|false)$", re.IGNORECASE)
|
||||
Quoted = re.compile(r"""^(["']).*\1$""")
|
||||
IntegerValue = re.compile(r"^[+-]?\d+$")
|
||||
@@ -169,9 +170,10 @@ def PropertiesView(Found: Parsed, FontSize: int, MakeMarkdown: Callable[[str], f
|
||||
|
||||
|
||||
def WithCheckboxes(Text: str, FirstLine: int, MakeMarkdown: Callable[[str], ft.Control],
|
||||
Toggle: OnToggle, FontSize: int, LineMap: Optional[list[Optional[int]]] = None) -> list[ft.Control]:
|
||||
"""Markdown with its task lines as real checkboxes: the lines between
|
||||
them render as usual. FirstLine is where Text starts in the note; LineMap
|
||||
Toggle: OnToggle, FontSize: int, LineMap: Optional[list[Optional[int]]] = None,
|
||||
MakeImage: Optional[Callable[[str, str], Optional[ft.Control]]] = None) -> list[ft.Control]:
|
||||
"""Markdown with its task lines as real checkboxes, and lines that are
|
||||
only an image as the image (MakeImage): the lines between render as usual. FirstLine is where Text starts in the note; LineMap
|
||||
(Variables.Substitute) says which of its lines each shown line is, None
|
||||
for one from a variable's result (its checkbox can't be ticked)."""
|
||||
Controls: list[ft.Control] = []
|
||||
@@ -186,6 +188,14 @@ def WithCheckboxes(Text: str, FirstLine: int, MakeMarkdown: Callable[[str], ft.C
|
||||
for Offset, Line in enumerate(Text.split("\n")):
|
||||
if re.match(r"^ {0,3}(`{3,}|~{3,})", Line):
|
||||
InFence = not InFence
|
||||
# A line that's only an image: shown and clickable (MakeImage), as
|
||||
# Flet's Markdown has no click for images.
|
||||
Picture = ImageLine.match(Line) if MakeImage is not None and not InFence else None
|
||||
Shown = MakeImage(Picture.group(2), Picture.group(1)) if Picture else None
|
||||
if Shown is not None:
|
||||
Flush()
|
||||
Controls.append(Shown)
|
||||
continue
|
||||
Task = None if InFence else TaskLine.match(Line)
|
||||
if Task is None:
|
||||
Pending.append(Line)
|
||||
|
||||
Reference in new issue
Block a user