Pretty prints an array of nodes (statements) and indents them optionally.
344785
protected function pStmts(array $nodes, $indent = true)
    {
        $result = '';
        foreach ($nodes as $node) {
            if ($node instanceof CodeBlock) {
                $comments = $node->getDocComment(true);
                $content = $this->pStmts($node->getStmts(), $indent);
            } else {
                $node = CodeBlock::getStmtNode($node);
                $comments = $node->getAttribute('comments', []);
                $content = $this->p($node);
            }
            if ($comments) {
                $front_of_comment = self::getFrontOfComment($node);
                $result .= $front_of_comment . $this->pComments($comments);
                if ($node instanceof Stmt\Nop) {
                    continue;
                }
            } else {
                $front_of_comment = '';
            }
            $front_of_node = self::getFrontOfNode($node, $front_of_comment);
            $end_of_node = self::getEndOfNode($node);
            $result .= $front_of_node . $content . $end_of_node;
        }
        if ($indent) {
            $result = $this->addIndent($result);
        }
        return $result;
    }
110387
function print(str, indent, inline) {
        var lines = str.split('\n');

        for(var i=0; i<lines.length; i++) {
            if(lines[i]) {
                if((inline && i > 0) || !inline) {
                    for(var j=0; j<indent; j++) {
                        process.stdout.write(' ');
                    }
                }
            }

            if(i === lines.length-1) {
                process.stdout.write(lines[i]);
            }
            else {
                process.stdout.write(lines[i] + '\n');
            }
        }
    }
381717
function serialize(node, indent) {
	indent = indent || 0;
	var type = node._type;
	var v;
	if (type < 3 || type == 7) {
		var name = node.name();
		if (type == 1) {
			var children = node;
			var ret = "";
			var attrs = "";
			var hasChildNodes = false;
			children.forEach(function (child, i) {
				var type = child._type;
				if (type == 2) {
					attrs += " " + serialize(child);
				} else {
					if (type == 1) hasChildNodes = hasChildNodes || true;
					ret += serialize(child, indent + 1);
				}
			});
			var dent = "";
			for (var i = 0; i < indent; i++) {
				dent += "\t";
			}
			return "\n" + dent + "<" + name + attrs + (ret === "" ? "/>" : ">") + ret + (ret === "" ? "" : (hasChildNodes ? "\n" + dent : "") + "</" + name + ">");
		} else if (type == 7) {
			v = node.value();
			return "<?" + name + " " + v.replace(/&/g, "&amp;") + "?>";
		} else {
			v = node.value();
			return name + "=\"" + v.replace(/&/g, "&amp;") + "\"";
		}
	} else if (type == 3 || type == 4 || type == 7 || type == 8) {
		v = node.value();
		if (type == 4) {
			return "<![CDATA[" + v + "]]>";
		} else if (type == 8) {
			return "<!--" + v + "-->";
		} else {
			return v.replace(/&/g, "&amp;");
		}
	} else {
		return "";
	}
}
1133157
function printNodes(node, indent) {
            indent = indent || 0;

            // This is hacky, but this is just a debugging function anyway
            function print(str, indent, inline) {
                var lines = str.split("\n");

                for (var i = 0; i < lines.length; i++) {
                    if (lines[i]) {
                        if ((inline && i > 0) || !inline) {
                            for (var j = 0; j < indent; j++) {
                                util.print(" ");
                            }
                        }
                    }

                    if (i === lines.length - 1) {
                        util.print(lines[i]);
                    } else {
                        util.puts(lines[i]);
                    }
                }
            }

            print(node.typename + ": ", indent);

            if (node instanceof NodeList) {
                print('\n');
                lib.each(node.children, function(n) {
                    printNodes(n, indent + 2);
                });
            } else if (node instanceof CallExtension) {
                print(node.extName + '.' + node.prop);
                print('\n');

                if (node.args) {
                    printNodes(node.args, indent + 2);
                }

                if (node.contentArgs) {
                    lib.each(node.contentArgs, function(n) {
                        printNodes(n, indent + 2);
                    });
                }
            } else {
                var nodes = null;
                var props = null;

                node.iterFields(function(val, field) {
                    if (val instanceof Node) {
                        nodes = nodes || {};
                        nodes[field] = val;
                    } else {
                        props = props || {};
                        props[field] = val;
                    }
                });

                if (props) {
                    print(util.inspect(props, true, null) + '\n', null, true);
                } else {
                    print('\n');
                }

                if (nodes) {
                    for (var k in nodes) {
                        printNodes(nodes[k], indent + 2);
                    }
                }

            }
        }
1004224
def pretty_print(ast, indent_str='  '):
    

    return ''.join(chunk.text for chunk in pretty_printer(indent_str)(ast))
974683
function printDanglingComments(path, options, sameIndent, filter) {
  const parts = [];
  const node = path.getValue();

  if (!node || !node.comments) {
    return "";
  }

  path.each(commentPath => {
    const comment = commentPath.getValue();
    if (
      comment &&
      !comment.leading &&
      !comment.trailing &&
      (!filter || filter(comment))
    ) {
      parts.push(printComment(commentPath, options));
    }
  }, "comments");

  if (parts.length === 0) {
    return "";
  }

  if (sameIndent) {
    return join(hardline, parts);
  }
  return indent(concat([hardline, join(hardline, parts)]));
}
1044548
function JSXAttribute(node, print) {
  print.plain(node.name);
  if (node.value) {
    this.push("=");
    print.plain(node.value);
  }
}
100395
function pprintSEXP(formJson, opts, indentLevel, priorNodeStr) {
  opts = opts || {};
  opts.lbracket = "(";
  opts.rbracket = ")";
  opts.separator = " ";
  opts.bareSymbols = true;
  return pprintJSON(formJson, opts, indentLevel, priorNodeStr);
}
176640
function indent(node) {
  var next = node;
  var i = 0;
  while (next) {
    ++i;
    next = next.suite || next.parent;
  }
  return Array(i).join('  ');
}
1199723
def node(node, indent)
      # Pretty print
      if @settings[:pretty]
        indentation = ' ' * indent
        inline = Settings::INLINE_NODE.include? node[@value]

        indentate = proc do
          if @in_definition
            buffer "' ' * (indent + #{indent})"
          else
            buffer_freeze indentation
          end
        end

        if inline
          inline_last_sibling = @sibling_stack[-1][-1] ? Settings::INLINE_NODE.include?(@sibling_stack[-1][-1][1]) : true

          if @sibling_stack[-1][-1] && @sibling_stack[-1][-1][0] == :plain
            buffer_remove_trailing_newline
          end

          if @in_definition || @sibling_stack[-1].length == 1 || !inline_last_sibling
            indentate[]
          end
        else
          indentate[]
        end

        @sibling_stack[-1] << [node[@type], node[@value]]
        @sibling_stack << [[node[@type], node[@value]]]
      end

      # Add the tag opening, with leading whitespace to the code buffer
      buffer_freeze ' ' if node[@options][:leading_whitespace]
      buffer_freeze "<#{node[@value]}"

      # Evaluate node extension in the current context
      if node[@options][:extension]
        extension_name = buffer_set_variable :extension,
                                             node[@options][:extension][@value]

        extension = {
          name: extension_name,
          escaped: node[@options][:extension][@options][:escaped]
        }
      end

      # Evaluate and generate node attributes, then process each one to
      # by generating the required attribute code
      buffer_attributes node[@options][:attributes],
                        extension


      # Check if the current node is self enclosing. Self enclosing nodes
      # do not have any child elements
      if node[@options][:self_enclosing]
        # If the tag is self enclosing, it cannot have any child elements.
        buffer_freeze '>'

        # Pretty print
        buffer_freeze "\n" if @settings[:pretty]

        # If we mistakenly add children to self enclosing nodes,
        # process each child element as if it was correctly indented
        # node[@children].each do |child|
        #   root child, indent + @settings[:indent]
        # end
      else
        # Set tag ending code
        buffer_freeze '>'

        # Pretty print
        if @settings[:pretty]
          if node[@children].length > 0
            buffer_freeze "\n" unless inline
          end
          # @sibling_stack << [[node[@type], node[@value]]]
        end

        # Process each child element recursively, increasing indentation
        node[@children].each do |child|
          root child, indent + @settings[:indent]
        end

        inline_last_child = @sibling_stack[-1][-2] &&
                            (@sibling_stack[-1][-2][0] == :plain ||
                              Settings::INLINE_NODE.include?(@sibling_stack[-1][-2][1]))

        # Pretty print
        if @settings[:pretty]
          if node[@children].length > 1 && inline_last_child
            buffer_freeze "\n"
          end

          if node[@children].size > 0 && !inline
            indentate[]
          end
        end

        # Set tag closing code
        buffer_freeze "</#{node[@value]}>"
        buffer_freeze ' ' if node[@options][:trailing_whitespace]

        # Pretty print
        if @settings[:pretty]
          buffer_freeze "\n" if !inline || @in_definition
        end
      end

      if @settings[:pretty]
        @sibling_stack.pop
      end
    end
1070259
def to_sexp(indent=0)
      indented = "  " * indent
      sexp = "#{indented}(#{fancy_type}"

      children.each do |child|
        if child.is_a?(Node)
          sexp += "\n#{child.to_sexp(indent + 1)}"
        else
          sexp += " #{child.inspect}"
        end
      end

      sexp += ")"

      sexp
    end
609843
def custom_print(data_structure, indent):
    
    for key, value in data_structure.items():
        print("\n%s%s:" % (' ' * attribute_indent * indent, str(key)), end=' ')
        if isinstance(value, OrderedDict):
            custom_print(value, indent + 1)
        elif isinstance(value, dict):
            custom_print(value, indent + 1)
        else:
            print("%s" % (str(value)), end=' ')
698031
public static String printNode(Node node, boolean prettyprint)
   {
      StringWriter strw = new StringWriter();
      new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
      return strw.toString();
   }
801530
private static void print(Node node, PrintWriter out) {
        if (node == null) {
            return;
        }

        boolean hasChildren = false;
        int type = node.getNodeType();
        NodeList children = null;
        switch (type) {
            case Node.DOCUMENT_NODE:
                children = node.getChildNodes();
                if (children != null) {
                    int numChildren = children.getLength();
                    for (int i = 0; i < numChildren; i++) {
                        print(children.item(i), out);
                    }
                }
                break;
            case Node.ELEMENT_NODE:
                out.print('<');
                out.print(node.getNodeName());
                if (node.hasAttributes()) {
                    NamedNodeMap attrs = node.getAttributes();
                    int len = (attrs != null) ? attrs.getLength() : 0;
                    for (int a = 0; a < len; a++) {
                        Attr attr = (Attr) attrs.item(a);
                        out.print(' ');
                        out.print(attr.getNodeName());
                        out.print("=\"");
                        out.print(attr.getValue());
                        out.print('\"');
                    }
                }
                children = node.getChildNodes();
                if (children != null) {
                    int numChildren = children.getLength();
                    hasChildren = (numChildren > 0);
                    if (hasChildren) {
                        out.print('>');
                    }
                    for (int i = 0; i < numChildren; i++) {
                        print(children.item(i), out);
                    }
                } else {
                    hasChildren = false;
                }
                if (!hasChildren) {
                    out.print("/>");
                }
                break;
            case Node.ENTITY_REFERENCE_NODE:
                out.print('&');
                out.print(node.getNodeName());
                out.print(';');
                break;
            case Node.CDATA_SECTION_NODE:
                out.print("<![CDATA[");
                out.print(node.getNodeValue());
                out.print("]]>");
                break;
            case Node.TEXT_NODE:
                out.print(node.getNodeValue());
                break;
            default:
                if (logger.isDebugEnabled()) {
                    logger.debug("Unknown type: " + type);
                }
        }
        if (type == Node.ELEMENT_NODE && hasChildren) {
            out.print("</");
            out.print(node.getNodeName());
            out.print('>');
            hasChildren = false;
        }
    }
590389
def pretty_print(self, indent=0):
        

        s = tab = ' '*indent
        s += '%s: ' %self.tag
        if isinstance(self.value, basestring):
            s += self.value
        else:
            s += '\n'
            for e in self.value:
                s += e.pretty_print(indent+4)
        s += '\n'

        return s
143565
function (node) {
    // Skip inline
    if (node.loc.start.line === node.loc.end.line) {
      return;
    }

    var elements = (node.type === 'ArrayExpression') ? node.elements : node.properties;

    // Skip if first element is in same line with this node
    if (elements.length > 0 && elements[0].loc.start.line === node.loc.start.line) {
      return;
    }

    var nodeIndent = getNodeIndent(node);

    var elementsIndent = nodeIndent + indentSize;
    // Elements can have double indent (detected by first item)
    if (elements.length > 0 &&
        getNodeIndent(elements[0]) === elementsIndent + indentSize) {
      elementsIndent = elementsIndent + indentSize;
    }

    // Comma can be placed before property name
    checkNodesIndent(elements, elementsIndent, true);

    if (elements.length > 0) {
      // Skip last block line check if last item in same line
      if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
        return;
      }
    }

    checkLastNodeLineIndent(node, elementsIndent - indentSize);
  }
474837
def PrintIndented(self, file, ident, code):
        """"""
        for entry in code:
            print >>file, '%s%s' % (ident, entry)