This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft-website.git
The following commit(s) were added to refs/heads/master by this push:
new 33ad510 Adding syntax highlighting instructions.
33ad510 is described below
commit 33ad510ad0b24f1e9584abdcf03599b741f75c0a
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sun Aug 22 13:36:46 2021 -0700
Adding syntax highlighting instructions.
---
ext/syntaxhighlighter/scripts/shBrushIdl.js | 4 +-
intent-matching.html | 107 ++++++++++++++++++++++++++--
resources.html | 1 -
3 files changed, 104 insertions(+), 8 deletions(-)
diff --git a/ext/syntaxhighlighter/scripts/shBrushIdl.js
b/ext/syntaxhighlighter/scripts/shBrushIdl.js
index 324d60b..73520a9 100644
--- a/ext/syntaxhighlighter/scripts/shBrushIdl.js
+++ b/ext/syntaxhighlighter/scripts/shBrushIdl.js
@@ -7,10 +7,10 @@
{
// Contributed by Aaron Radzinski.
- const keywords = 'flow fragment import intent meta ordered term';
+ const keywords = 'flow fragment import intent meta options term';
const literals = 'false null true';
const symbols = '[\\[\\]{}*@+?~=]+';
- const fns = 'or_else abs acos asin atan atn2 cbrt ceil comp_addr
comp_city comp_country comp_id comp_name comp_postcode comp_region comp_website
cos cosh count day_of_month day_of_week day_of_year degrees euler exp expm1
first floor get has has_all has_any hour hypot if is_alpha is_alphanum
is_alphanumspace is_alphaspace is_empty is_num is_numspace is_whitespace json
keys last length list log log10 log1p lowercase max meta_company meta_conv
meta_frag meta_intent meta_model meta_p [...]
+ const fns = 'abs asin atan atan2 avg cbrt ceil comp_addr comp_city
comp_country comp_id comp_name comp_postcode comp_region comp_website concat
contains cos cosh count day_of_month day_of_week day_of_year degrees distinct
ends_with euler exp expm1 first floor get has has_all has_any hour hypot if
index_of is_alpha is_alphanum is_alphanumspace is_alphaspace is_empty is_num
is_numspace is_whitespace json keys last length list log log10 log1p lowercase
max meta_company meta_conv met [...]
this.regexList = [
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css:
'comments' }, // One line comments.
diff --git a/intent-matching.html b/intent-matching.html
index 675f1cc..5251f6c 100644
--- a/intent-matching.html
+++ b/intent-matching.html
@@ -38,7 +38,7 @@ id: intent_matching
</p>
<p>
The intent generally refers to the goal that the end-user had in
mind when speaking or typing the input utterance.
- The intent has a <em>declarative part or template</em> written in
<a href="#idl">Intent Definition Language</a> that strictly defines
+ The intent has a <em>declarative part or template</em> written in
<a href="#idl">IDL - Intent Definition Language</a> that strictly defines
a particular form the user input.
Intent is also <a href="#binding">bound</a> to a callback method
that will be executed when that intent, i.e. its template, is detected as the
best match
for a given input. A typical data model will have multiple intents
defined for each form of the expected user input
@@ -55,7 +55,7 @@ id: intent_matching
</p>
</section>
<section id="idl">
- <h2 class="section-title">IDL - Intent Definition Language <a
href="#"><i class="top-link fas fa-fw fa-angle-double-up"></i></a></h2>
+ <h2 class="section-title">IDL Syntax <a href="#"><i class="top-link
fas fa-fw fa-angle-double-up"></i></a></h2>
<p>
NLPCraft intents are written in Intent Definition Language (IDL).
IDL is a relatively straightforward declarative language. For
example,
@@ -663,7 +663,104 @@ id: intent_matching
this string, list or map should be greater than
<code>10</code>.
</li>
</ul>
- <h2 id="idl_functions" class="section-title">IDL Functions <a
href="#"><i class="top-link fas fa-fw fa-angle-double-up"></i></a></h2>
+ <h2 id="syntax_highlighting" class="section-sub-title">Syntax
Highlighting <a href="#"><i class="top-link fas fa-fw
fa-angle-double-up"></i></a></h2>
+ <p>
+ NLPCraft IDL has relatively simple <a href="#idl">syntax</a> and
you can easily configure its syntax highlighting in most modern
+ code editors and IDEs. Here are two examples of how to add IDL
syntax highlighting:
+ </p>
+ <nav>
+ <div class="nav nav-tabs" role="tablist">
+ <a class="nav-item nav-link active" data-toggle="tab"
href="#idea_highlight" role="tab">IntelliJ IDEA</a>
+ <a class="nav-item nav-link" data-toggle="tab"
href="#sh_highlight" role="tab">SyntaxHighlighter.js</a>
+ </div>
+ </nav>
+ <div class="tab-content">
+ <div class="tab-pane fade show active" id="idea_highlight"
role="tabpanel">
+ <p></p>
+ <p>
+ NLPCraft project comes with
<code><b>idea/nlpcraft_idl_idea_settings.zip</b></code> file that contains
+ syntax highlighting configuration for <code>*.idl</code>
file types. Import this
+ file (File -> Manage IDE Settings -> Import Settings...)
and you will get proper syntax highlighting
+ for <code>*.idl</code> files in your project.
+ </p>
+ </div>
+ <div class="tab-pane fade" id="sh_highlight" role="tabpanel">
+ <p></p>
+ <p>
+ For highlighting the IDL syntax on the web you can use
+ <a target="github"
href="https://github.com/syntaxhighlighter/syntaxhighlighter">SyntaxHighlighter</a>
JavaScript library
+ that is used for all IDL code on this website.
+ </p>
+ <p>
+ To add custom language support, create a new brush file
<code><b>shBrushIdl.js</b></code> with the
+ following content and place it under <code>scripts</code>
folder in your local <a target="github"
href="https://github.com/syntaxhighlighter/syntaxhighlighter">SyntaxHighlighter</a>
+ installation:
+ </p>
+ <pre class="brush: js">
+;(function()
+{
+ // CommonJS
+ typeof(require) != 'undefined' ? SyntaxHighlighter =
require('shCore').SyntaxHighlighter : null;
+
+ function Brush()
+ {
+ const keywords = 'flow fragment import intent meta options term';
+ const literals = 'false null true';
+ const symbols = '[\\[\\]{}*@+?~=]+';
+ const fns = 'abs asin atan atan2 avg cbrt ceil comp_addr comp_city
comp_country comp_id comp_name comp_postcode comp_region comp_website concat
contains cos cosh count day_of_month day_of_week day_of_year degrees distinct
ends_with euler exp expm1 first floor get has has_all has_any hour hypot if
index_of is_alpha is_alphanum is_alphanumspace is_alphaspace is_empty is_num
is_numspace is_whitespace json keys last length list log log10 log1p lowercase
max meta_company meta_conv met [...]
+
+ this.regexList = [
+ { regex: SyntaxHighlighter.regexLib.singleLineCComments, css:
'comments' }, // One line comments.
+ { regex: SyntaxHighlighter.regexLib.multiLineCComments, css:
'comments' }, // Multiline comments.
+ { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css:
'string' }, // String.
+ { regex: SyntaxHighlighter.regexLib.singleQuotedString, css:
'string' }, // String.
+ { regex: /0x[a-f0-9]+|\d+(\.\d+)?/gi, css: 'value' }, // Numbers.
+ { regex: new RegExp(this.getKeywords(keywords), 'gm'), css:
'keyword' }, // Keywords.
+ { regex: new RegExp(this.getKeywords(literals), 'gm'), css:
'color1' }, // Literals.
+ { regex: /<|>|<=|>=|==|!=|&&|\|\|/g, css: 'color2' }, // Operators.
+ { regex: new RegExp(this.getKeywords(fns), 'gm'), css: 'functions'
}, // Functions.
+ { regex: new RegExp(symbols, 'gm'), css: 'color3' } // Symbols.
+ ];
+ }
+
+ Brush.prototype = new SyntaxHighlighter.Highlighter();
+ Brush.aliases = ['idl'];
+
+ SyntaxHighlighter.brushes.Idl = Brush;
+
+ // CommonJS.
+ typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
+})();
+ </pre>
+ <p>
+ Make sure to include this script in your page:
+ </p>
+ <pre class="brush: js">
+<script src="/path/to/your/scripts/shBrushIdl.js"
type="text/javascript"></script>
+ </pre>
+ <p>
+ And then you can use it to display IDL code from HTML
using <code><pre></code> tag and
+ <code>brush: idl</code> CSS class:
+ </p>
+ <pre class="brush: html">
+<pre class="brush: idl">
+ intent=xa
+ flow="^(?:login)(^:logout)*$"
+ meta={'enabled': true}
+ term(a)={month() >= 6 && !(tok_id()) != "z" && meta_intent('enabled')
== true}[1,3]
+ term(b)~{
+ @tokId = tok_id()
+ @usrTypes = meta_model('user_types')
+
+ (tokId == 'order' || tokId == 'order_cancel') &&
has_all(@usrTypes, list(1, 2, 3))
+ }
+</pre>
+ </pre>
+ </div>
+ </div>
+ </section>
+ <section id="idl_functions" >
+ <h2 class="section-title">IDL Functions <a href="#"><i class="top-link
fas fa-fw fa-angle-double-up"></i></a></h2>
<p>
IDL provides over 140 built-in functions that can be used in IDL
intent definitions.
IDL function call takes on traditional
@@ -1034,8 +1131,8 @@ id: intent_matching
</div>
</div>
</section>
- <section>
- <h2 id="idl_location" class="section-title">IDL Location <a
href="#"><i class="top-link fas fa-fw fa-angle-double-up"></i></a></h2>
+ <section id="idl_location" >
+ <h2 class="section-title">IDL Location <a href="#"><i class="top-link
fas fa-fw fa-angle-double-up"></i></a></h2>
<p>
IDL declarations can be placed in different locations based on
user preferences:
</p>
diff --git a/resources.html b/resources.html
index ae52e2c..beb4ee1 100644
--- a/resources.html
+++ b/resources.html
@@ -219,4 +219,3 @@ layout: interior
</ul>
</div>
</div>
-