249 Q_ASSERT(inlineContent.isEmpty() || children.isEmpty());
252 json[
"type"_L1] = blockTypeId(type);
253 json[
"text"_L1] = plainText();
255 if (!attributes.isEmpty())
256 json[
"attributes"_L1] = attributes;
258 if (!inlineContent.isEmpty()) {
260 for (
const auto &inline_ : inlineContent)
261 arr.append(inline_.toJson());
262 json[
"inlines"_L1] = arr;
265 if (!children.isEmpty()) {
267 for (
const auto &child : children)
268 arr.append(child.toJson());
270 if (type == BlockType::Table)
271 json[
"rows"_L1] = arr;
272 else if (type == BlockType::TableRow || type == BlockType::TableHeaderRow)
273 json[
"cells"_L1] = arr;
275 json[
"children"_L1] = arr;
291 Q_ASSERT(inlineContent.isEmpty() || children.isEmpty());
292 if (!inlineContent.isEmpty()) {
294 parts.reserve(inlineContent.size());
295 for (
const auto &inline_ : inlineContent)
296 parts.append(inline_.plainText());
297 return parts.join(u""_s);
300 if (!children.isEmpty()) {
302 parts.reserve(children.size());
303 for (
const auto &child : children)
304 parts.append(child.plainText());
305 return parts.join(u"\n"_s);
Represents a structural block element in documentation.
QJsonObject toJson() const
Converts the ContentBlock to a QJsonObject for template rendering.
QString plainText() const
Returns the concatenated plain text of this block's inline content or child blocks,...
Represents inline content within a documentation block.
QJsonObject toJson() const
Converts the InlineContent to a QJsonObject for template rendering.
QString plainText() const
Returns the concatenated plain text of this inline element and all its children, recursively.