Skip to content

Commit

Permalink
Improve the way all languages are registered to reveal.js
Browse files Browse the repository at this point in the history
Fix code to correctly register languages to reveal.js, when loading from a browser.

Add missing keywords to ATL.
  • Loading branch information
sunye committed Jan 31, 2020
1 parent b5f0fbb commit 1604463
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 31 deletions.
139 changes: 117 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/mde-languages.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:bundle": "browserify ./src/mde-languages.js | uglifyjs -mc > ./build/mde-languages.min.js"
"build": "browserify ./src/mde-languages.js | uglifyjs -mc > ./build/mde-languages.min.js"
},
"repository": {
"type": "git",
Expand All @@ -32,5 +32,9 @@
"browserify": "^16.5.0",
"uglify-js": "^3.7.6",
"uglifyjs": "^2.4.11"
},
"dependencies": {
"highlight.js": "^9.18.0",
"js-beautify": "^1.10.3"
}
}
4 changes: 2 additions & 2 deletions src/atl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = function(hljs) {
var TYPES = 'Boolean Integer UnlimitedNatural Real String OrderedSet Tuple OrderedSet Bag Set Sequence OclInvalid OclVoid TupleType OclState Collection OclMessage ';
var TYPES = 'Boolean Integer UnlimitedNatural Real String OrderedSet Tuple OrderedSet Bag Set Sequence OclInvalid OclVoid OclUndefined OclAny TupleType OclState Collection OclMessage ';
return {
case_insensitive: false,
beginKeywords: 'module rule ',
keywords: {
keyword: 'module rule to from thisModule abstract query IN OUT extends helper def uses ' +
'create refining ' +
'create refining context ' +
'select collect reject forAll exists collectNested closure iterate flatten one first ' +
'includes excludes excludesAll includesAll including excluding union intersection ' +
'size avg isEmpty notEmpty count sum average ' +
Expand Down
12 changes: 7 additions & 5 deletions src/mde-languages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = function(hljs) {
hljs.registerLanguage('atl', require('./atl'));
hljs.registerLanguage('ocl', require('./ocl'));
hljs.registerLanguage('xcore', require('./xcore'));
};
var hljsDefineOCL = require('./ocl')
var hljsDefineATL = require('./atl')
var hljsDefineXcore = require('./xcore')

hljs.registerLanguage('ocl', hljsDefineOCL);
hljs.registerLanguage('atl', hljsDefineATL);
hljs.registerLanguage('xcore', hljsDefineXcore);
2 changes: 1 addition & 1 deletion src/ocl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ module.exports = function(hljs) {
hljs.COMMENT('--', '$')
]
}
};
};

9 comments on commit 1604463

@joshgoebel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume your doing this yourself because you wanted one file instead of 3?

@sunye
Copy link
Collaborator Author

@sunye sunye commented on 1604463 Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyyc514 I'm sorry, I don't understand your question.

@joshgoebel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlight.js will build individual files for you automatically.

@sunye
Copy link
Collaborator Author

@sunye sunye commented on 1604463 Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware. Is there a pointer for the doc that explains the subprojects building process?

@joshgoebel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented on 1604463 Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm waiting for some other PRs to get reviewed first and then this will be merged into the master branch. (although the distributable it builds will work in any case).

@sunye
Copy link
Collaborator Author

@sunye sunye commented on 1604463 Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The text is somewhat confusing for me. As I understand, I should:

  1. Checkout highlight.js
  2. Checkout my project inside the highlight.js/extra folder.
  3. Use the build scripts to create a distributable file.

Is it correct?
Once the distributable file is created, what should I do? Will it be distributed along with hightlight.js, or should I find another way to distribute it?

@joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented on 1604463 Feb 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You add it to your git project, in the dist folder where it’s created. That’s the idea. Or you can distribute it however you want. It’s just a convention to make finding the distributable easier for those who only need the file.

@joshgoebel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe see my last thoughts here: highlightjs/highlight.js#2328

Please sign in to comment.