public void ProcessChar(char input, ParserStateMachine sm) { if (char.IsDigit(input)) { sm.NextState = new OLState(); return; } switch (input) { case '#': sm.NextState = new Header1State(); break; case '`': sm.NextState = new CodeState(); break; //case '*': //case '+': //case '-': // sm.NextState = new ULState(); // break; case ' ': case '\n': case '\r': break; default: sm.NextState = new ParagraphState(); sm.NextState.ProcessChar(input, sm); break; } }
public void ProcessChar(char input, ParserStateMachine sm) { if (!ShouldIgnoreChar(input)) { this.OnHeaderComplete(input, sm); this.header.Append(input); } }
private void ChangeState(char input, ParserStateMachine sm) { var newListItemDetected = input.Equals('@'); if (!this.orderedList.SubElements.Any() || newListItemDetected) { sm.NextState = new ListItemState(this); } }
protected void OnHeaderComplete(char input, ParserStateMachine sm) { if (input.Equals('\n')) { this.AddHeader(sm); sm.NextState = new EntryState(); } }
private void OnListCompleted(char input, ParserStateMachine sm) { var isListCompleted = input.Equals('&'); if (isListCompleted) { sm.MdDoc.AddOrderedList(this.orderedList); sm.NextState = new EntryState(); } }
private void OnCodeCompleted(char input, ParserStateMachine sm) { if (this.IsElemCompleted(input)) { this.AddLineTerminators(input); sm.MdDoc.AddCode( new Code(this.code.ToString())); sm.NextState = new EntryState(); } }
public void ProcessChar(char input, ParserStateMachine sm) { this.OnLinkIdCompleted(input); this.OnLinkCompleted(input, sm); if (ShouldAddChar(input)) { this.builder.Append(input); } }
private void OnLinkCompleted(char input, ParserStateMachine sm) { if (input.Equals('>') || input.Equals(')')) { sm.NextState = this.initialState; this.initialState.OnSubElementCompleted( new LinkItem( this.link.Length > 0 ? this.link.ToString() : this.id.ToString(), this.id.ToString())); } }
public void ProcessChar(char input, ParserStateMachine sm) { if (this.ShouldChangeState(input)) { sm.NextState = new Header4State(); } else if (!ShouldIgnoreChar(input)) { this.OnHeaderComplete(input, sm); this.header.Append(input); } }
public void ProcessChar(char input, ParserStateMachine sm) { if (this.initialState == null) { this.OnCodeCompleted(input, sm); } else { this.OnSubElemCompleted(input, sm); } this.AppendChar(input); }
private void OnTextElemCompleted(char input, ParserStateMachine sm) { var isLinkItem = input.Equals('[') || input.Equals('<'); var isTextCompleted = input.Equals('\n') || input.Equals('\r'); var isCodeItem = input.Equals('`'); this.AddLineTerminators(isTextCompleted); if (isTextCompleted || isLinkItem || isCodeItem) { sm.NextState = initialState; this.initialState.OnSubElementCompleted( new TextItem(this.textBuilder.ToString())); sm.NextState.ProcessChar(input, sm); } }
private void OnParagraphCompleted(char input, ParserStateMachine sm) { //we assume that a new line followed by a carriage return means end on list if (isEndPending) { if (input.Equals('\r')) { sm.MdDoc.AddParagraph(this.paragraph); sm.NextState = new EntryState(); } else { isEndPending = false; } } }
public void ProcessChar(char input, ParserStateMachine sm) { this.OnListItemCompleted(input, sm); if (ShouldParseChar(input)) { switch (input) { case '`': sm.NextState = new CodeState(this); break; case '[': case '<': sm.NextState = new LinkState(this); break; default: sm.NextState = new TextState(this); sm.NextState.ProcessChar(input, sm); break; } } isEndPending = input.Equals('\n') || this.isListItemEndPending; }
private void OnListItemCompleted(char input, ParserStateMachine sm) { //we assume that a digit on a new line means new list item //we also assume that a new line followed by a carriage return means end on list var isListEndPending = input.Equals('\r'); if (this.isEndPending) { if (isListItemEndPending) { if (input.Equals('.')) { sm.NextState = this.initialState; this.initialState.OnSubElementCompleted(this.listItem); sm.NextState.ProcessChar(newListItemChar, sm); } else { this.isListItemEndPending = false; this.isEndPending = false; } } else if (isListEndPending && !this.isListItemEndPending) { sm.NextState = this.initialState; this.initialState.OnSubElementCompleted(this.listItem); sm.NextState.ProcessChar(endListChar, sm); } else if (char.IsDigit(input)) { this.isListItemEndPending = true; } else { this.isEndPending = false; } } }
protected override void AddHeader(ParserStateMachine sm) { sm.MdDoc.AddHeader( new Header3(this.header.ToString())); }
private void OnSubElemCompleted(char input, ParserStateMachine sm) { if (IsElemCompleted(input)) { this.AddLineTerminators(input); sm.NextState = this.initialState; this.initialState.OnSubElementCompleted( new Code(this.code.ToString())); this.initialState.ProcessChar(input, sm); } }
public void ProcessChar(char input, ParserStateMachine sm) { this.OnListCompleted(input, sm); this.ChangeState(input, sm); }
protected abstract void AddHeader(ParserStateMachine sm);
public void ProcessChar(char input, ParserStateMachine sm) { throw new NotImplementedException(); }
public void ProcessChar(char input, ParserStateMachine sm) { this.OnTextElemCompleted(input, sm); this.textBuilder.Append(input); }