SoulDoc and TenTags

SoulDoc complements TenTags; it does not replace it.

  • TenTags is a compact declarative language and export engine for tables.

  • SoulDoc is a document layout engine that handles free positioning, geometry, pagination, and complete documents.

The souldoc.tentags module is independent from the DOCX renderer. It converts TenTags input into a neutral table model and semantic HTML. TenTags <cm> and <rm> markers become standard colspan and rowspan attributes, after which each renderer can create its native merged cells.

The parser supports the cell tags currently used by TenTags, including <b>, <i>, <u>, <s>, <color>, <bg>, <fs>, <left>, <center>, <right>, <cm>, <rm>, <url>, <img>, <mark>, <value>, and <br>. SoulDoc neither imports nor modifies the external tentags package.

5 views

Add a comment

Replies

Best

The scale(...) preamble is also supported. Its vertical value controls row height, and its horizontal value controls relative column width:

TABLE(
  scale(A1=2,3;C1=1,2)
  data(A1=<b>Name</b>;B1=Amount;C1=Status)
)

In this example, the first row receives a height multiplier of 2, column A a width weight of 3, and column C a width weight of 2. Semantic HTML uses colgroup and row heights; the DOCX renderer converts them into native Word column widths and row heights.

Quick start

Create a high-level document and export it to several formats:

from souldoc import (
    Column,
    SoulLayoutDocument,
    SoulStyle,
    Table,
    Text,
    save_document,
)

document = SoulLayoutDocument(
    name="Quarterly report",
    children=[
        Column(
            gap_mm=5,
            children=[
                Text(
                    "Quarterly report",
                    style=SoulStyle(
                        font_size_pt=24,
                        font_weight="bold",
                        text_align="center",
                    ),
                ),
                Text(
                    "The same component tree can be rendered to every "
                    "supported output format."
                ),
                Table(
                    rows=[
                        ["Product", "Quantity", "Amount"],
                        ["Service A", "12", "$1,200"],
                        ["Service B", "8", "$960"],
                    ],
                    header_rows=1,
                ),
            ],
        )
    ],
)

save_document(document, "report.html")
save_document(document, "report.svg")
save_document(document, "report.pdf")
save_document(document, "report.docx")
save_document(document, "report.xlsx")

save_document() selects the backend from the file extension.