public static void ProcessStage3(Syntax.Block document, TextWriter target, CommonMarkSettings settings = null) { if (document == null) { throw new ArgumentNullException("document"); } if (target == null) { throw new ArgumentNullException("target"); } if (document.Tag != Syntax.BlockTag.Document) { throw new ArgumentException("The block element passed to this method must represent a top level document.", "document"); } if (settings == null) { settings = CommonMarkSettings.Default; } try { switch (settings.OutputFormat) { case OutputFormat.Html: HtmlFormatterSlim.BlocksToHtml(target, document, settings); break; case OutputFormat.SyntaxTree: Printer.PrintBlocks(target, document, settings); break; case OutputFormat.CustomDelegate: if (settings.OutputDelegate == null) { throw new CommonMarkException("If `settings.OutputFormat` is set to `CustomDelegate`, the `settings.OutputDelegate` property must be populated."); } settings.OutputDelegate(document, target, settings); break; default: throw new CommonMarkException("Unsupported value '" + settings.OutputFormat + "' in `settings.OutputFormat`."); } } catch (CommonMarkException) { throw; } catch (IOException) { throw; } catch (Exception ex) { throw new CommonMarkException("An error occurred during formatting of the document.", ex); } }
public static void ProcessStage3(Syntax.Block document, TextWriter target, CommonMarkSettings settings = null) { if (document == null) { throw new ArgumentNullException(document.ToString()); } if (target == null) { throw new ArgumentNullException(target.ToString()); } if (document.Tag != Syntax.BlockTag.Document) { throw new ArgumentException("Блочный элемент, предоставляемый методу, болжен быть высокоуровневым документом.", document.ToString()); } if (settings == null) { settings = CommonMarkSettings.Default; } try { switch (settings.OutputFormat) { case OutputFormat.Html: HtmlFormatterSlim.BlocksToHtml(target, document, settings); break; case OutputFormat.SyntaxTree: Printer.PrintBlocks(target, document, settings); break; case OutputFormat.CustomDelegate: if (settings.OutputDelegate == null) { throw new CommonMarkException("Если `settings.OutputFormat` установлен в `CustomDelegate`, свойство `settings.OutputDelegate` должно быть заполнено."); } settings.OutputDelegate(document, target, settings); break; default: throw new CommonMarkException("Неподдерживаемое значение '" + settings.OutputFormat + "' в `settings.OutputFormat`."); } } catch (CommonMarkException) { throw; } catch (IOException) { throw; } catch (Exception ex) { throw new CommonMarkException("Ошибка при форматировании документа.", ex); } }