pretty-print

Wanted: Command line HTML5 beautifier [closed]

旧时模样 提交于 2019-11-29 19:42:00
Wanted A command line HTML5 beautifier running under Linux. Input Garbled, ugly HTML5 code. Possibly the result of multiple templates. You don't love it, it doesn't love you. Output Pure beauty. The code is nicely indented, has enough line breaks, cares for it's whitespace. Rather than viewing it in a webbrowser, you would like to display the code on your website directly. Suspects tidy does too much (heck, it alters my doctype!), and it doesn't work well with HTML5. Maybe there is a way to make it cooperate and not alter anything ? vim does too little. It only indents. I want the program to

Regex to Indent an XML File

為{幸葍}努か 提交于 2019-11-29 15:17:20
Is it possible to write a REGEX (search replace) that when run on an XML string will output that XML string indented nicely? If so whats the REGEX :) Is it possible to write a REGEX (search replace) that when run on an XML string [...anything] No. Use an XML parser to read the string, then an XML serialiser to write it back out in ‘pretty’ mode. Each XML processor has its own options so it depends on platform, but here is the somewhat long-winded way that works on DOM Level 3 LS-compliant implementations: input= implementation.createLSInput(); input.stringData= unprettyxml; parser=

Empty lines while using minidom.toprettyxml

末鹿安然 提交于 2019-11-29 11:31:48
问题 I've been using a minidom.toprettyxml for prettify my xml file. When I'm creating XML file and using this method, all works grate, but if I use it after I've modified the xml file (for examp I've added an additional nodes) and then I'm writing it back to XML, I'm getting empty lines, each time I'm updating it, I'm getting more and more empty lines... my code : file.write(prettify(xmlRoot)) def prettify(elem): rough_string = xml.tostring(elem, 'utf-8') //xml as ElementTree reparsed = mini

Pandas printing ALL dtypes

自作多情 提交于 2019-11-29 11:11:02
问题 This seems like a very simple problem, however it's driving me round the bend. I'm sure it should be solved by RTFM, but I've looked at the options and I can see the one to fix it. I just want to print the dtypes of all columns, currently I'm getting: print df.dtypes #> Date object Selection object Result object ... profit float64 PL float64 cumPL float64 Length: 11, dtype: object I've tried setting options display.max_row , display.max_info_row , display.max_info_columns all to no avail.

Git Diff Indent/Pretty Print/Beautify Before Diff

烂漫一生 提交于 2019-11-29 10:12:56
Is there a way to make Git indent /beautify/pretty print two versions of C++ source files before diffing them? I don't want Git to show me the myriads of changes introduced after someone auto-formatted the code. Example usage: I hit git difftool --indent-before-diffing path/to/file and get the changes after both the original version of path/to/file and the modified version of path/to/file have been indented. If you can find an application that does the indenting for you, you could use the method described here for odt files: Add the following line to your .gitattributes file: *.odt diff=odt

pretty-printing a record using a custom method in Clojure

自古美人都是妖i 提交于 2019-11-29 10:09:58
In Clojure 1.5.0, how can I provide a custom pretty-printer for my own record type, defined with defrecord. (defrecord MyRecord [a b]) (defmethod print-method MyRecord [x ^java.io.Writer writer] (print-method (:a x) writer)) (defmethod print-dup MyRecord [x ^java.io.Writer writer] (print-dup (:a x) writer)) (println (MyRecord. 'a 'b)) ;; a -- OK (clojure.pprint/pprint (MyRecord. 'a 'b)) ;; {:a a, :b b} -- not OK, I want a I would like clojure.pprint/pprint to also use my cutsom printer (which now, should just pretty-prints whatever is in the field a of the record for illustration purposes).

pprint(): how to use double quotes to display strings?

帅比萌擦擦* 提交于 2019-11-29 09:59:21
If I print a dictionary using pprint , it always wraps strings around single quotes ( ' ): >>> from pprint import pprint >>> pprint({'AAA': 1, 'BBB': 2, 'CCC': 3}) {'AAA': 1, 'BBB': 2, 'CCC': 3} Is there any way to tell pprint to use double quotes ( " ) instead? I would like to have the following behaviour: >>> from pprint import pprint >>> pprint({'AAA': 1, 'BBB': 2, 'CCC': 3}) {"AAA": 1, "BBB": 2, "CCC": 3} It looks like you are trying to produce JSON; if so, use the json module : >>> import json >>> print json.dumps({'AAA': 1, 'BBB': 2, 'CCC': 3}) {"AAA": 1, "BBB": 2, "CCC": 3} The pprint()

Multi-line pretty-printing of (nested) collections in Java

左心房为你撑大大i 提交于 2019-11-29 09:56:24
I want to be able to (pretty-)print the contents of my maps. They should have newlines and indentation rather than on a single line; ignoring the toString methods of collections/iterables/etc; and recursing into nested collections. This is especially of interest for me regarding maps. I suppose JSON'ing might be relevant, but I don't want to go that far, or at least - I don't want my code to have to know about JSON just for me to pretty-print it. What are my options (other than writing this myself)? You can use the method MapUtils.debugPrint from the apache commons collections in order to

Python Source Formatter/Pretty Printer [closed]

一个人想着一个人 提交于 2019-11-29 09:20:59
Is there an online or offline utility that will format/pretty-print Python source code? http://pypi.python.org/pypi/PythonTidy is an excellent, simple script. I've found that PyLint and other code analysis tools all choke on pyrex, twisted and other modules. If you want formatting, just use PythonTidy . Depends of what you mean by "format/pretty-print Python source code". There's Pygments that do syntax highlighting and you can try it online at Lodgeit (it's a pastebin). There's also the pprint module in the standard library that pretty-print python data sctructures (dict, list, etc.). If you

How do I get the compact form of pretty-printed JSON code?

断了今生、忘了曾经 提交于 2019-11-29 03:06:36
How do I make Jackson's build() method pretty-print its JSON output? Here is an example that pretty-prints the ugly form of JSON code. I need to take the nice version of JSON code then convet it to ugly fom. How can it be done? I need to convert this: { "one" : "AAA", "two" : [ "BBB", "CCC" ], "three" : { "four" : "DDD", "five" : [ "EEE", "FFF" ] } } to this: {"one":"AAA","two":["BBB","CCC"],"three":{"four":"DDD","five":["EEE","FFF"]}} I tried to remove '\n', '\t', and ' ' characters; but there may be some of these characters in values so I can't do that. What else can be done? Brad Jackson