Add function to format XML efficiently
This commit is contained in:
parent
332a091e42
commit
a6859cb9e8
@ -1869,6 +1869,23 @@ Set up hideshow for nXML mode:
|
||||
nxml-forward-element
|
||||
nil))
|
||||
#+END_SRC
|
||||
|
||||
A function to format XML using tidy or xmllint if available, falling back to sgml-pretty-print:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun xml-pretty-print ()
|
||||
(interactive)
|
||||
(let ((start (if (region-active-p) (region-beginning) (point-min)))
|
||||
(end (if (region-active-p) (region-end) (point-max))))
|
||||
(cond
|
||||
((executable-find "tidy")
|
||||
(shell-command-on-region start end "tidy -wrap 88 -q -i -xml" nil t))
|
||||
((executable-find "xmllint")
|
||||
(shell-command-on-region start end "xmllint --format -" nil t))
|
||||
(t (sgml-pretty-print start end)))))
|
||||
|
||||
(general-def nxml-mode-map "C-M-\\" #'xml-pretty-print)
|
||||
|
||||
#+END_SRC
|
||||
* CSVs
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package csv-mode
|
||||
|
Loading…
Reference in New Issue
Block a user