1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

LibMarkdown: Add strike-through text support to markdown

Using ~~text~~ syntax will strike out the text between the two tildes.

Only missing portion is the terminal rendering of strike through text.
The ansi escape codes for strike through text are \e[9m and \e[29m but
it appears the terminal does not support these. Please correct me if I
am wrong.

I tested that the render_to_terminal function was being called by giving
it bold ANSI escape codes, and that did work so the function is being
called correctly.
This commit is contained in:
huttongrabiel 2022-04-26 21:34:29 -07:00 committed by Andreas Kling
parent 45f3fffbad
commit 25970f2763
3 changed files with 88 additions and 3 deletions

View file

@ -121,6 +121,21 @@ public:
virtual RecursionDecision walk(Visitor&) const override;
};
class StrikeThroughNode : public Node {
public:
NonnullOwnPtr<Node> striked_text;
StrikeThroughNode(NonnullOwnPtr<Node> striked_text)
: striked_text(move(striked_text))
{
}
virtual void render_to_html(StringBuilder& builder) const override;
virtual void render_for_terminal(StringBuilder& builder) const override;
virtual size_t terminal_length() const override;
virtual RecursionDecision walk(Visitor&) const override;
};
size_t terminal_length() const;
String render_to_html() const;
@ -172,6 +187,7 @@ private:
static NonnullOwnPtr<Node> parse_emph(Vector<Token>::ConstIterator& tokens, bool in_link);
static NonnullOwnPtr<Node> parse_code(Vector<Token>::ConstIterator& tokens);
static NonnullOwnPtr<Node> parse_link(Vector<Token>::ConstIterator& tokens);
static NonnullOwnPtr<Node> parse_strike_through(Vector<Token>::ConstIterator& tokens);
OwnPtr<Node> m_node;
};