Open spodzone opened 9 years ago
If you change your file's grammar to XML
does it work well for beautification? Let me know, because if treating this as XML works then this will be a very quick fix to get XSLT support since we can already handle XML.
To change your grammar go to Atom's menu -> Edit -> Select Grammar.
Thanks; switching the grammar allows beautify to run, and the results remain unchanged by subsequent re-beautifications, but it doesn't really add much.
0) correct: it generally introduces a regular 4-space indent, that's fine.
1) major bug: it has broken a mention of <xsl:text>
by introducing spaces: <xsl : text>
.
2) bug: it introduces a double space between elements and their attributes
<link [double-space here] href="/skin/style-display.css" rel="STYLESHEET" type="text/css"/>
3) bug: comment PIs are not indented
4) nice to have: wrap+indent attributes to keep the line-length sane - currently these come out all on one line(!):
<xsl:transform
exclude-result-prefixes="xsd xsl"
version="1.1"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:q="http://www.w3.org/2005/sparql-results#"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5) nice to have: blank lines before <xsl:template>
declarations, before <xsl:stylesheet>
, before <xsl:output>
, and indent <xsl:param>
and <xsl:variable>
4 spaces.
I'm new to Atom, but from previous lives, I used to pipe a buffer through this little shell script - included here to assist what I'd like to emulate:
#!/bin/sh
export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
basic() {
xmlstarlet fo -s 2
}
nltemplate() {
sed -E 's#<xsl:template#\n <xsl:template#g'
}
stylesheet() {
sed -E '/<xsl:stylesheet/s# #\n #g'
}
stylespace() {
sed -E 's#<xsl:stylesheet#\n<xsl:stylesheet#'
}
paramspace() {
sed -E '1,/<xsl:param/s#<xsl:(param)#\n <xsl:\1#'
}
outputspace() {
sed -E '1,/<xsl:output/s#<xsl:(output)#\n <xsl:\1#'
}
variablespace() {
sed -E '1,/<xsl:variable/s#<xsl:(variable)#\n <xsl:\1#'
}
nowhitespaceblanklines() {
sed -E 's#^[ \t]*$##'
}
basic | nltemplate | stylesheet | stylespace | paramspace | outputspace | variablespace | nowhitespaceblanklines
Also a couple of images just for amusement - what I'd like and what it gives.
Cheers
Interesting. Please run the Atom command from the command palette: Atom Beautify: Help Debug Editor
. This will provide me with some more debugging information. Please put this into a Gist with the extension .md
(it is a markdown file) and post the link here. Thanks!
https://gist.github.com/spodzone/1e15d08b795eb6214eed
The real breakage with the xsl : text
happens just after a bunch of inline JS script at the bottom near the </body>
tag.
HTH!
@spodzone I provide the XML support for Atom-Beautify. Would you mind opening a bug at https://github.com/prettydiff/prettydiff/issues and list as bullet points features you would like to extend XML beautification into a more desirable format for XSLT?
Please could we have a beautifier for files .xsl, .xslt ?
Ideally, typical XML 2-space indent and a blank line between xsl elements such as xsl:template, xsl:output, etc.
Thanks!