Closed gdolle closed 7 years ago
Oh, large diff.. I'll look it lator. Can you separate refactor PR and feature PR if possible.
@azu Actually, features are minors and deeply dependent of the of refactor. It'd be quite difficult to separate now.
Would it be ok to keep it as one PR ?
The related features changes are
test-parser.js
(I added comments on file changes to help)
@gdolle fmm, I want to separate big PR to smll PRs by following reasons.
Add Url support #42 (sync http request using sync-request modules + check url valid-url)
Sync request is simple solution, but it is not correct solution. Because GitBook support async hook.
(Not actuall code)
// THIS IS IMAGINE
module.exports = {
hooks: {
"page:before": function(page) {
var options = this.options.pluginsConfig["include-codeblock"];
var pageDir = path.dirname(page.rawPath);
var parseResults = parse(page.content, pageDir, options);
var promises = results.map(result => {
return requestUrlAndCreateReplaceContent(result).then(newContent => {
replaceContent(page, newContent);
});
});
return Promise.all(promises); // GitBook support async by returing promise
}
}
};
and
Immutable.js is overlarge for this project. I recommened that use ES2015 Map + Poilyfill insteadof immutable.js.
Of course, Welcome to bugfix, but the bugfix should not contains other feature. I hesitate to merge the bugfix PR.
Sorry, slow response.
Does ES2015 Map guaranty const Map values ?
Actually refactor parser:
I agree for the url feature, it is from far not perfect. I'll separate it in another PR.
(Currently, this project mixed codeing style, We should apply ESLint #39)
@azu I updated the code.
I didn't apply yet Eslint, I'll have a look into that.
@azu I added eslint config following #39 and fix current code following the convention. I also added a "check" script which test eslint on src/ and test/. This script is executed in travis, therefore we can see if something is not good with respect to the coding style. Let me know if it's ok for you like that. ;)
Sorry for the late reply. I updated the code relatively to your last review
@gdolle Thanks for great work!
Major refactoring for the parser. Breaking changes (3.1.0 ?)
Changelog
src/options.js
edit:true
instead ofedit:"true"
, to be more consistent (this fix an ace plugin bug).template
,fixlang
,lang
,theme
are now also local/global options. We can set a template per code, a theme per code, etc.. or globally.lang-typescript
to use uniform optionslang:"typescript"
to be consistent with other options and to simplify functions.[import:"tag0,tag1,..."](fixtures/test.js)
to import several snippets into one codeblock , for examplewill produce
It should work far better with this PR :)
I've been noticed that ace plugin might crash after a page reload in previous version, but I couldn't reproduce that problem. However, these changes fix some bugs and "might" be fix for that behaviour, we will see.
NB: It might be interesting to have a look to async operation in the future to optimize the code.
@azu waiting for your review, you'll have some work ;)