public static Syntax.Block ProcessStage1(TextReader source, CommonMarkSettings settings = null) { if (source == null) { throw new ArgumentNullException(source.ToString()); } if (settings == null) { settings = CommonMarkSettings.Default; } var cur = Syntax.Block.CreateDocument(); var doc = cur; var line = new LineInfo(settings.TrackSourcePosition); try { var reader = new TabTextReader(source); reader.ReadLine(line); while (line.Line != null) { BlockMethods.IncorporateLine(line, ref cur); reader.ReadLine(line); } } catch (IOException) { throw; } catch (CommonMarkException) { throw; } catch (Exception ex) { throw new CommonMarkException("Ошибка при разборе строки " + line.ToString(), cur, ex); } try { do { BlockMethods.Finalize(cur, line); cur = cur.Parent; } while (cur != null); } catch (CommonMarkException) { throw; } catch (Exception ex) { throw new CommonMarkException("Ошибка при финализации открытых контейнеров.", cur, ex); } return(doc); }
public static Syntax.Block ProcessStage1(TextReader source, CommonMarkSettings settings = null) { if (source == null) { throw new ArgumentNullException("source"); } if (settings == null) { settings = CommonMarkSettings.Default; } var cur = Syntax.Block.CreateDocument(); var doc = cur; var line = new LineInfo(settings.TrackSourcePosition); try { var reader = new TabTextReader(source); reader.ReadLine(line); while (line.Line != null) { BlockMethods.IncorporateLine(line, ref cur); reader.ReadLine(line); } } catch (IOException) { throw; } catch (CommonMarkException) { throw; } catch (Exception ex) { throw new CommonMarkException("An error occurred while parsing line " + line.ToString(), cur, ex); } try { do { BlockMethods.Finalize(cur, line); cur = cur.Parent; } while (cur != null); } catch (CommonMarkException) { throw; } catch (Exception ex) { throw new CommonMarkException("An error occurred while finalizing open containers.", cur, ex); } return(doc); }