163 case BlockType::Paragraph:
return u"paragraph"_s;
164 case BlockType::CodeBlock:
return u"code-block"_s;
165 case BlockType::List:
return u"list"_s;
166 case BlockType::ListItem:
return u"list-item"_s;
167 case BlockType::Section:
return u"section"_s;
168 case BlockType::SectionHeading:
return u"section-heading"_s;
169 case BlockType::Note:
return u"note"_s;
170 case BlockType::Warning:
return u"warning"_s;
171 case BlockType::Important:
return u"important"_s;
172 case BlockType::Details:
return u"details"_s;
173 case BlockType::Brief:
return u"brief"_s;
174 case BlockType::Div:
return u"div"_s;
175 case BlockType::Quotation:
return u"quotation"_s;
176 case BlockType::Legalese:
return u"legalese"_s;
177 case BlockType::HorizontalRule:
return u"horizontal-rule"_s;
178 case BlockType::Table:
return u"table"_s;
179 case BlockType::TableRow:
return u"table-row"_s;
180 case BlockType::TableHeaderRow:
return u"table-header-row"_s;
181 case BlockType::TableCell:
return u"table-cell"_s;
182 case BlockType::Raw:
return u"raw"_s;
183 case BlockType::DefinitionList:
return u"definition-list"_s;
184 case BlockType::DefinitionTerm:
return u"definition-term"_s;
185 case BlockType::DefinitionDescription:
return u"definition-description"_s;
186 case BlockType::ListPlaceholder:
return u"list-placeholder"_s;
187 case BlockType::Catalog:
return u"catalog"_s;
265 json[
"type"_L1] = blockTypeId(type);
266 json[
"text"_L1] = plainText();
268 if (!attributes.isEmpty())
269 json[
"attributes"_L1] = attributes;
271 if (!inlineContent.isEmpty()) {
273 for (
const auto &inline_ : inlineContent)
274 arr.append(inline_.toJson());
275 json[
"inlines"_L1] = arr;
285 qsizetype bodyIndex = 0;
286 for (
const auto &child : children) {
287 QJsonObject childJson = child.toJson();
288 if (child.type == BlockType::TableRow) {
290 QJsonObject attrs = childJson.value(
"attributes"_L1).toObject();
291 attrs[
"bodyIndex"_L1] = bodyIndex;
292 childJson[
"attributes"_L1] = attrs;
294 arr.append(childJson);
296 json[
"rows"_L1] = arr;
298 for (
const auto &child : children)
299 arr.append(child.toJson());
301 if (type == BlockType::TableRow || type == BlockType::TableHeaderRow)
302 json[
"cells"_L1] = arr;
304 json[
"children"_L1] = arr;
322 if (!inlineContent.isEmpty()) {
323 parts.reserve(inlineContent.size());
324 for (
const auto &inline_ : inlineContent)
325 parts.append(inline_.plainText());
328 if (!children.isEmpty()) {
329 QStringList childParts;
330 for (
const auto &child : children)
331 childParts.append(child.plainText());
332 if (!parts.isEmpty())
333 parts.append(u"\n"_s);
334 parts.append(childParts.join(u"\n"_s));
337 return parts.join(u""_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 content, recursively.
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.