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
Question [Solved] Getting python's default 'printed' byte-string as string ? MvGulik 8 136 Apr-06-2026, 09:16 AM
Last Post: Dustbunny
Question [SOLVED] Linefeed when writing "f" strings to text file? Winfried 5 858 Nov-04-2025, 11:51 AM
Last Post: buran
Question [SOLVED] Open file, and insert space in string? Winfried 7 2,524 May-28-2025, 07:56 AM
Last Post: Winfried
Question [SOLVED] [Beautiful Soup] Replace tag.string from another file? Winfried 2 1,672 May-01-2025, 03:43 PM
Last Post: Winfried
  Replace values in Yaml file with value in dictionary PelleH 1 3,817 Feb-11-2025, 09:51 AM
Last Post: alexjordan
  question about changing the string value of a list element jacksfrustration 4 3,127 Feb-08-2025, 07:43 AM
Last Post: jacksfrustration
  [SOLVED] Sub string not found in string ? jehoshua 4 2,311 Dec-03-2024, 09:17 PM
Last Post: jehoshua
  [SOLVED] [Linux] Write file and change owner? Winfried 6 3,193 Oct-17-2024, 01:15 AM
Last Post: Winfried
Question [SOLVED] How to replace characters in a string? Winfried 2 1,957 Sep-04-2024, 01:41 PM
Last Post: Winfried
  [solved] how to delete the 10 first lines of an ascii file paul18fr 7 4,178 Aug-07-2024, 08:18 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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