/* * Copyright (c) 2019-2020, Sergey Bugaev * Copyright (c) 2021, Peter Elliott * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Markdown { String Document::render_to_html() const { StringBuilder builder; builder.append("\n"); builder.append("\n"); builder.append("\n"); builder.append("\n"); builder.append("\n"); builder.append("\n"); builder.append(render_to_inline_html()); builder.append("\n"); builder.append("\n"); return builder.build(); } String Document::render_to_inline_html() const { return m_container->render_to_html(); } String Document::render_for_terminal(size_t view_width) const { return m_container->render_for_terminal(view_width); } RecursionDecision Document::walk(Visitor& visitor) const { RecursionDecision rd = visitor.visit(*this); if (rd != RecursionDecision::Recurse) return rd; return m_container->walk(visitor); } OwnPtr Document::parse(StringView str) { Vector const lines_vec = str.lines(); LineIterator lines(lines_vec.begin()); return make(ContainerBlock::parse(lines)); } }