Browse Source

Add position and size for paragraph

pull/204/head
Samy Pessé 9 years ago
parent
commit
9514121052
  1. 9
      lib/rules_block/paragraph.js

9
lib/rules_block/paragraph.js

@ -7,7 +7,8 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
var content, terminate, i, l, token,
nextLine = startLine + 1,
terminatorRules = state.md.block.ruler.getRules('paragraph'),
endLine = state.lineMax;
endLine = state.lineMax,
pos = state.bMarks[startLine];
// jump line-by-line until empty one or EOF
for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
@ -35,13 +36,19 @@ module.exports = function paragraph(state, startLine/*, endLine*/) {
token = state.push('paragraph_open', 'p', 1);
token.map = [ startLine, state.line ];
token.position = pos;
token.size = 0;
token = state.push('inline', '', 0);
token.content = content;
token.map = [ startLine, state.line ];
token.children = [];
token.position = pos;
token.size = content.length;
token = state.push('paragraph_close', 'p', -1);
token.size = 0;
token.position = content.length + pos;
return true;
};

Loading…
Cancel
Save