The Web site's large frame has defined fonts, including font size and color, and so on, when the user published the article may be copied from other sites, copy the process also retains the font description information. When the article is displayed on the page, the font defined in the article is used by default, and the global font defined under the large frame is displayed if the font does not exist in the article. So the content of the site will appear very messy, some articles font is very large, some articles font is very small, not beautiful. It's good to be unified!
I'm not familiar with HTML and CSS, and I don't know if I can set the font content that is defined in the article to be invalidated.
Stupid people have a stupid way, unified modify the article, the user's definition of the font deleted all! Ha ha! If done by hand, this is a very heavy task, to first preview the page, if not unified to modify the font, fortunately the editor has a "clear format" option, select the text, click on the OK, and then save ... It's also troublesome.
If you only modify the font, the most convenient way is to directly modify the database, from the database to extract the article, delete and font-related tags, and then write back to the database.
A special look at the HTML reference manual, there are two ways to define the font:
1. Use <font> label, for example:
Copy Code code as follows:
<p>
<font size= "2" face= "Verdana" >
This is a paragraph.
</font>
</p>
<p>
<font size= "3" face= "Times" >
This is another paragraph.
</font>
</p>
This method is not recommended for use
2. Use the style definition, for example:
Copy Code code as follows:
<p style= "Font-family:verdana;font-size:80%;color:green" >
This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it. This is a paragraph with some text in it.
</p>
Just remove the definition part of the font and replace it with Python's regular expression module without pressure:
Copy Code code as follows:
def format (data):
"Delete the font label and style label All" "
p = re.compile (R ' <font. *?>|</font>|style=\ ". *?\")
ret = P.sub (', Data ')
If RET!= data:
Return Retelse:
Return None
Python to handle database-related operations should be careful to update the data method, you can refer to this article: http://www.cnblogs.com/ma6174/archive/2013/02/21/2920126.html