mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
LibMarkdown: Take a 'view_width' argument for render_for_terminal()
Some constructs will require the width of the terminal (or a general 'width') to be rendered correctly, such as tables.
This commit is contained in:
parent
5fbec2b003
commit
aa65f664a9
12 changed files with 30 additions and 14 deletions
|
@ -36,7 +36,7 @@ public:
|
|||
virtual ~Block() { }
|
||||
|
||||
virtual String render_to_html() const = 0;
|
||||
virtual String render_for_terminal() const = 0;
|
||||
virtual String render_for_terminal(size_t view_width = 0) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ String CodeBlock::render_to_html() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String CodeBlock::render_for_terminal() const
|
||||
String CodeBlock::render_for_terminal(size_t) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual ~CodeBlock() override { }
|
||||
|
||||
virtual String render_to_html() const override;
|
||||
virtual String render_for_terminal() const override;
|
||||
virtual String render_for_terminal(size_t view_width = 0) const override;
|
||||
static OwnPtr<CodeBlock> parse(Vector<StringView>::ConstIterator& lines);
|
||||
|
||||
private:
|
||||
|
|
|
@ -52,12 +52,12 @@ String Document::render_to_html() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String Document::render_for_terminal() const
|
||||
String Document::render_for_terminal(size_t view_width) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
for (auto& block : m_blocks) {
|
||||
auto s = block.render_for_terminal();
|
||||
auto s = block.render_for_terminal(view_width);
|
||||
builder.append(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Markdown {
|
|||
class Document final {
|
||||
public:
|
||||
String render_to_html() const;
|
||||
String render_for_terminal() const;
|
||||
String render_for_terminal(size_t view_width = 0) const;
|
||||
|
||||
static OwnPtr<Document> parse(const StringView&);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ String Heading::render_to_html() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String Heading::render_for_terminal() const
|
||||
String Heading::render_for_terminal(size_t) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
virtual ~Heading() override { }
|
||||
|
||||
virtual String render_to_html() const override;
|
||||
virtual String render_for_terminal() const override;
|
||||
virtual String render_for_terminal(size_t view_width = 0) const override;
|
||||
static OwnPtr<Heading> parse(Vector<StringView>::ConstIterator& lines);
|
||||
|
||||
private:
|
||||
|
|
|
@ -47,7 +47,7 @@ String List::render_to_html() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String List::render_for_terminal() const
|
||||
String List::render_for_terminal(size_t) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
virtual ~List() override { }
|
||||
|
||||
virtual String render_to_html() const override;
|
||||
virtual String render_for_terminal() const override;
|
||||
virtual String render_for_terminal(size_t view_width = 0) const override;
|
||||
|
||||
static OwnPtr<List> parse(Vector<StringView>::ConstIterator& lines);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ String Paragraph::render_to_html() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
String Paragraph::render_for_terminal() const
|
||||
String Paragraph::render_for_terminal(size_t) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_text.render_for_terminal());
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
virtual ~Paragraph() override { }
|
||||
|
||||
virtual String render_to_html() const override;
|
||||
virtual String render_for_terminal() const override;
|
||||
virtual String render_for_terminal(size_t view_width = 0) const override;
|
||||
static OwnPtr<Paragraph> parse(Vector<StringView>::ConstIterator& lines);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue