Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
a85e6907
Commit
a85e6907
authored
13 years ago
by
Hardest
Committed by
Marijn Haverbeke
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added NTriples mode
parent
6889665b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
compress.html
+1
-0
1 addition, 0 deletions
compress.html
index.html
+1
-0
1 addition, 0 deletions
index.html
mode/ntriples/index.html
+33
-0
33 additions, 0 deletions
mode/ntriples/index.html
mode/ntriples/ntriples.js
+172
-0
172 additions, 0 deletions
mode/ntriples/ntriples.js
with
207 additions
and
0 deletions
compress.html
+
1
−
0
View file @
a85e6907
...
...
@@ -56,6 +56,7 @@
<option
value=
"http://codemirror.net/mode/jinja2/jinja2.js"
>
jinja2.js
</option>
<option
value=
"http://codemirror.net/mode/lua/lua.js"
>
lua.js
</option>
<option
value=
"http://codemirror.net/mode/markdown/markdown.js"
>
markdown.js
</option>
<option
value=
"http://codemirror.net/mode/ntriples/ntriples.js"
>
ntriples.js
</option>
<option
value=
"http://codemirror.net/mode/pascal/pascal.js"
>
pascal.js
</option>
<option
value=
"http://codemirror.net/mode/php/php.js"
>
php.js
</option>
<option
value=
"http://codemirror.net/mode/plsql/plsql.js"
>
plsql.js
</option>
...
...
This diff is collapsed.
Click to expand it.
index.html
+
1
−
0
View file @
a85e6907
...
...
@@ -46,6 +46,7 @@
<li><a
href=
"mode/jinja2/index.html"
>
Jinja2
</a></li>
<li><a
href=
"mode/lua/index.html"
>
Lua
</a></li>
<li><a
href=
"mode/markdown/index.html"
>
Markdown
</a></li>
<li><a
href=
"mode/ntriples/index.html"
>
NTriples
</a></li>
<li><a
href=
"mode/pascal/index.html"
>
Pascal
</a></li>
<li><a
href=
"mode/php/index.html"
>
PHP
</a></li>
<li><a
href=
"mode/plsql/index.html"
>
PL/SQL
</a></li>
...
...
This diff is collapsed.
Click to expand it.
mode/ntriples/index.html
0 → 100644
+
33
−
0
View file @
a85e6907
<!doctype html>
<html>
<head>
<title>
CodeMirror 2: NTriples mode
</title>
<link
rel=
"stylesheet"
href=
"../../lib/codemirror.css"
>
<script
src=
"../../lib/codemirror.js"
></script>
<script
src=
"ntriples.js"
></script>
<link
rel=
"stylesheet"
href=
"../../theme/default.css"
>
<link
rel=
"stylesheet"
href=
"../../css/docs.css"
>
<style
type=
"text/css"
>
.CodeMirror
{
border
:
1px
solid
#eee
;
}
</style>
</head>
<body>
<h1>
CodeMirror 2: NTriples mode
</h1>
<form>
<textarea
id=
"ntriples"
name=
"ntriples"
>
<http:
//
Sub1
>
<http:
//
pred1
>
<http:
//
obj
>
.
<http:
//
Sub2
>
<http:
//
pred2#an2
>
"literal 1" .
<http:
//
Sub3#an3
>
<http:
//
pred3
>
_:bnode3 .
_:bnode4
<http:
//
pred4
>
"literal 2"@lang .
_:bnode5
<http:
//
pred5
>
"literal 3"^^
<http:
//
type
>
.
</textarea>
</form>
<script>
var
editor
=
CodeMirror
.
fromTextArea
(
document
.
getElementById
(
"
ntriples
"
),
{});
</script>
<p><strong>
MIME types defined:
</strong>
<code>
text/n-triples
</code>
.
</p>
</body>
</html>
This diff is collapsed.
Click to expand it.
mode/ntriples/ntriples.js
0 → 100644
+
172
−
0
View file @
a85e6907
/**********************************************************
* This script provides syntax highlighting support for
* the Ntriples format.
* Ntriples format specification:
* http://www.w3.org/TR/rdf-testcases/#ntriples
***********************************************************/
/*
The following expression defines the defined ASF grammar transitions.
pre_subject ->
{
( writing_subject_uri | writing_bnode_uri )
-> pre_predicate
-> writing_predicate_uri
-> pre_object
-> writing_object_uri | writing_object_bnode |
(
writing_object_literal
-> writing_literal_lang | writing_literal_type
)
-> post_object
-> BEGIN
} otherwise {
-> ERROR
}
*/
CodeMirror
.
defineMode
(
"
ntriples
"
,
function
()
{
Location
=
{
PRE_SUBJECT
:
0
,
WRITING_SUB_URI
:
1
,
WRITING_BNODE_URI
:
2
,
PRE_PRED
:
3
,
WRITING_PRED_URI
:
4
,
PRE_OBJ
:
5
,
WRITING_OBJ_URI
:
6
,
WRITING_OBJ_BNODE
:
7
,
WRITING_OBJ_LITERAL
:
8
,
WRITING_LIT_LANG
:
9
,
WRITING_LIT_TYPE
:
10
,
POST_OBJ
:
11
,
ERROR
:
12
};
function
transitState
(
currState
,
c
)
{
var
currLocation
=
currState
.
location
;
var
ret
;
// Opening.
if
(
currLocation
==
Location
.
PRE_SUBJECT
&&
c
==
'
<
'
)
ret
=
Location
.
WRITING_SUB_URI
;
else
if
(
currLocation
==
Location
.
PRE_SUBJECT
&&
c
==
'
_
'
)
ret
=
Location
.
WRITING_BNODE_URI
;
else
if
(
currLocation
==
Location
.
PRE_PRED
&&
c
==
'
<
'
)
ret
=
Location
.
WRITING_PRED_URI
;
else
if
(
currLocation
==
Location
.
PRE_OBJ
&&
c
==
'
<
'
)
ret
=
Location
.
WRITING_OBJ_URI
;
else
if
(
currLocation
==
Location
.
PRE_OBJ
&&
c
==
'
_
'
)
ret
=
Location
.
WRITING_OBJ_BNODE
;
else
if
(
currLocation
==
Location
.
PRE_OBJ
&&
c
==
'
"
'
)
ret
=
Location
.
WRITING_OBJ_LITERAL
;
// Closing.
else
if
(
currLocation
==
Location
.
WRITING_SUB_URI
&&
c
==
'
>
'
)
ret
=
Location
.
PRE_PRED
;
else
if
(
currLocation
==
Location
.
WRITING_BNODE_URI
&&
c
==
'
'
)
ret
=
Location
.
PRE_PRED
;
else
if
(
currLocation
==
Location
.
WRITING_PRED_URI
&&
c
==
'
>
'
)
ret
=
Location
.
PRE_OBJ
;
else
if
(
currLocation
==
Location
.
WRITING_OBJ_URI
&&
c
==
'
>
'
)
ret
=
Location
.
POST_OBJ
;
else
if
(
currLocation
==
Location
.
WRITING_OBJ_BNODE
&&
c
==
'
'
)
ret
=
Location
.
POST_OBJ
;
else
if
(
currLocation
==
Location
.
WRITING_OBJ_LITERAL
&&
c
==
'
"
'
)
ret
=
Location
.
POST_OBJ
;
else
if
(
currLocation
==
Location
.
WRITING_LIT_LANG
&&
c
==
'
'
)
ret
=
Location
.
POST_OBJ
;
else
if
(
currLocation
==
Location
.
WRITING_LIT_TYPE
&&
c
==
'
>
'
)
ret
=
Location
.
POST_OBJ
;
// Closing typed and language literal.
else
if
(
currLocation
==
Location
.
WRITING_OBJ_LITERAL
&&
c
==
'
@
'
)
ret
=
Location
.
WRITING_LIT_LANG
;
else
if
(
currLocation
==
Location
.
WRITING_OBJ_LITERAL
&&
c
==
'
^
'
)
ret
=
Location
.
WRITING_LIT_TYPE
;
// Spaces.
else
if
(
c
==
'
'
&&
(
currLocation
==
Location
.
PRE_SUBJECT
||
currLocation
==
Location
.
PRE_PRED
||
currLocation
==
Location
.
PRE_OBJ
||
currLocation
==
Location
.
POST_OBJ
)
)
ret
=
currLocation
;
// Reset.
else
if
(
currLocation
==
Location
.
POST_OBJ
&&
c
==
'
.
'
)
ret
=
Location
.
PRE_SUBJECT
;
// Error
else
ret
=
Location
.
ERROR
;
currState
.
location
=
ret
;
}
untilSpace
=
function
(
c
)
{
return
c
!=
'
'
;
};
untilEndURI
=
function
(
c
)
{
return
c
!=
'
>
'
;
};
return
{
startState
:
function
()
{
return
{
location
:
Location
.
PRE_SUBJECT
,
uris
:
[],
anchors
:
[],
bnodes
:
[],
langs
:
[],
types
:
[]
};
},
token
:
function
(
stream
,
state
)
{
var
ch
=
stream
.
next
();
if
(
ch
==
'
<
'
)
{
transitState
(
state
,
ch
);
var
parsedURI
=
''
;
stream
.
eatWhile
(
function
(
c
)
{
if
(
c
!=
'
#
'
&&
c
!=
'
>
'
)
{
parsedURI
+=
c
;
return
true
;
}
return
false
;}
);
state
.
uris
.
push
(
parsedURI
);
if
(
stream
.
match
(
'
#
'
,
false
)
)
return
'
variable
'
;
stream
.
next
();
transitState
(
state
,
'
>
'
);
return
'
variable
'
;
}
if
(
ch
==
'
#
'
)
{
var
parsedAnchor
=
''
;
stream
.
eatWhile
(
function
(
c
)
{
if
(
c
!=
'
>
'
&&
c
!=
'
'
)
{
parsedAnchor
+=
c
;
return
true
;
}
return
false
});
state
.
anchors
.
push
(
parsedAnchor
);
return
'
variable-2
'
;
}
if
(
ch
==
'
>
'
)
{
transitState
(
state
,
'
>
'
);
return
'
variable
'
;
}
if
(
ch
==
'
_
'
)
{
transitState
(
state
,
ch
);
var
parsedBNode
=
''
;
stream
.
eatWhile
(
function
(
c
)
{
if
(
c
!=
'
'
)
{
parsedBNode
+=
c
;
return
true
;
}
return
false
;});
state
.
bnodes
.
push
(
parsedBNode
);
stream
.
next
();
transitState
(
state
,
'
'
);
return
'
builtin
'
;
}
if
(
ch
==
'
"
'
)
{
transitState
(
state
,
ch
);
stream
.
eatWhile
(
function
(
c
)
{
return
c
!=
'
"
'
;
}
);
stream
.
next
();
if
(
stream
.
peek
()
!=
'
@
'
&&
stream
.
peek
()
!=
'
^
'
)
{
transitState
(
state
,
'
"
'
);
}
return
'
string
'
;
}
if
(
ch
==
'
@
'
)
{
transitState
(
state
,
'
@
'
);
var
parsedLang
=
''
;
stream
.
eatWhile
(
function
(
c
)
{
if
(
c
!=
'
'
)
{
parsedLang
+=
c
;
return
true
;
}
return
false
;});
state
.
langs
.
push
(
parsedLang
);
stream
.
next
();
transitState
(
state
,
'
'
);
return
'
string-2
'
;
}
if
(
ch
==
'
^
'
)
{
stream
.
next
();
transitState
(
state
,
'
^
'
);
var
parsedType
=
''
;
stream
.
eatWhile
(
function
(
c
)
{
if
(
c
!=
'
>
'
)
{
parsedType
+=
c
;
return
true
;
}
return
false
;}
);
state
.
types
.
push
(
parsedType
);
stream
.
next
();
transitState
(
state
,
'
>
'
);
return
'
variable
'
;
}
if
(
ch
==
'
'
)
{
transitState
(
state
,
ch
);
}
if
(
ch
==
'
.
'
)
{
transitState
(
state
,
ch
);
}
}
};
});
CodeMirror
.
defineMIME
(
"
text/n-triples
"
,
"
ntriples
"
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment