mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:17:35 +00:00
LibMarkdown: Implement the image size extension
This implements the image size extension that's quite commonly used: https://github.com/commonmark/commonmark-spec/wiki/Deployed-Extensions#image-size This supports specifying... Both width and height:  Width only:  Height only:  The size is always in pixels (relative sizing does not seem to be spec'd anywhere).
This commit is contained in:
parent
fb47a87340
commit
8140b1fa18
2 changed files with 58 additions and 2 deletions
|
@ -97,14 +97,22 @@ public:
|
|||
bool is_image;
|
||||
NonnullOwnPtr<Node> text;
|
||||
String href;
|
||||
Optional<int> image_width;
|
||||
Optional<int> image_height;
|
||||
|
||||
LinkNode(bool is_image, NonnullOwnPtr<Node> text, String href)
|
||||
LinkNode(bool is_image, NonnullOwnPtr<Node> text, String href, Optional<int> image_width, Optional<int> image_height)
|
||||
: is_image(is_image)
|
||||
, text(move(text))
|
||||
, href(move(href))
|
||||
, image_width(image_width)
|
||||
, image_height(image_height)
|
||||
{
|
||||
}
|
||||
|
||||
bool has_image_dimensions() const
|
||||
{
|
||||
return image_width.has_value() || image_height.has_value();
|
||||
}
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue