mirror of
https://github.com/nature-of-code/noc-book-2
synced 2024-11-16 07:47:48 +01:00
Break the code snippet into individual lines
This commit is contained in:
parent
be4c84f06b
commit
f5f9e3ae0f
1 changed files with 3 additions and 1 deletions
|
@ -43,14 +43,16 @@ Plugin.prototype = {
|
|||
for (let line of lines) {
|
||||
const currentIndent = this.countIndent(line);
|
||||
// Closing a pair:
|
||||
// - when there is no comment, but code
|
||||
// - when another comment (not right after the last comment) appear
|
||||
// - when the indentation goes `backward`
|
||||
// - when a blank line appear
|
||||
// - when the custom max line number is achieved
|
||||
if (
|
||||
(pair.comment.length === 0 && pair.code.length > 0) ||
|
||||
(this.isComment(line) && pair.code.length > 0) ||
|
||||
(!pair.maxLines && currentIndent < pair.indent) ||
|
||||
(!pair.maxLines && line === '' && pair.comment.length > 0) ||
|
||||
(!pair.maxLines && line === '') ||
|
||||
(!!pair.maxLines && pair.code.length >= pair.maxLines)
|
||||
) {
|
||||
if (pair.code.length > 0 || pair.comment.length > 0) {
|
||||
|
|
Loading…
Reference in a new issue