Python Forum
Parsing a YAML file without changing the string content..?, Flask - solved.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parsing a YAML file without changing the string content..?, Flask - solved.
#1
Thumbs Up 
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
[Image: NfRQr9R.jpg]
Reply
#2
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
[Image: NfRQr9R.jpg]
Reply
#3
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
[Image: NfRQr9R.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error (Errno 2), File upload with the Flask framework and a public IP Username_Python1 0 117 5 hours ago
Last Post: Username_Python1
Question [SOLVED] Correct way to convert file from cp-1252 to utf-8? Winfried 8 544 Feb-29-2024, 12:30 AM
Last Post: Winfried
  [solved] list content check paul18fr 6 615 Jan-04-2024, 11:32 AM
Last Post: deanhystad
  Virtual Env changing mysql connection string in python Fredesetes 0 324 Dec-20-2023, 04:06 PM
Last Post: Fredesetes
  Need to replace a string with a file (HTML file) tester_V 1 699 Aug-30-2023, 03:42 AM
Last Post: Larz60+
Video doing data treatment on a file import-parsing a variable EmBeck87 15 2,666 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
  Loop through json file and reset values [SOLVED] AlphaInc 2 1,961 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  Changing the initial worksheet name in an MS Excel file azizrasul 3 908 Oct-02-2022, 07:56 PM
Last Post: azizrasul
  Changing file location azizrasul 6 1,237 Sep-28-2022, 01:01 AM
Last Post: azizrasul
  [SOLVED] [BeautifulSoup] Why does it turn inserted string's brackets into &lt;/&gt;? Winfried 0 1,452 Sep-03-2022, 11:21 PM
Last Post: Winfried

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020