before:=block.PrecendingCharacter()// ScanDelimiter needs this for shady left vs. right delimiter reasons. Who delimits the delimiters?
restOfLine,segment:=block.PeekLine()// Gets the rest of the line (starting at the current parser cursor index), and the segment representing the indices in the source text.
delimiter:=parser.ScanDelimiter(restOfLine,before,2,spoilerDelimiterParser{})// Scans a consecutive run of the trigger character. Returns a delimiter node tracking which character that was, how many of it there were, etc. We do 2 here because we want ~~spoilers~~.
ifdelimiter==nil{
// I guess we only saw one ~ :)
returnnil
}
delimiter.Segment=segment.WithStop(segment.Start+delimiter.OriginalLength)// The delimiter needs to know exactly what source indices it corresponds to.
block.Advance(delimiter.OriginalLength)// Advance the parser past the delimiter.
pc.PushDelimiter(delimiter)// Push the delimiter onto the stack (either opening or closing; both are handled the same way as far as this method is concerned).