blob: 7f81cb8e762cb903aa883822a99e5c0023d27682 [file] [log] [blame]
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:convert';
/// Renderer for source code snippets extracted from source files.
abstract class SourceCodeRenderer {
String renderSourceCode(String source);
class SourceCodeRendererNoop implements SourceCodeRenderer {
const SourceCodeRendererNoop();
String renderSourceCode(String source) => source;
/// [SourceCodeRenderer] that escapes characters for HTML.
class SourceCodeRendererHtml implements SourceCodeRenderer {
const SourceCodeRendererHtml();
String renderSourceCode(String source) {
return const HtmlEscape().convert(source);