@@ -272,15 +272,38 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
272272 state . parentType = oldParentType ;
273273 lines [ 1 ] = state . line ;
274274
275+ let totalLineOffset = 0 ;
275276 // Restore original tShift; this might not be necessary since the parser
276277 // has already been here, but just to make sure we can do that.
277278 for ( i = 0 ; i < oldTShift . length ; i ++ ) {
278- state . bMarks [ i + startLine ] = oldBMarks [ i ] ;
279- state . tShift [ i + startLine ] = oldTShift [ i ] ;
280- state . sCount [ i + startLine ] = oldSCount [ i ] ;
281- state . bsCount [ i + startLine ] = oldBSCount [ i ] ;
279+ const lineNumber = i + startLine ;
280+ if ( state . lineOffsets [ lineNumber ] === null ) {
281+ state . lineOffsets [ lineNumber ] = totalLineOffset ;
282+ if ( isNotEmptyLine ( state , lineNumber ) ) {
283+ totalLineOffset += calcLineOffset ( state , lineNumber ) ;
284+ } else {
285+ totalLineOffset = 0 ;
286+ }
287+ }
288+
289+ state . bMarks [ lineNumber ] = oldBMarks [ i ] ;
290+ state . tShift [ lineNumber ] = oldTShift [ i ] ;
291+ state . sCount [ lineNumber ] = oldSCount [ i ] ;
292+ state . bsCount [ lineNumber ] = oldBSCount [ i ] ;
282293 }
283294 state . blkIndent = oldIndent ;
284295
285296 return true ;
286297} ;
298+
299+ function calcLineOffset ( state , lineNumber ) {
300+ const previousLineEnd = state . eMarks [ lineNumber - 1 ] + 1 || 0 ;
301+ return state . bMarks [ lineNumber ] - previousLineEnd ;
302+ }
303+
304+ function isNotEmptyLine ( state , lineNumber ) {
305+ return (
306+ state . bMarks [ lineNumber ] + state . tShift [ lineNumber ] <
307+ state . eMarks [ lineNumber ]
308+ )
309+ }
0 commit comments