I have the following Python code using Genshi (simplified):
with open(pathToHTMLFile, 'r') as f: template = MarkupTemplate(f.read()) finalPage = template.generate().render('html', doctype = 'html')
The HTML source file contains objects such as ©, ™and ®. Genshi replaces them with its UTF-8 character, which causes problems with the viewer (the output is used as a separate file, not a response to a web request), which ultimately sees the received HTML. Is there any way to prevent Genshi from parsing these entities? More general ones, such as &go through a fine.
©
™
®
&
& , , & , HTML. ©, , , .
, . , , ASCII, ASCII:
template.generate().render('html', doctype= 'html', encoding= 'us-ascii')
- © , ©, , , , .
©
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head> HTML- UTF-8.
<head>
, , & copy; UTF-8 HTML. HTML , , , UTF-8.
To prevent escaping character markup characters (x) html in Genshi:
from genshi.core import Markup ... newstring = Markup(oldstring) ... <now apply templates as before, but substituting newstring for oldstring>
Source: https://habr.com/ru/post/1719897/More articles:webbrowser.get( "firefox" ) на Mac с Firefox "не смог найти исполняемый браузер" - pythonStore value in variable after using select statement - c #appengine remote api cannot log in - pythonЛюбой существующий код С# (OSS), который будет вычислять diff между двумя строками и выходом html? - htmlEditing Live CSS with Textmate & Firefox - cssSimulate a lack of system resources on a Linux machine - debuggingWhat frame does ffmpeg do when lowering frame rates - ffmpegКакие драгоценные Rails RubyGems, с которыми не могут жить рельсы? - ruby-on-railsASP.NET with Delphi 2007 for .NET. Could not load file or assembly ... The located assembly manifest definition does not match the assembly reference - asp.netDynamic Localization WinForms - c #All Articles