2020-05-25 19:24:46 +00:00
|
|
|
/*
|
2020-05-25 15:46:10 +00:00
|
|
|
* Copyright (c) 2020, Hunter Salyer <thefalsehonesty@gmail.com>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-25 15:46:10 +00:00
|
|
|
*/
|
2020-05-25 19:24:46 +00:00
|
|
|
|
2020-05-28 18:40:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-05-25 19:24:46 +00:00
|
|
|
#include <AK/HashTable.h>
|
2022-12-06 20:42:59 +00:00
|
|
|
#include <AK/String.h>
|
2020-05-25 19:24:46 +00:00
|
|
|
#include <LibJS/Forward.h>
|
2022-10-08 15:38:32 +00:00
|
|
|
#include <LibJS/Runtime/Error.h>
|
2020-05-25 19:24:46 +00:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class MarkupGenerator {
|
|
|
|
public:
|
2022-12-06 20:42:59 +00:00
|
|
|
static ErrorOr<String> html_from_source(StringView);
|
|
|
|
static ErrorOr<String> html_from_value(Value);
|
|
|
|
static ErrorOr<String> html_from_error(Error const&, bool);
|
2020-05-25 19:24:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum class StyleType {
|
|
|
|
Invalid,
|
|
|
|
String,
|
|
|
|
Number,
|
|
|
|
KeywordBold,
|
|
|
|
Punctuation,
|
|
|
|
Operator,
|
|
|
|
Keyword,
|
|
|
|
ControlKeyword,
|
2021-04-20 09:41:59 +00:00
|
|
|
Identifier,
|
|
|
|
ObjectType,
|
2020-05-25 19:24:46 +00:00
|
|
|
};
|
|
|
|
|
2023-06-06 21:34:59 +00:00
|
|
|
static ErrorOr<void> value_to_html(Value, StringBuilder& output_html, HashTable<Object*>& seen_objects);
|
2022-12-06 20:42:59 +00:00
|
|
|
static ErrorOr<void> array_to_html(Array const&, StringBuilder& output_html, HashTable<Object*>&);
|
|
|
|
static ErrorOr<void> object_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&);
|
|
|
|
static ErrorOr<void> function_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&);
|
|
|
|
static ErrorOr<void> date_to_html(Object const&, StringBuilder& output_html, HashTable<Object*>&);
|
|
|
|
static ErrorOr<void> error_to_html(Error const&, StringBuilder& output_html, bool in_promise);
|
|
|
|
static ErrorOr<void> trace_to_html(TracebackFrame const&, StringBuilder& output_html);
|
2020-05-25 19:24:46 +00:00
|
|
|
|
2022-12-06 20:42:59 +00:00
|
|
|
static StringView style_from_style_type(StyleType);
|
2020-05-25 19:24:46 +00:00
|
|
|
static StyleType style_type_for_token(Token);
|
2022-12-06 20:42:59 +00:00
|
|
|
static ErrorOr<String> open_style_type(StyleType type);
|
|
|
|
static ErrorOr<String> wrap_string_in_style(StringView source, StyleType type);
|
2020-05-25 19:24:46 +00:00
|
|
|
};
|
|
|
|
|
2020-05-28 18:40:53 +00:00
|
|
|
}
|