


I'd like to add a pure Bash solution, as it is not 'that' difficult to just do it by hand, and sometimes you won't want to install an extra tool to do the job. I've written this script for one of those cases, but they are rare, so precede with caution. However, there are valid situations where using existing tooling is preferable over manually installing new ones, and where it is also a safe bet the XML's source is valid (enough). XML/HTML can be a horribly mutilated mess. (Credit to Reino) Output for all commands: ĭisclaimer: you should usually prefer installing a mature tool like xmllint to do a job like this. To change this behavior, see the formatterclass argument. output-node-format=xml -output-node-indent By default, the description will be line-wrapped so that it fits within the given space. To install html2text, simply run: sudo apt install html2text To get started simply run: html2text file. Of course you can further manipulate the output with other command-line tools such as sed and awk. Java -cp /usr/share/java/saxon/saxon9he.jar net.sf.saxon.Query \ html2text would format the resultant HTML page into plain text characters. Python -c 'import sys import s=() print((s).toprettyxml())' Python's can format XML (works also on legacy python2): echo 'lorem' | SynWrite is a free source code editor, HTML editor, and Notepad replacement for Windows systems. Syntax highlighting Automatic indentation and formatting Automatic pagination Node. This command comes with xmlstarlet: echo 'lorem' | Advanced text editor for programmers and Notepad replacement. Command-line XML and HTML beautifier and content extractor. For those like me, who have reached this thread because they want to serve an html file from linux terminal or want to view it using a terminal command, use these steps:-If you want to view your html using a browser: Navigate to the directory containing the html file If you have chrome installed, Use. This command comes with XML::Twig perl module, sometimes xml-twig-tools package: echo 'lorem' | This utility comes with libxml2-utils: echo 'lorem' |
