pretty-print

Wanted: Command line HTML5 beautifier [closed]

一个人想着一个人 提交于 2019-11-28 15:28:47
问题 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

Changing how output is printed to the console

空扰寡人 提交于 2019-11-28 12:13:00
When I print something directly to the console (type some variable name, such as x , rather than using the print function print(x) ), I'd like it to print differently from the way that it normally prints. My idea is that the printing is done by some function. If that's the case, all I have to do is replace that function with a function of my own. However, I cannot figure out what the internal function that does the printing is. Here is what I've tried so far. .real_cat = cat cat = function(x) .real_cat("*** cat ***", x, "\n") cat(2345) 2345 # no Printing to console is not done via cat . What

Printing out a linked list using toString

岁酱吖の 提交于 2019-11-28 11:24:50
Ok guys, so I am trying to learn how to print out a linked list. I have all the methods that I would need to use for the list, but I can't figure out how to display the values of the nodes. Right now there is nothing in my main method because I kept getting errors trying to call non static methods in the main. I have a toString method that displays the contents of the list. How would I go about calling this toString to display the value of each node? Any advice will be greatly appreciated. Here is the node class: public class LinkedListNode { private int data; private LinkedListNode next;

Python pretty print dictionary of lists, abbreviate long lists

廉价感情. 提交于 2019-11-28 09:11:59
I have a dictionary of lists and the lists are quite long. How can I print it in a way that only a few elements of the list show up? Obviously, I can write a custom function for that but is there any built-in way or library that can achieve this? For example when printing large data frames, pandas prints it nicely in a short way. This example better illustrates what I mean: obj = {'key_1': ['EG8XYD9FVN', 'S2WARDCVAO', 'J00YCU55DP', 'R07BUIF2F7', 'VGPS1JD0UM', 'WL3TWSDP8E', 'LD8QY7DMJ3', 'J36U3Z9KOQ', 'KU2FUGYB2U', 'JF3RQ315BY'], 'key_2': ['162LO154PM', '3ROAV881V2', 'I4T79LP18J', 'WBD36EM6QL',

Pretty print XML in java 8

女生的网名这么多〃 提交于 2019-11-28 06:51:31
I have an XML file stored as a DOM Document and I would like to pretty print it to the console, preferably without using an external library. I am aware that this question has been asked multiple times on this site, however none of the previous answers have worked for me. I am using java 8, so perhaps this is where my code differs from previous questions? I have also tried to set the transformer manually using code found from the web, however this just caused a not found error. Here is my code which currently just outputs each xml element on a new line to the left of the console. import java

Preferred method for viewing code generated by Template Haskell

吃可爱长大的小学妹 提交于 2019-11-28 06:12:22
As you know, Template Haskell is used to generate various kinds of AST splices programmatically at compile-time. However, a splice can often be very opaque, and it is often difficult to discern what a splice actually generates. If you run the Q monad for a splice, and the splice is well-typed, you get a show able representation of the generated piece of AST, but this representation can be very difficult to understand, because of its unstructured layout. What is the preferred method for converting a piece of TH-generated AST into something akin to normal Haskell code, so that the code can be

How to Print “Pretty” String Output in Python

ⅰ亾dé卋堺 提交于 2019-11-28 04:23:01
I have a list of dicts with the fields classid, dept, coursenum, area, and title from a sql query. I would like to output the values in a human readable format. I was thinking a Column header at the top of each and then in each column the approrpiate output ie: CLASSID DEPT COURSE NUMBER AREA TITLE foo bar foo bar foo yoo hat yoo bar hat (obviously with standard alignment/spacing) How would I accomplish this in python? Standard Python string formatting may suffice. # assume that your data rows are tuples template = "{0:8}|{1:10}|{2:15}|{3:7}|{4:10}" # column widths: 8, 10, 15, 7, 10 print

When using Spring MVC for REST, how do you enable Jackson to pretty-print rendered JSON?

爷,独闯天下 提交于 2019-11-28 03:55:01
While developing REST services using Spring MVC, I would like render JSON 'pretty printed' in development but normal (reduced whitespace) in production. user4061342 If you are using Spring Boot 1.2 or later the simple solution is to add spring.jackson.serialization.INDENT_OUTPUT=true to the application.properties file. This assumes that you are using Jackson for serialization. If you are using an earlier version of Spring Boot then you can add http.mappers.json-pretty-print=true This solution still works with Spring Boot 1.2 but it is deprecated and will eventually be removed entirely. You

Any way to properly pretty-print ordered dictionaries?

北慕城南 提交于 2019-11-28 03:44:26
I like the pprint module in Python. I use it a lot for testing and debugging. I frequently use the width option to make sure the output fits nicely within my terminal window. It has worked fine until they added the new ordered dictionary type in Python 2.7 (another cool feature I really like). If I try to pretty-print an ordered dictionary, it doesn't show nicely. Instead of having each key-value pair on its own line, the whole thing shows up on one long line, which wraps many times and is hard to read. Does anyone here have a way to make it print nicely, like the old unordered dictionaries? I

pretty-printing a record using a custom method in Clojure

帅比萌擦擦* 提交于 2019-11-28 03:29:32
问题 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