Browse Source

Avoid shadow copy for inline containers

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
6db093844b
  1. 3
      lib/rules_block/heading.js
  2. 3
      lib/rules_block/lheading.js
  3. 3
      lib/rules_block/paragraph.js
  4. 7
      lib/rules_block/table.js

3
lib/rules_block/heading.js

@ -51,7 +51,8 @@ module.exports = function heading(state, startLine, endLine, silent) {
state.tokens.push({ state.tokens.push({
type: 'inline', type: 'inline',
content: state.src.slice(pos, max).trim(), content: state.src.slice(pos, max).trim(),
level: state.level + 1 level: state.level + 1,
children: []
}); });
} }
state.tokens.push({ type: 'heading_close', hLevel: level, level: state.level }); state.tokens.push({ type: 'heading_close', hLevel: level, level: state.level });

3
lib/rules_block/lheading.js

@ -42,7 +42,8 @@ module.exports = function lheading(state, startLine, endLine, silent) {
state.tokens.push({ state.tokens.push({
type: 'inline', type: 'inline',
content: state.src.slice(pos, state.eMarks[startLine]).trim(), content: state.src.slice(pos, state.eMarks[startLine]).trim(),
level: state.level + 1 level: state.level + 1,
children: []
}); });
state.tokens.push({ state.tokens.push({
type: 'heading_close', type: 'heading_close',

3
lib/rules_block/paragraph.js

@ -43,7 +43,8 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
state.tokens.push({ state.tokens.push({
type: 'inline', type: 'inline',
content: content, content: content,
level: state.level + 1 level: state.level + 1,
children: []
}); });
state.tokens.push({ type: 'paragraph_close', level: state.level }); state.tokens.push({ type: 'paragraph_close', level: state.level });
} }

7
lib/rules_block/table.js

@ -64,7 +64,8 @@ module.exports = function table(state, startLine, endLine, silent) {
state.tokens.push({ state.tokens.push({
type: 'inline', type: 'inline',
content: rows[i].trim(), content: rows[i].trim(),
level: state.level level: state.level,
children: []
}); });
state.tokens.push({ type: 'th_close', level: --state.level }); state.tokens.push({ type: 'th_close', level: --state.level });
} }
@ -85,7 +86,9 @@ module.exports = function table(state, startLine, endLine, silent) {
state.tokens.push({ type: 'td_open', align: aligns[i], level: state.level++ }); state.tokens.push({ type: 'td_open', align: aligns[i], level: state.level++ });
state.tokens.push({ state.tokens.push({
type: 'inline', type: 'inline',
content: rows[i].replace(/^\|? *| *\|?$/g, '') content: rows[i].replace(/^\|? *| *\|?$/g, ''),
level: state.level,
children: []
}); });
state.tokens.push({ type: 'td_close', level: --state.level }); state.tokens.push({ type: 'td_close', level: --state.level });
} }

Loading…
Cancel
Save