public string ToText(ScriptPrinterOptions options = default(ScriptPrinterOptions)) { CheckErrors(); var writer = new TextWriterOutput(); var renderContext = new ScriptPrinter(writer, options); renderContext.Write(Page); return(writer.ToString()); }
public ScriptPrinter(IScriptOutput output, ScriptPrinterOptions options = default(ScriptPrinterOptions)) { _isWhileLoop = new FastStack <bool>(4); Options = options; if (options.Mode != ScriptMode.Default && options.Mode != ScriptMode.ScriptOnly) { throw new ArgumentException($"The rendering mode `{options.Mode}` is not supported. Only `ScriptMode.Default` or `ScriptMode.ScriptOnly` are currently supported"); } _isScriptOnly = options.Mode == ScriptMode.ScriptOnly; _isInCode = _isScriptOnly || (options.Mode == ScriptMode.FrontMatterOnly || options.Mode == ScriptMode.FrontMatterAndContent); _output = output; _hasEndOfStatement = true; // We start as if we were on a new line }