Skip to content

Commit 6675833

Browse files
committed
Newlines after code blocks should remain
1 parent 080e320 commit 6675833

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/parser.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ fn parse_items(input: Vec<LexItem>) -> Result<Vec<GrammarItem>, ParseError> {
157157
params,
158158
tag: content.into(),
159159
});
160+
161+
if content == "endcode" {
162+
grammar_items.push(GrammarItem::Text("".into()));
163+
}
160164
}
161165
_ => {}
162166
}
@@ -330,6 +334,7 @@ mod test {
330334
params: vec![],
331335
tag: "endcode".into(),
332336
},
337+
GrammarItem::Text("".into())
333338
]
334339
)
335340
}
@@ -352,6 +357,36 @@ mod test {
352357
params: vec![],
353358
tag: "endcode".into(),
354359
},
360+
GrammarItem::Text("".into())
361+
]
362+
)
363+
}
364+
365+
#[test]
366+
pub fn code_with_args() {
367+
let result = parse("@code\nfn main() {}\n@endcode\n\n@param[in] a - a".into()).unwrap();
368+
369+
assert_eq!(
370+
result,
371+
vec![
372+
GrammarItem::Notation {
373+
meta: vec![],
374+
params: vec![],
375+
tag: "code".into(),
376+
},
377+
GrammarItem::Text("\nfn main() {}\n".into()),
378+
GrammarItem::Notation {
379+
meta: vec![],
380+
params: vec![],
381+
tag: "endcode".into(),
382+
},
383+
GrammarItem::Text("\n\n".into()),
384+
GrammarItem::Notation {
385+
meta: vec!["in".into()],
386+
params: vec!["a".into()],
387+
tag: "param".into()
388+
},
389+
GrammarItem::Text(" - a".into())
355390
]
356391
)
357392
}

0 commit comments

Comments
 (0)