You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.0 KiB

#!/usr/bin/env node
/**
* Wrapper script to process content using gc-parser
* Called from Go code via exec
*/
const { Parser } = require('gc-parser');
// Read content from stdin
let content = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', (chunk) => {
content += chunk;
});
process.stdin.on('end', async () => {
try {
// Parse options from environment or command line args
const linkBaseURL = process.env.LINK_BASE_URL || process.argv[2] || '';
// Create parser with options
const parser = new Parser({
linkBaseURL: linkBaseURL,
enableAsciiDoc: true,
enableMarkdown: true,
enableCodeHighlighting: true,
enableLaTeX: true,
enableMusicalNotation: true,
enableNostrAddresses: true,
});
// Process content
const result = await parser.process(content);
// Output as JSON
console.log(JSON.stringify(result));
} catch (error) {
console.error(JSON.stringify({
error: error.message,
stack: error.stack,
}));
process.exit(1);
}
});