highmark-markdown 0.0.406 → 0.0.407

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,12 +11,6 @@ import { replaceSpacesWithHyphens, removedLeadingWhitespace, removeNonAlphabetic
11
11
  const { last } = arrayUtilities;
12
12
 
13
13
  export default class HeadingMarkdownNode extends MarkdownNode {
14
- lines(context) {
15
- const { lines } = this.constructor;
16
-
17
- return lines;
18
- }
19
-
20
14
  getDepth() {
21
15
  const { depth } = this.constructor;
22
16
 
@@ -109,19 +109,26 @@ class MarkdownNode extends NonTerminalNode {
109
109
  }
110
110
 
111
111
  lines(context) {
112
- const childNodes = this.getChildNodes(),
113
- lines = childNodes.reduce((lines, childNode) => {
114
- const childNodeMarkdownNode = (childNode instanceof MarkdownNode);
112
+ let lines;
115
113
 
116
- if (childNodeMarkdownNode) {
117
- const markdownNode = childNode, ///
118
- markdownNodeLines = markdownNode.lines(context);
114
+ ({ lines = null } = this.constructor);
119
115
 
120
- lines += markdownNodeLines;
121
- }
116
+ if (lines === null) {
117
+ const childNodes = this.getChildNodes();
122
118
 
123
- return lines;
124
- }, 0);
119
+ lines = childNodes.reduce((lines, childNode) => {
120
+ const childNodeMarkdownNode = (childNode instanceof MarkdownNode);
121
+
122
+ if (childNodeMarkdownNode) {
123
+ const markdownNode = childNode, ///
124
+ markdownNodeLines = markdownNode.lines(context);
125
+
126
+ lines += markdownNodeLines;
127
+ }
128
+
129
+ return lines;
130
+ }, 0);
131
+ }
125
132
 
126
133
  return lines;
127
134
  }