Fix tables in pdf export

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-07-21 12:40:09 +02:00
parent f420effb83
commit 2df463c5dc
2 changed files with 39 additions and 2 deletions

View File

@@ -25,6 +25,8 @@ import (
"github.com/getprobo/probo/pkg/coredata" "github.com/getprobo/probo/pkg/coredata"
"github.com/yuin/goldmark" "github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
gmhtml "github.com/yuin/goldmark/renderer/html"
) )
var ( var (
@@ -38,7 +40,12 @@ var (
"lower": func(s string) string { return strings.ToLower(s) }, "lower": func(s string) string { return strings.ToLower(s) },
"classificationString": func(c Classification) string { return string(c) }, "classificationString": func(c Classification) string { return string(c) },
"formatContent": func(content string) template.HTML { "formatContent": func(content string) template.HTML {
md := goldmark.New() md := goldmark.New(
goldmark.WithExtensions(extension.Table),
goldmark.WithRendererOptions(
gmhtml.WithUnsafe(),
),
)
var buf bytes.Buffer var buf bytes.Buffer
if err := md.Convert([]byte(content), &buf); err != nil { if err := md.Convert([]byte(content), &buf); err != nil {

View File

@@ -276,6 +276,36 @@
margin: 0 auto; margin: 0 auto;
} }
} }
.document-content table {
width: 100%;
border-collapse: collapse;
margin: 12px 0;
font-size: 10pt;
page-break-inside: avoid;
table-layout: auto;
word-wrap: break-word;
}
.document-content table th,
.document-content table td {
padding: 6px 8px;
text-align: left;
border: 1px solid #ddd;
vertical-align: top;
word-wrap: break-word;
overflow-wrap: break-word;
}
.document-content table th {
background: #f5f5f5;
font-weight: bold;
color: #333;
}
.document-content table tr {
page-break-inside: avoid;
}
</style> </style>
</head> </head>
<body> <body>
@@ -364,4 +394,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>