Commit 99eb25aa authored by Sylvain Schmitz's avatar Sylvain Schmitz

added pretty-printing support for XPath

parent b27cb20b
......@@ -57,6 +57,9 @@
</replacetokens>
</filterchain>
</copy>
<copy file="prettify.js" todir="${target.dir}"/>
<copy file="prettify.css" todir="${target.dir}"/>
<copy file="lang-xpath.js" todir="${target.dir}"/>
<move file="matrix.json" todir="${target.dir}/${xml}"/>
<move file="fragments.csv" todir="${target.dir}/${xml}"/>
</target>
......
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Flows Between XPath Fragments</title>
<title>Flows Between XPath Fragments</title>
<link rel="stylesheet" type="text/css" href="../prettify.css">
<script type="text/javascript" src="../prettify.js"></script>
<script type="text/javascript" src="../lang-xpath.js"></script>
<style>
body {
margin: 1em auto 4em auto;
......@@ -81,7 +84,6 @@ path.inactive, #circle:hover path.fade {
<p>Built with <a href="http://d3js.org/">D3</a>.
<div id="log" style="opacity: 0;"></div>
<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="https://d3js.org/queue.v1.min.js"></script>
......@@ -291,8 +293,9 @@ function matrixgraph(fragments, matrix, maxentries) {
list.append("li")
.append("code")
.attr("class", "prettyprint lang-xpath")
.text(d);
.text(d.replace("&quot;","'"));
});
PR.prettyPrint();
}
function mouseovercell(p) {
......@@ -527,8 +530,9 @@ function chordgraph(fragments, matrix, maxentries) {
list.append("li")
.append("code")
.attr("class", "prettyprint lang-xpath")
.text(d);
.text(d.replace("&quot;","'"));
});
PR.prettyPrint();
}
}
......
/**
* Based on `lang-xq.js' Copyright (C) 2011 Patrick Wied
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview
* Registers a language handler for XQuery.
*
* To use, include prettify.js and this file in your HTML page.
* Then put your code in an HTML tag like
* <pre class="prettyprint lang-xq"></pre>
*
*
* @author Patrick Wied ( patpa7p@live.de )
* @version 2010-09-28
*/
(function () {
// Falls back to plain for stylesheets that don't style fun.
var PR_FUNCTION = 'fun pln';
// Falls back to plaiin for stylesheets that don't style var.
var PR_VARIABLE = 'var pln';
PR['registerLangHandler'](
PR['createSimpleLexer'](
[
// Matching $var-ia_bles
[PR_VARIABLE, /^\$[A-Za-z0-9_\-]+/, null, "$"]
],
[
// Matching lt and gt operators
// Not the best matching solution but you have to differentiate between the gt operator and the tag closing char
[PR['PR_PLAIN'], /^[\s=][<>][\s=]/],
// Matching @Attributes
[PR['PR_LITERAL'], /^[0-9\.]+/],
// Matching xml tags
[PR['PR_TAG'], /^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],
// Tokenizing /{}=;*,[]() as plain
[PR['PR_PLAIN'], /^[\/\{\};,\[\]\(\)\:]$/],
// Matching a double or single quoted, possibly multi-line, string.
// with the special condition that a { in a string changes to xquery context
[PR['PR_STRING'], /^(?:\"(?:[^\"\\\{]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\\{]|\\[\s\S])*(?:\'|$))/, null, '"\''],
// Matching standard xpath keywords
[PR['PR_KEYWORD'], /^(?:ancestor::|ancestor-or-self::|attribute::|child::|descendant::|following::|following-sibling::|namespace::|parent::|preceding::|preceding-sibling::|self::)|(?:any|and|as|cast|castable|else|eq|every|for|ge|gt|idiv|in|instance|intersect|is|le|let|lt|satisfies|ne|of|or|some|then|to|treat|union)\b/],
// Matching functions
[PR_FUNCTION, /^(?:(?:fn|math):[a-z\-]+|zero-or-one|years-from-duration|year-from-dateTime|year-from-date|upper-case|unordered|true|translate|trace|tokenize|timezone-from-time|timezone-from-dateTime|timezone-from-date|sum|subtract-dateTimes-yielding-yearMonthDuration|subtract-dateTimes-yielding-dayTimeDuration|substring-before|substring-after|substring|subsequence|string-to-codepoints|string-pad|string-length|string-join|string|static-base-uri|starts-with|seconds-from-time|seconds-from-duration|seconds-from-dateTime|round-half-to-even|round|reverse|resolve-uri|resolve-QName|replace|remove|QName|prefix-from-QName|position|one-or-more|number|not|normalize-unicode|normalize-space|node-name|node-kind|nilled|namespace-uri-from-QName|namespace-uri-for-prefix|namespace-uri|months-from-duration|month-from-dateTime|month-from-date|minutes-from-time|minutes-from-duration|minutes-from-dateTime|min|max|matches|lower-case|local-name-from-QName|local-name|last|lang|iri-to-uri|insert-before|index-of|in-scope-prefixes|implicit-timezone|idref|id|hours-from-time|hours-from-duration|hours-from-dateTime|floor|false|expanded-QName|exists|exactly-one|escape-uri|escape-html-uri|error|ends-with|encode-for-uri|document-uri|doc-available|doc|distinct-values|distinct-nodes|default-collation|deep-equal|days-from-duration|day-from-dateTime|day-from-date|data|current-time|current-dateTime|current-date|count|contains|concat|compare|collection|codepoints-to-string|codepoint-equal|ceiling|boolean|base-uri|avg|adjust-time-to-timezone|adjust-dateTime-to-timezone|adjust-date-to-timezone|abs)\b/],
// Matching normal words if none of the previous regular expressions matched
[PR['PR_PLAIN'], /^[A-Za-z0-9_\-]+/],
// Matching whitespaces
[PR['PR_PLAIN'], /^[\t\n\r \xA0]+/]
]),
['xpath']);
})();
......@@ -64,7 +64,9 @@
<xsl:if test="$examples">
<xsl:text>, "examples": [</xsl:text>
<xsl:for-each select="$examples[position() &lt;= $nexamples]">
<xsl:text>"</xsl:text><xsl:value-of select="current()/query"/><xsl:text>"</xsl:text>
<xsl:text>"</xsl:text><xsl:value-of
select="replace(normalize-space(current()/query),'&quot;',&quot;'&quot;)"/>
<xsl:text>"</xsl:text>
<xsl:if test="position() != last() and position() &lt; $nexamples">
<xsl:text>,</xsl:text>
</xsl:if>
......
/**
* @license
* Copyright (C) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Pretty printing styles. Used with prettify.js. */
/* SPAN elements with the classes below are added by prettyprint. */
.pln { color: #333 } /* plain text */
@media screen {
.str { color: #cccc99; font-style: italic; } /* string content */
.kwd { font-weight: bold; } /* a keyword */
.com { color: #f2f2f2 } /* a comment */
.lit { color: #cccc99; } /* a literal value */
/* punctuation, lisp open bracket, lisp close bracket */
.pun, .opn, .clo { color: #333 }
.tag { color: #fddaec } /* a markup tag name */
.atn { color: #fddaec } /* a markup attribute name */
.atv { color: #fddaec } /* a markup attribute value */
.dec, .var { color: #e5d8bd } /* a declaration; a variable name */
.fun { color: #fddaec } /* a function name */
}
/* Use higher contrast and text-weight for printable form. */
@media print, projection {
.str { color: #060 }
.kwd { color: #006; font-weight: bold }
.com { color: #600; font-style: italic }
.typ { color: #404; font-weight: bold }
.lit { color: #044 }
.pun, .opn, .clo { color: #440 }
.tag { color: #006; font-weight: bold }
.atn { color: #404 }
.atv { color: #060 }
}
/* Put a border around prettyprinted code snippets. */
pre.prettyprint { padding: 2px; border: 1px solid #888 }
/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 { background: #eee }
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment