How can I extract only and output the HTML only, without the JSON?
I’m using a Set node that receives a JSON:
[
{
"response": "```html\n<!DOCTYPE html>\n<html lang=\"pt-BR\">\n<head>\n <meta charset=\"UTF-8\">\n <title></title>\n <style>\n /* Estilos básicos para simular a aparência do Confluence (opcional, mas útil para visualização) */\n body { font-family: sans-serif; line-height: 1.5; }\n h1, h2, h3 { margin-top: 1.5em; margin-bottom: 0.5em; }\n hr { border: 0; border-top: 1px solid #ccc; margin: 1em 0; }\n table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }\n th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }\n th { background-color: #f2f2f2; }\n ul { margin-left: 20px; }\n strong { font-weight: bold; }\n a { color: #0052cc; text-decoration: none; }\n a:hover { text-decoration: underline; }\n /* Simulação do cabeçalho da imagem */\n .header-image-placeholder {\n background-color: #f0f0f0;\n text-align: center;\n padding: 20px;\n margin-bottom: 1em;\n border: 1px dashed #ccc;\n font-style: italic;\n color: #666;\n }\n </style>\n</head>\n<body> ... \n\n</body>\n</html>\n```"
}
]
Then, I created a Set node that deletes all the “\n” from the Input.
{{ $json.response.match(/<\!DOCTYPE html>[\s\S]*<\/html>/)[0].replace(/\n/g, '') }}
But the output remains inside a JSON:
[
{
"": "<!DOCTYPE html><html lang=\"pt-BR\"><head> <meta charset=\"UTF-8\"> <title>Arquitetura de Referência – Spanner</title> <style> /* Estilos básicos para simular a aparência do Confluence (opcional, mas útil para visualização) */ body { font-family: sans-serif; line-height: 1.5; } h1, h2, h3 { margin-top: 1.5em; margin-bottom: 0.5em; } hr { border: 0; border-top: 1px solid #ccc; margin: 1em 0; } table { border-collapse: collapse; width: 100%; margin-bottom: 1em; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } ul { margin-left: 20px; } strong { font-weight: bold; } a { color: #0052cc; text-decoration: none; } a:hover { text-decoration: underline; } /* Simulação do cabeçalho da imagem */ .header-image-placeholder { background-color: #f0f0f0; text-align: center; padding: 20px; margin-bottom: 1em; border: 1px dashed #ccc; font-style: italic; color: #666; } </style></head><body> . . . </body></html>"
}
]
How can I get the HTML only, like the following?
<!DOCTYPE html><html lang=\"pt-BR\"><head> <meta charset=\"UTF-8\"> <title>Arquitetura de Referência – Spanner</title> <style> /* Estilos básicos para simular a aparência do Confluence (opcional, mas útil para visualização) */ body { font-family: sans-serif; line-height: 1.5; } h1, h2, h3 { margin-top: 1.5em; margin-bottom: 0.5em; } hr { border: 0; border-top: 1px solid #ccc; margin: 1em 0; } table { border-collapse: collapse; width: 100%; margin-bottom: 1em; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } ul { margin-left: 20px; } strong { font-weight: bold; } a { color: #0052cc; text-decoration: none; } a:hover { text-decoration: underline; } /* Simulação do cabeçalho da imagem */ .header-image-placeholder { background-color: #f0f0f0; text-align: center; padding: 20px; margin-bottom: 1em; border: 1px dashed #ccc; font-style: italic; color: #666; } </style></head><body> . . . </body></html>
Information on your n8n setup
- n8n version: 1.89.2
- Running n8n via Docker,