Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wikiformat #164

Open
wants to merge 54 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b0316a7
wikiformat in progress
mistermboy Jun 29, 2020
051565a
wikiFormat v0
mistermboy Jun 30, 2020
3ab6360
working on #153
mistermboy Jul 7, 2020
db7e801
solved #153
mistermboy Jul 7, 2020
ba3d3af
fixed comments after shapes
mistermboy Jul 7, 2020
667e15b
solved cypress dependency problem
mistermboy Jul 10, 2020
8d6cf2b
shor valueSets tags
mistermboy Jul 10, 2020
5ed79e5
fixed getSemicolonIfNeedeed
mistermboy Jul 10, 2020
da48928
solved #157
mistermboy Jul 10, 2020
c5ac307
fixed hasComments method
mistermboy Jul 13, 2020
cbaa21b
prettyprinter behaviour change with one line inlineshapes
mistermboy Jul 13, 2020
b502c05
wikiformat scroll oK
mistermboy Jul 13, 2020
6a4f49a
pretty comments (ugly code)
mistermboy Jul 13, 2020
e481848
prettifyComments
mistermboy Jul 13, 2020
26a2467
check yashe errors before wikiformat
mistermboy Jul 13, 2020
343088b
undo/redo history wikiformat
mistermboy Jul 13, 2020
26202e1
tooltipUtils refactor
mistermboy Jul 14, 2020
62e36de
getEntityData
mistermboy Jul 14, 2020
749dc19
fixed entityData.title exception
mistermboy Jul 14, 2020
99655e7
wikiFormat btn adjustment
mistermboy Jul 15, 2020
308af36
...
mistermboy Jul 22, 2020
a6099f6
removed unused method in node.js
mistermboy Jul 29, 2020
ab584a5
removed wikidata cache
mistermboy Jul 29, 2020
df1e7b0
removed logs
mistermboy Jul 29, 2020
9374353
fixed valueSet bug with <...>
mistermboy Jul 30, 2020
48cd53b
fixed simple tconstraint bug
mistermboy Jul 30, 2020
e33f0ef
[PRETTY] afterTriples
mistermboy Jul 30, 2020
c904eab
increased performance
mistermboy Jul 30, 2020
6401713
[Autocompleters] Ctrl-Space msg and autoshows
mistermboy Jul 31, 2020
f31ce55
[Autocompleters] Keywords and prefixes splited
mistermboy Jul 31, 2020
c328fa5
[Autocompleters] Wikibase adjustment
mistermboy Jul 31, 2020
e2f421a
wikiformat in progress msg
mistermboy Aug 3, 2020
373e826
wikistop btn
mistermboy Aug 3, 2020
bb94939
enable/disable editor while format
mistermboy Aug 3, 2020
407f5ff
new wikiformat logo
mistermboy Aug 3, 2020
02a95dc
Generate Wikidata COmments example
mistermboy Aug 3, 2020
56ea916
multicomments in the same line with just one #
mistermboy Aug 4, 2020
aee484e
prettyfyOnStop
mistermboy Aug 4, 2020
560b6a3
fixed wikiformat bug when non wikidata entities iris before constraints
mistermboy Aug 4, 2020
b2875d0
fixed #159
mistermboy Aug 4, 2020
b96d383
LOGICAL_OR const
mistermboy Aug 4, 2020
1de09d8
error check pretty
mistermboy Aug 4, 2020
bda7cae
alermsg when errors before wikiformat
mistermboy Aug 5, 2020
92ca5f9
solved prettyprint bug with | after non existing triples
mistermboy Aug 5, 2020
a1bb31b
rm blank comments
mistermboy Aug 6, 2020
3223cdd
fixed history problem
mistermboy Aug 6, 2020
4ae7dfe
title wikiBtn
mistermboy Aug 7, 2020
bf9ca97
solved #150
mistermboy Aug 10, 2020
27ebec4
solved #149
mistermboy Aug 10, 2020
53f3a13
solved #163
mistermboy Aug 10, 2020
293846b
solved small bug with ]
mistermboy Aug 10, 2020
7234982
wikiformat new replacement comments system
mistermboy Aug 11, 2020
2fbf431
Delete Example-77-Difference-between-Or-and-|
mistermboy Nov 11, 2020
e33899b
dependency update
mistermboy Nov 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check yashe errors before wikiformat
  • Loading branch information
mistermboy committed Jul 13, 2020
commit 26a24677176a1ceb1feb75c95fc44132b72cb147
85 changes: 55 additions & 30 deletions dist/yashe.bundled.min.js

Large diffs are not rendered by default.

53 changes: 35 additions & 18 deletions src/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,42 @@ YASHE.defaults = $.extend(true, {}, YASHE.defaults, {
/**
* Default shape
*/
value: `PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @<#operating_system>

<#operating_system> {
p:P31 [ wd:Q9135 ] ; #instancia de #sistema operativo
p:P31 [ wd:Q42 ] ; #instancia de #Douglas Adams
p:P31 [ wd:Q5 ] #instancia de #ser humano
}



value: `
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>


start = @<human>

<human> EXTRA wdt:P31 {
wdt:P31 [wd:Q5];
wdt:P21 [wd:Q6581097 wd:Q6581072 wd:Q1097630 wd:Q1052281 wd:Q2449503 wd:Q48270]?;
wdt:P19 . ?;
wdt:P569 . ? ;
wdt:P735 . * ;
wdt:P734 . * ;
wdt:P106 . * ;
wdt:P27 @<country> *;
wdt:P22 @<human> *;
wdt:P25 @<human> *;
wdt:P3373 @<human> *;
wdt:P26 @<human> *;
wdt:P40 @<human> *;
wdt:P1038 @<human> *;
wdt:P103 @<language> *;
wdt:P1412 @<language> *;
wdt:P6886 @<language> *;
rdfs:label rdf:langString+;
}

<country> EXTRA wdt:P31 {
wdt:P31 [wd:Q6256 wd:Q3024240 wd:Q3624078] +;
}

<language> EXTRA wdt:P31 {
wdt:P31 [wd:Q34770 wd:Q1288568] +;
}
`,

highlightSelectionMatches: {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/formatUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ var copyLineDown = function(yashe) {


var wikiFormat = async function(yashe){
if(yashe.hasErrors())return;
yashe.prettify();
yashe.setOption('readOnly',true);

Expand All @@ -181,7 +182,7 @@ var copyLineDown = function(yashe) {
dataType: 'jsonp',
})
if(result.entities){
comments +=' #'+result.entities[entity].labels[language].value;
comments +=' # '+result.entities[entity].labels[language].value;
valueSetSize--;
if(valueSetSize<0){
let replacement = '';
Expand Down
27 changes: 17 additions & 10 deletions src/utils/pretty/prettyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ function prettify(yashe){
let shapesStr = getShapesStr(shapes);
let prettified = initialComments+initialDirectivesAndStartsStr+shapesStr;






// Is there any change?
// It is true that without this check the user
// wouldn't appreciate the difference but yashe
Expand Down Expand Up @@ -459,11 +454,13 @@ function prettifyComments(){
let longest = getLongestCommentedLine();
for (var l = 0; l < yashe.lineCount(); ++l) {
let lineTokens = formatUtils.getNonWsLineTokens(yashe.getLineTokens(l));
lineTokens.map(t=>{
if(t.type == 'comment') {
yashe.replaceRange(printUtils.getSeparator(longest-t.start)+t.string,{line:l,ch:t.start},{line:l,ch:t.end})
}
});
if(!hasOnlyComments(lineTokens)){
lineTokens.map(t=>{
if(t.type == 'comment') {
yashe.replaceRange(printUtils.getSeparator(longest-t.start)+t.string,{line:l,ch:t.start},{line:l,ch:t.end})
}
});
}
}
}

Expand All @@ -479,6 +476,16 @@ function getLongestCommentedLine(){
return longest;
}

/**
* Returns true if the line has onlyComments
*/
function hasOnlyComments(lineTokens){
return lineTokens.reduce((acc,t)=>{
if(t.type!='comment')acc=false;
return acc;
},true);
}


function isCursorToken(token1,token2,line){
return token1.start == token2.start
Expand Down