llvm/clang-tools-extra/clangd/support/Markup.cpp

//===--- Markup.cpp -----------------------------------------*- C++-*------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "support/Markup.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
#include <iterator>
#include <memory>
#include <string>
#include <vector>

namespace clang {
namespace clangd {
namespace markup {
namespace {

// Is <contents a plausible start to an HTML tag?
// Contents may not be the rest of the line, but it's the rest of the plain
// text, so we expect to see at least the tag name.
bool looksLikeTag(llvm::StringRef Contents) {}

// Tests whether C should be backslash-escaped in markdown.
// The string being escaped is Before + C + After. This is part of a paragraph.
// StartsLine indicates whether `Before` is the start of the line.
// After may not be everything until the end of the line.
//
// It's always safe to escape punctuation, but want minimal escaping.
// The strategy is to escape the first character of anything that might start
// a markdown grammar construct.
bool needsLeadingEscape(char C, llvm::StringRef Before, llvm::StringRef After,
                        bool StartsLine) {}

/// Escape a markdown text block. Ensures the punctuation will not introduce
/// any of the markdown constructs.
std::string renderText(llvm::StringRef Input, bool StartsLine) {}

/// Renders \p Input as an inline block of code in markdown. The returned value
/// is surrounded by backticks and the inner contents are properly escaped.
std::string renderInlineBlock(llvm::StringRef Input) {}

/// Get marker required for \p Input to represent a markdown codeblock. It
/// consists of at least 3 backticks(`). Although markdown also allows to use
/// tilde(~) for code blocks, they are never used.
std::string getMarkerForCodeBlock(llvm::StringRef Input) {}

// Trims the input and concatenates whitespace blocks into a single ` `.
std::string canonicalizeSpaces(llvm::StringRef Input) {}

std::string renderBlocks(llvm::ArrayRef<std::unique_ptr<Block>> Children,
                         void (Block::*RenderFunc)(llvm::raw_ostream &) const) {}

// Separates two blocks with extra spacing. Note that it might render strangely
// in vscode if the trailing block is a codeblock, see
// https://github.com/microsoft/vscode/issues/88416 for details.
class Ruler : public Block {};

class CodeBlock : public Block {};

// Inserts two spaces after each `\n` to indent each line. First line is not
// indented.
std::string indentLines(llvm::StringRef Input) {}

class Heading : public Paragraph {};

} // namespace

std::string Block::asMarkdown() const {}

std::string Block::asPlainText() const {}

void Paragraph::renderMarkdown(llvm::raw_ostream &OS) const {}

std::unique_ptr<Block> Paragraph::clone() const {}

/// Choose a marker to delimit `Text` from a prioritized list of options.
/// This is more readable than escaping for plain-text.
llvm::StringRef chooseMarker(llvm::ArrayRef<llvm::StringRef> Options,
                             llvm::StringRef Text) {}

void Paragraph::renderPlainText(llvm::raw_ostream &OS) const {}

BulletList::BulletList() = default;
BulletList::~BulletList() = default;

void BulletList::renderMarkdown(llvm::raw_ostream &OS) const {}

void BulletList::renderPlainText(llvm::raw_ostream &OS) const {}

Paragraph &Paragraph::appendSpace() {}

Paragraph &Paragraph::appendText(llvm::StringRef Text) {}

Paragraph &Paragraph::appendCode(llvm::StringRef Code, bool Preserve) {}

std::unique_ptr<Block> BulletList::clone() const {}

class Document &BulletList::addItem() {}

Document &Document::operator=(const Document &Other) {}

void Document::append(Document Other) {}

Paragraph &Document::addParagraph() {}

void Document::addRuler() {}

void Document::addCodeBlock(std::string Code, std::string Language) {}

std::string Document::asMarkdown() const {}

std::string Document::asPlainText() const {}

BulletList &Document::addBulletList() {}

Paragraph &Document::addHeading(size_t Level) {}
} // namespace markup
} // namespace clangd
} // namespace clang