Remove ```html from content

Hi,

I am generating html content using chatgpt module. But the generated content always contains

“triple backtick html” at the beginning and “triple backtick” at the end. How can this be removed?

1 Like

Hello @Vipin_Chandran,
I’m hoping that you’re getting content from some of the AI models and it’s formatted in the specific type of format.

So when there is no specific output format given and you ask for input in some specific format that time content is returned surrounded with that 3 backticks (`).
In Markdown writing style it’s considered as code blocks.

If you need a direct solution to replace it then go to this answer of @samliew

I recommend you check my to know about how prompts are built and work. A Beginner's Guide to Effective AI Prompts: The Input-Process-Output Framework


:bulb:P.S.: Always search first, Check Make Academy. If this is helpful, Mark Best Answers as Solutions :white_check_mark: and give :+1: If you need expert help or have questions? Contact or comment below! :point_down:

2 Likes

Hi @Vipin_Chandran

Just improve the prompt. Ask openAI in system to produce output in a valid json format. Output should start with { and end with }. And you will get the correct json.

Hope this helps.

Regards,
Msquare Automation - Platinum Partner of Make
@Msquare_Automation

Used the built-in replace function to sort this.

Thanks.

2 Likes

Welcome to the Make community!

You can use the built-in function replace

e.g.:

{{ replace(1.result; "/^```.+\n|\n```$)/g"; emptystring) }}

For more information, see the function documentation in the Help Center and do the tutorials in the Make Academy.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.