Token ProcessCodeSpan()
{
int start = Position;
// Count leading ticks
int tickcount = 0;
while (SkipChar('`'))
{
tickcount++;
}
// Skip optional leading space...
SkipWhitespace();
// End?
if (Eof)
return CreateToken(TokenType.Text, start, Position - start);
int startofcode = Position;
// Find closing ticks
if (!Find(Substring(start, tickcount)))
return CreateToken(TokenType.Text, start, Position - start);
// Save end position before backing up over trailing whitespace
int endpos = Position + tickcount;
while (char.IsWhiteSpace(CharAtOffset(-1)))
SkipForward(-1);
// Create the token, move back to the end and we're done
var ret = CreateToken(TokenType.code_span, startofcode, Position - startofcode);
Position = endpos;
return ret;
}