Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cmd/libschema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/gremllm/lib/internal/converter"
)

//export Convert
// Convert processes HTML with optional element stripping configuration.
//
// IMPORTANT: The function signature uses **C.char and C.int instead of []*C.char because
Expand All @@ -22,6 +21,8 @@ import (
// The correct pattern for passing arrays through CGO is to pass the array pointer
// (as **C.char) and its length (as C.int) separately, then use unsafe.Slice to convert
// to a Go slice inside the function.
//
//export Convert
func Convert(htmlInput *C.char, elementsToStrip **C.char, elementsLen C.int) *C.char {
if htmlInput == nil {
return C.CString("")
Expand Down Expand Up @@ -52,7 +53,12 @@ func Convert(htmlInput *C.char, elementsToStrip **C.char, elementsLen C.int) *C.
return C.CString(goHTML)
}

return C.CString(string(processed))
md, err := converter.HTMLToMarkdown(processed, stripConfig)
if err != nil {
return C.CString(goHTML)
}

return C.CString(md)
}

//export Free
Expand Down
2 changes: 1 addition & 1 deletion ffi_tests/nodejs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (!result.includes('<footer>')) {
errors++;
}

if (result.includes('<main>')) {
if (result.includes('This content should remain')) {
console.log('✓ Main content preserved')
} else {
console.log('✗ Main content missing')
Expand Down
2 changes: 1 addition & 1 deletion ffi_tests/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
print("✗ Footer tag still present")
failures += 1

if b'<main>' in result_str.encode():
if b'This content should remain' in result_str.encode():
print("✓ Main content preserved")
else:
print("✗ Main content missing")
Expand Down