diff --git a/NEWS.md b/NEWS.md index e03c94a..4521672 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,18 @@ # Algorithmic NEWS +## v1.0.7 + +> ![INFO] +> @nonl4331 fixed an issue with `LineComment` not working with certain input types (#27, #28). +> +> LineComment statements similar to the instances below will now render correctly. +> ```typ +> #{ +> LineComment([Initialize hashmap], [Count instances]) +> LineComment([$c += a-b$], [Sum of differences]) +> } +> ``` + ## v1.0.6 > ![INFO] diff --git a/algorithmic.typ b/algorithmic.typ index fd42ba7..4c62b2a 100644 --- a/algorithmic.typ +++ b/algorithmic.typ @@ -163,7 +163,10 @@ #let Call(..args) = (CallInline(..args),) #let Fn(..args) = (FnInline(..args),) #let Comment(c) = (CommentInline(c),) -#let LineComment(l, c) = ([#l.first()#h(1fr)#CommentInline(c)], ..l.slice(1)) +#let LineComment(l, c) = { + let l = arraify(l).flatten() + ([#l.first()#h(1fr)#CommentInline(c)], ..l.slice(1)) +} // Control flow #let If = iflike.with(kw1: "if", kw2: "then", kw3: "end") diff --git a/tests/linecomment/ref/1.png b/tests/linecomment/ref/1.png index 282bdcd..a4a5a5d 100644 Binary files a/tests/linecomment/ref/1.png and b/tests/linecomment/ref/1.png differ diff --git a/tests/linecomment/test.typ b/tests/linecomment/test.typ index 850fbfe..064a4ed 100644 --- a/tests/linecomment/test.typ +++ b/tests/linecomment/test.typ @@ -1,7 +1,15 @@ #import "../../algorithmic.typ" #import algorithmic: algorithm -#set page(margin: (left: .1cm, top: .1cm, bottom: .1cm), width: 6cm, height: auto) +#set page(margin: (left: .1cm, top: .1cm, bottom: .1cm), width: 8cm, height: auto) #algorithm({ import algorithmic: * LineComment(Assign[a][1], [Initialize $a$ to 1]) + LineComment([Initialize hashmap], [Count instances]) + LineComment(Break, [Early exit]) + LineComment([$c += a-b$], [Sum of differences]) + LineComment(IfElseChain([condition], {Line[Test]}), [It's just amazing]) + LineComment([], [blank]) + LineComment(While([stuff], {Line[Another test]}), [foo]) + LineComment(Function("add", ($a$, $b$), {Assign[c][$a+b$]}), [bar]) + LineComment(LineComment([nested], [inner]), [outer]) })