<commit_before><!DOCTYPE html>
<html>

<head>
    <title>CSL Style Formatter</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/png" href="favicon-32x32.png">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap-theme.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/ace.js"></script>
    <script src="libraries/vkbeautify.js"></script>
    <script src="libraries/HTML.min.js"></script>
</head>

<body>
    <div class="container-fluid">
        <div class="navbar navbar-default" role="navigation">
            <div class="navbar-header">
                <div class="navbar-brand">CSL Style Formatter</div>
                <div class="navbar-text"><a class="active" href="http://citationstyles.org/">CitationStyles.org</a>
                </div>
            </div>
        </div>
        <form class="form-horizontal" role="form">
            <div class="form-group" title="The CSL style to reformat.">
                <div class="col-sm-10 col-sm-offset-1">
                    <textarea id="source-text" class="form-control source-input" rows="8"></textarea>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                    <button id="doFormat" type="button" class="btn btn-primary" data-style="expand-left">Reformat</button>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                    <textarea id="output-text" class="form-control source-input" rows="8"></textarea>
                </div>
            </div>
        </form>
        <hr/>
        <div id="output"></div>
        <div id="footer"><small>Created by <a href="http://rintze.zelle.me/"><NAME></a>. Powered by GitHub Pages. <a href="https://github.com/rmzelle/style-formatter">Code</a> on GitHub.</small>
        </div>
    </div>
    <script>
        $("#doFormat").click(doFormat);
        
        function parseXML (xmlStr) {
            if (window.DOMParser) {
                var parser=new DOMParser();
                xmlDoc=parser.parseFromString(xmlStr,"text/xml");
            } else { // code for IE
                var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async=false;
                xmlDoc.loadXML(xmlStr);
            }
            return xmlDoc
        }

        function doFormat() {
            var inputString = $('#source-text').val();
            
            var XmlObject = parseXML(inputString);
            
            //Trim whitespace from cs:title textContent
            var styleTitle = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","title")[0];
            styleTitle.textContent = styleTitle.textContent.trim();
            
            //Trim whitespace from cs:summary textContent
            var styleSummary = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","summary")[0];
            styleSummary.textContent = styleSummary.textContent.trim();
            
            //Reorder attributes on cs:link
            var styleLinks = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","link");
            for (var i = 0; i < styleLinks.length; i++) {
                if (styleLinks[i].hasAttribute("rel")) {
                    var relValue = styleLinks[i].getAttribute("rel");
                    styleLinks[i].removeAttribute("rel"); 
                    styleLinks[i].setAttribute("rel", relValue);
                }
            }
            
            var serializer = new XMLSerializer(); 
            var outputXML = serializer.serializeToString(XmlObject);            
            
            outputXML = vkbeautify.xml(outputXML, 2);
            
            //Escape hard-to-identify characters
            //outputXML = outputXML.replace(/\u00a0/g,"&#160;"); //no-break space (somehow doesn't work)
            outputXML = outputXML.replace(/ᵉ/g,"&#7497;"); //modifier letter small e
            outputXML = outputXML.replace(/‑/g,"&#8209;"); //non-breaking hyphen
            outputXML = outputXML.replace(/–/g,"&#8211;"); //en dash
            outputXML = outputXML.replace(/—/g,"&#8212;"); //em dash
            outputXML = outputXML.replace(/ /g,"&#8239;"); //narrow no-break space
            
            $("#output-text").text(outputXML);
        }
        
        //To do:
        //Reorder elements cs:info
    </script>
</body>

</html><commit_msg>Get started on cs:info reordering<commit_after><!DOCTYPE html>
<html>

<head>
    <title>CSL Style Formatter</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/png" href="favicon-32x32.png">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap-theme.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/ace.js"></script>
    <script src="libraries/vkbeautify.js"></script>
    <script src="libraries/HTML.min.js"></script>
</head>

<body>
    <div class="container-fluid">
        <div class="navbar navbar-default" role="navigation">
            <div class="navbar-header">
                <div class="navbar-brand">CSL Style Formatter</div>
                <div class="navbar-text"><a class="active" href="http://citationstyles.org/">CitationStyles.org</a>
                </div>
            </div>
        </div>
        <form class="form-horizontal" role="form">
            <div class="form-group" title="The CSL style to reformat.">
                <div class="col-sm-10 col-sm-offset-1">
                    <textarea id="source-text" class="form-control source-input" rows="8"></textarea>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                    <button id="doFormat" type="button" class="btn btn-primary" data-style="expand-left">Reformat</button>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-10 col-sm-offset-1">
                    <textarea id="output-text" class="form-control source-input" rows="8"></textarea>
                </div>
            </div>
        </form>
        <hr/>
        <div id="output"></div>
        <div id="footer"><small>Created by <a href="http://rintze.zelle.me/"><NAME></a>. Powered by GitHub Pages. <a href="https://github.com/rmzelle/style-formatter">Code</a> on GitHub.</small>
        </div>
    </div>
    <script>
        $("#doFormat").click(doFormat);
        
        function parseXML (xmlStr) {
            if (window.DOMParser) {
                var parser=new DOMParser();
                xmlDoc=parser.parseFromString(xmlStr,"text/xml");
            } else { // code for IE
                var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async=false;
                xmlDoc.loadXML(xmlStr);
            }
            return xmlDoc
        }

        function doFormat() {
            var inputString = $('#source-text').val();
            
            var XmlObject = parseXML(inputString);
            
            //Trim whitespace from cs:title textContent
            var styleTitle = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","title")[0];
            styleTitle.textContent = styleTitle.textContent.trim();
            
            //Trim whitespace from cs:summary textContent
            var styleSummary = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","summary")[0];
            styleSummary.textContent = styleSummary.textContent.trim();
            
            //Reorder attributes on cs:link
            var styleLinks = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","link");
            for (var i = 0; i < styleLinks.length; i++) {
                if (styleLinks[i].hasAttribute("rel")) {
                    var relValue = styleLinks[i].getAttribute("rel");
                    styleLinks[i].removeAttribute("rel"); 
                    styleLinks[i].setAttribute("rel", relValue);
                }
            }
            
            //Reorder child elements in cs:info
            var infoChildNodes = XmlObject.getElementsByTagNameNS("http://purl.org/net/xbiblio/csl","info")[0].childNodes;
            for (var i = 0; i < infoChildNodes.length; i++) {
                //Skip Text nodes; http://stackoverflow.com/questions/12009329/why-does-this-childnodes-give-me-that-strange-output
                if (infoChildNodes[i].nodeType != 3) {
                    console.log(i);
                    //XML comment is 8; Element is 1
                    console.log(infoChildNodes[i].nodeType);
                    console.log(infoChildNodes[i].tagName);
                }
            }
            
            var serializer = new XMLSerializer(); 
            var outputXML = serializer.serializeToString(XmlObject);            
            
            outputXML = vkbeautify.xml(outputXML, 2);
            
            //Escape hard-to-identify characters
            //outputXML = outputXML.replace(/\u00a0/g,"&#160;"); //no-break space (somehow doesn't work)
            outputXML = outputXML.replace(/ᵉ/g,"&#7497;"); //modifier letter small e
            outputXML = outputXML.replace(/‑/g,"&#8209;"); //non-breaking hyphen
            outputXML = outputXML.replace(/–/g,"&#8211;"); //en dash
            outputXML = outputXML.replace(/—/g,"&#8212;"); //em dash
            outputXML = outputXML.replace(/ /g,"&#8239;"); //narrow no-break space
            
            $("#output-text").text(outputXML);
        }
        
        //To do:
        //Reorder elements cs:info
    </script>
</body>

</html>
{'fraction_non_alphanumeric': 0.15843525347773318, 'fraction_numerical': 0.013164036971337877, 'mean_word_length': 1.9763823284245623, 'pattern_counts': {'":': 0, '<': 148, '<?xml version=': 0, '>': 145, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6554810', 'n_tokens_mistral': 3317, 'n_tokens_neox': 3114, 'n_words': 527}