3 module.exports = setextHeading;
11 var MAX_HEADING_INDENT = 3;
13 /* Map of characters which can be used to mark setext
14 * headers, mapping to their corresponding depth. */
15 var SETEXT_MARKERS = {};
17 SETEXT_MARKERS[C_EQUALS] = 1;
18 SETEXT_MARKERS[C_DASH] = 2;
20 function setextHeading(eat, value, silent) {
23 var length = value.length;
32 /* Eat initial indentation. */
33 while (++index < length) {
34 character = value.charAt(index);
36 if (character !== C_SPACE || index >= MAX_HEADING_INDENT) {
41 subvalue += character;
48 while (++index < length) {
49 character = value.charAt(index);
51 if (character === C_NEWLINE) {
56 if (character === C_SPACE || character === C_TAB) {
59 content += queue + character;
64 now.column += subvalue.length;
65 now.offset += subvalue.length;
66 subvalue += content + queue;
68 /* Ensure the content is followed by a newline and a
70 character = value.charAt(++index);
71 marker = value.charAt(++index);
73 if (character !== C_NEWLINE || !SETEXT_MARKERS[marker]) {
77 subvalue += character;
79 /* Eat Setext-line. */
81 depth = SETEXT_MARKERS[marker];
83 while (++index < length) {
84 character = value.charAt(index);
86 if (character !== marker) {
87 if (character !== C_NEWLINE) {
102 return eat(subvalue + queue)({
105 children: self.tokenizeInline(content, now)