Skip to content

Commit

Permalink
Merge pull request #912 from nature-of-code/pdf/break-code-lines
Browse files Browse the repository at this point in the history
Break the code snippet into individual lines
  • Loading branch information
jasongao97 authored Mar 12, 2024
2 parents bc8f910 + 1d277d7 commit c279736
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion magicbook/plugins/codesplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== undefined && pair.code.length >= pair.maxLines)
) {
if (pair.code.length > 0 || pair.comment.length > 0) {
Expand Down

0 comments on commit c279736

Please sign in to comment.