Python Forum
Parsing a YAML file without changing the string content..?, Flask - solved. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Parsing a YAML file without changing the string content..?, Flask - solved. (/thread-34502.html)



Parsing a YAML file without changing the string content..?, Flask - solved. - SpongeB0B - Aug-05-2021

Hi everyone,

I'm using a yaml file to load the text for a html page (Flask, Jinja)

extract of my YAML
Title: This is a <b>test</b>

but this will be parsed in my html as ->
Title: This is a &lt;b&gt;test&lt;/b&gt;

and for example an will be "converted" as €

and ideas how to keep those characters as they are ?

Thanks


RE: Parsing a YAML file without changing the string content..? - SpongeB0B - Aug-05-2021

I made some test and it the same with a simple

	
with open('test.txt', 'r') as file2:
  tyml = file2.read()

return render_template('index.html', TYML = tyml )
So either it's when I read the file with open or when I pass the variable to flask with render... humm Wall


RE: Parsing a YAML file without changing the string content..? - SpongeB0B - Aug-05-2021

Oh !

I believe I found ->

https://flask.palletsprojects.com/en/2.0.x/templating/

Quote:{% autoescape false %}
<p>autoescaping is disabled here
<p>{{ will_not_be_escaped }}
{% endautoescape %}

I'll make some try now... Pray
edit: it work Dance