pretty-print

How to print pretty xml in javascript?

独自空忆成欢 提交于 2019-12-19 08:54:54
问题 What's the best way to pretty-print xml in JavaScript? I obtain xml content through ajax call and before displaying this request in textarea i want to format it so it looks nice to the eye :) 回答1: This does not take care of any indenting, but helps to encode the XML for use within <pre> or <textarea> tags: /* hack to encode HTML entities */ var d = document.createElement('div'); var t = document.createTextNode(myXml); d.appendChild(t); document.write('<pre>' + d.innerHTML + '</pre>'); And if,

Google Prettify Removes Line Breaks?

时光总嘲笑我的痴心妄想 提交于 2019-12-18 20:10:01
问题 When I try to use Google Prettify to syntax highlight my code, I notice that it causes code to become one line ... why is that? When I remvoe prettify, it works 回答1: This is a well-known issue that someone's still trying to track down. Hang on, I've got the bug favourited somewhere... Yeah, there we go, here's the link to the issue in the Google Code issue tracker, assuming you're using IE, or one of the other affected browser/versions. 来源: https://stackoverflow.com/questions/5830408/google

MSXML from C++ - pretty print / indent newly created documents

谁说胖子不能爱 提交于 2019-12-18 13:27:19
问题 I'm writing out XML files using the MSXML parser, with a wrapper I downloaded from here: http://www.codeproject.com/KB/XML/JW_CXml.aspx. Works great except that when I create a new document from code (so not load from file and modify), the result is all in one big line. I'd like elements to be indented nicely so that I can read it easily in a text editor. Googling shows many people with the same question - asked around 2001 or so. Replies usually say 'apply an XSL transformation' or 'add your

Memory dump formatted like xxd from gdb

故事扮演 提交于 2019-12-18 10:05:15
问题 I'm trying to inspect a buffer which contains a binary formatted message, but also contains string data. As an example, I'm using this C code: int main (void) { char buf[100] = "\x01\x02\x03\x04String Data\xAA\xBB\xCC"; return 0; } I'd like to get a hex dump of what's in buf , of a format similar to xxd (I don't care if it's an exact match, what I'm really looking for is a hex dump side by side with printable chars). Inside GDB I can use something like: (gdb) x /100bx buf 0x7fffffffdf00: 0x01

Regex to Indent an XML File

最后都变了- 提交于 2019-12-18 09:04:10
问题 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 :) 回答1: 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

Git Diff Indent/Pretty Print/Beautify Before Diff

北城以北 提交于 2019-12-18 05:54:14
问题 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. 回答1: If you can find an application that does the indenting for you, you could use

Python pretty XML printer for XML string

筅森魡賤 提交于 2019-12-18 04:54:07
问题 I generate a long and ugly XML string with python, and I need to filter it through pretty printer to look better. I found this post for python pretty printers, but I have to write the XML string to a file to be read back to use the tools, which I want to avoid if possible. What python pretty tools that works on string are available? 回答1: Here's how to parse from a text string to the lxml structured data type. Python 2: from lxml import etree xml_str = "<parent><child>text</child><child>other

Simple HTML Pretty Print

南楼画角 提交于 2019-12-18 02:57:32
问题 http://jsfiddle.net/JamesKyle/L4b8b/ This may be a futile effort, but I personally think its possible. I'm not the best at Javascript or jQuery, however I think I have found a simple way of making a simple prettyprint for html. There are four types of code in this prettyprint: Plain Text Elements Attributes Values In order to stylize this I want to wrap elements , attibutes and values with spans with their own classes. The first way I have of doing this is to store every single kind of

How to pretty print in ipython notebook via sympy?

主宰稳场 提交于 2019-12-17 22:25:54
问题 I tried pprint , print , the former only prints Unicode version, and the latter doesn't do pretty prints. from sympy import symbols, Function import sympy.functions as sym from sympy import init_printing init_printing(use_latex=True) from sympy import pprint from sympy import Symbol x = Symbol('x') # If a cell contains only the following, it will render perfectly. (pi + x)**2 # However I would like to control what to print in a function, # so that multiple expressions can be printed from a

Printing out a linked list using toString

Deadly 提交于 2019-12-17 19:50:54
问题 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.