Answer the question
In order to leave comments, you need to log in
How to make html code in one line?
In php this is easy to do.
Add a type file to Index
<?php
$s=str_replace("\r\n"," ",$text);
echo preg_replace("/((?<=>)|(?<=--)|(?<=.))[\s\n\r\t]+((?=--)|(?=<))/U",'',$s);?>
Answer the question
In order to leave comments, you need to log in
The {% spaceless %} tag, although it won't remove all hyphens, because it might break the code. If you need to remove all the transfers directly, then make your tag based on the Jang one.
But I like the filter much more in the nginx pagespeed module:
pagespeed on;
pagespeed EnableFilters collapse_whitespace;
Yes, pretty much the same:
>>> a = """
... <!DOCTYPE html>
... <html lang="en">
... <head>
... <meta charset="UTF-8">
... <title>Title</title>
... </head>
... <body>
...
... </body>
... </html>
... """
>>> import re
>>> a1 = a.replace("\r\n"," ")
>>> a1
'\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <title>Title</title>\n</head>\n<body>\n\n</body>\n</html>\n'
>>> re.sub("/((?<=>)|(?<=--)|(?<=.))[\s\n\r\t]+((?=--)|(?=<))/U",'', a1)
'\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <title>Title</title>\n</head>\n<body>\n\n</body>\n</html>\n'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question