pretty-print

PHP SimpleXML new line

隐身守侯 提交于 2019-12-05 05:27:49
I have created a XML file using PHP's simple XML, saved the file. When opening the file in php using fopen and printing the contents. my XML looks like this: (see below) <?xml version="1.0" encoding="UTF-8"?> <home><orderList><delivery_cost>0.00</delivery_cost><delivery_surname>TEST</delivery_surname><delivery_postcode>1234</delivery_postcode><status>1</status></orderList></home> I want the xml file looking all indented and on new lines for each element. Does anybody know how to do this? Thanks You can do this using the formatOutput property of DOMDocument . Save your XML like this instead,

Use PHP to format an input SQL query as HTML?

纵然是瞬间 提交于 2019-12-05 04:07:57
What I am looking for is a php function that takes an unformatted query like this: $sql = "select name, size from things where color = 'green' order by price asc"; so that it would appear in an HTML page something like this: SELECT name, size FROM things WHERE color = 'green' ORDER BY price ASC'; There's some code inside phpMyAdmin that does this already, I could look in there I guess! I had the same problem and made a light-weight PHP class to do formatting/syntax highlighting. https://github.com/jdorn/sql-formatter I haven't fully tested it with complex queries (sub-selects, unions, etc.),

Pretty HTML snippet output

早过忘川 提交于 2019-12-05 02:05:37
I've a snippet of HTML <div><p>text1</p></div><div><p>text1</p></div> I want to make it pretty like this <div> <p>text1</p> </div> <div> <p>text1</p> </div> What would be most simple way to do it? (I've looked on transform and jsoup) but not sure what would be really smart to use. Thanks! jTidy could fit for this task - http://jtidy.sourceforge.net/howto.html public String prettyPrintHTML(String rawHTML) { Tidy tidy = new Tidy(); tidy.setXHTML(true); tidy.setIndentContent(true); tidy.setPrintBodyOnly(true); tidy.setTidyMark(false); // HTML to DOM Document htmlDOM = tidy.parseDOM(new

How to make XML strings bold, underlined etc?

删除回忆录丶 提交于 2019-12-04 23:58:37
http://docs.fusioncharts.com/charts/contents/Styles/Font.html I tried this, along with a lot of things but failed to do so. Here's what I want. <string name="ss">Bold. Underlined. Italic. Big. Small</string> I want to format a little bit of the string. Where it's written bold, I want it to be bold...and same for others. I tried a lot of tags ...but well nothing worked, and I couldn't find anything on Google or SO. I know how to do it in a textview, but that's not what I want... I'm sending some text resource to an activity that shows it... If I did it with different text views, I'd have to

How do I pretty-print a table in Haskell?

假如想象 提交于 2019-12-04 22:49:22
I would like to prettyprint a table-like data structure in Haskell (a list of columns). For example... Table [ StrCol "strings" ["a", "bc", "c"], IntCol "ints" [1, 30, -2], DblCol "doubles" [2.0, 4.5, -3.2]] Should render something like... strings ints doubles "a" 1 2.0 "bc" 30 4.5 "c" -2 -3.2 Currently I have implemented this functionality in Text.PrettyPrint that comes with the most recent version of the Haskell Platform. Unfortunately the <+> operator orients multi-line documents "diagonally" from each other. eg (text "a" $+$ text "b") <+> (text "c" $+$ text "d") renders as a b c d rather

Python: limit the width of printed columns of pandas DataFrame

廉价感情. 提交于 2019-12-04 18:29:28
问题 I am trying to print a pandas DataFrame. One of the columns is too wide (it is a very long string). To print I am using tabulate library. But when it is printed it shows the whole content of all columns in one very long line. Here is what I see: row name review rating 0 Planetwise Flannel Wipes These flannel wipes are OK, but in my opinion not worth keeping. I also ordered someImse Vimse Cloth Wipes-Ocean Blue-12 countwhich are larger, had a nicer, softer texture and just seemed higher

Getting a python traceback without an exception

好久不见. 提交于 2019-12-04 17:27:09
问题 Suppose you have these modules: module1.py import module2 def a(): module1.b() def c(): print "Hi guys!" module2.py import module1 def b(): module1.c() I want a function func(a()) that produces a similar output to this: (=a traceback ?) /usr/local/lib/python2.7/dist-packages/test/module1.py 3 def a(): 4 module1.b() 1 import module1 /usr/local/lib/python2.7/dist-packages/test/module2.py 3 def b(): 4 module1.c() 1 import module2 /usr/local/lib/python2.7/dist-packages/test/module1.py 6 def c():

pretty output with pyyaml

我怕爱的太早我们不能终老 提交于 2019-12-04 16:59:12
问题 I have a python project where I'd like to use YAML (pyYaml 3.11), particularly because it is "pretty" and easy for users to edit in a text editor if and when necessary. My problem, though, is if I bring the YAML into a python application (as I will need to) and edit the contents (as I will need to) then writing the new document is typically not quite as pretty as what I started with. The pyyaml documentation is pretty poor - does not even document the parameters to the dump function. I found

Is it possible to pretty print Awk's code?

百般思念 提交于 2019-12-04 11:48:22
问题 Quite often I find myself writing Awk one-liners that gain complexity over time. I know I can always create an Awk file where to keep adding use cases, but it is certainly not as usable as changing the text on the command line. For this: is there any way I can pretty print Awk's code, so I can make more sense out of it? For example, given this: awk 'flag{ if (/PAT2/){printf "%s", buf; flag=0; buf=""} else buf = buf $0 ORS}; /PAT1/{flag=1}' file How can I get something a bit more readable? 回答1

How to see a large JSON file pretty printed on Ubuntu? [closed]

你。 提交于 2019-12-04 09:53:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last month . I would like to hear your suggestions on how to handle a large (40MB) JSON file on Ubuntu. I would like to see it pretty printed in vim or gedit or any other editor. One can find numerious tutorials on how to prettify the JSON, however, they do not have to deal with large input. I also imagine I could pipe the