Skip to content

Commit 02d30bc

Browse files
committed
update
Signed-off-by: George Lemon <georgelemon@protonmail.com>
1 parent 3cd4c59 commit 02d30bc

File tree

6 files changed

+297
-279
lines changed

6 files changed

+297
-279
lines changed

marvdown.nimble

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ installExt = @["nim"]
1313

1414
requires "nim >= 2.0.0"
1515
requires "kapsis#head"
16-
requires "denim#head"
1716
requires "jsony#head"
1817
requires "nyml#head"
1918

src/marvdown.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ elif isMainModule:
4242
allowed: @[tagA, tagAbbr, tagB, tagBlockquote, tagBr,
4343
tagCode, tagDel, tagEm, tagH1, tagH2, tagH3, tagH4, tagH5, tagH6,
4444
tagHr, tagI, tagImg, tagLi, tagOl, tagP, tagPre, tagStrong, tagTable,
45-
tagTbody, tagTd, tagTh, tagThead, tagTr, tagUl],
45+
tagTbody, tagTd, tagTh, tagThead, tagTr, tagUl, tagDiv],
4646
enableAnchors: v.has("--optAnchors")
4747
)
4848
t = cpuTime() # start timer after reading file

src/marvdown/ast.nim

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,38 @@ type
9696
## Child nodes (for container nodes)
9797
line*: int
9898
## Line number in the source markdown
99-
wsno*: int
100-
## Whitespace count before the token (for indentation)
10199

102100
proc debugEcho*(n: MarkdownNode) =
103-
echo toJson(n)
101+
echo toJson(n)
102+
103+
proc newText*(text: string, ln: int): MarkdownNode =
104+
result = MarkdownNode(kind: mdkText)
105+
result.text = text
106+
result.line = ln
107+
108+
proc newImage*(alt, src, title: string, ln: int): MarkdownNode =
109+
result = MarkdownNode(kind: mdkImage)
110+
result.imageAlt = alt
111+
result.imageSrc = src
112+
result.imageTitle = title
113+
result.line = ln
114+
115+
proc newLink*(href, title: string, ln: int): MarkdownNode =
116+
result = MarkdownNode(kind: mdkLink, children: MarkdownNodeList())
117+
result.linkHref = href
118+
result.linkTitle = title
119+
result.line = ln
120+
121+
proc newRawHtml*(html: string, ln: int): MarkdownNode =
122+
result = MarkdownNode(kind: mdkHtml)
123+
result.html = html
124+
result.line = ln
125+
126+
proc newHeading*(level: range[1..6], ln: int): MarkdownNode =
127+
## Create a new heading node
128+
MarkdownNode(
129+
kind: mdkHeading,
130+
level: level,
131+
children: MarkdownNodeList(),
132+
line: ln
133+
)

0 commit comments

Comments
 (0)