-
Notifications
You must be signed in to change notification settings - Fork 124
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
Upgrade js-beautify and provide option to turn it off #1116
Conversation
@ang-zeyu can I get your review on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick look:
ecf7a68
to
a4e186d
Compare
7778f34
to
da56974
Compare
4ead9a6
to
e7457bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@ further reviewers there's quite a few changes to test_site_convert
and test_site_template
, but its expected since htmlBeautify
is off for those. Might be nice to have a mix of test sites with this option on / off as well. If it wasn't broken after htmlBeautify
ing it before, it shouldn't be broken by turning off htmlBeautify
either. ( also since htmlBeautify
is the final step in page generation )
Some miscellaneous changes were observed for the other test sites with htmlBeautify
turned on otherwise which are expected due to the bug fixes / changes in htmlBeautify
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to default to enabling htmlBeautify
(rationale in comments). As always though, if anyone has differing opinions on this I'm happy to discuss 🙂
docs/userGuide/siteConfiguration.md
Outdated
@@ -199,6 +199,18 @@ The example above uses tags as an example of configuring plugin settings, refer | |||
|
|||
**Specifies that the website should use MarkBind's search functionality.** Default: `true`. See [User Guide: Making the Site Searchable](makingTheSiteSearchable.html) for more details. | |||
|
|||
#### **`htmlBeautify`** | |||
|
|||
**Toggles-on html beautification done by [js-beautify](https://github.com/beautify-web/js-beautify) for html files generated by MarkBind.** By default, MarkBind turns this option off to improve the performance of the MarkBind `build` process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally lean towards defaulting to having htmlBeautify
on, and allowing users to turn it off if they really wish to get the performance improvement.
The reason behind this are:
- The build process generally isn't very time critical or performance sensitive for most use cases
- Standardisation of our generated files make it easier to ignore diffs for non-material changes (i.e. markbind might make changes internally that changes the indendentation of files, but these changes don't actually change the markup of the site)
- Having inconsistently formatted files by default isn't really a good look for the product
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build process generally isn't very time critical or performance sensitive for most use cases
Hmm, although there's markbind serve -o
now, it could still really help when writing the page ( ~20% performance gains ).
Having inconsistently formatted files by default isn't really a good look for the product
Good point though
Standardisation of our generated files make it easier to ignore diffs for non-material changes (i.e. markbind might make changes internally that changes the indendentation of files, but these changes don't actually change the markup of the site)
The test sites which don't have htmlBeautify
turned on are only the template sites
and test_site_convert
.
In this sense, how about changing the one for the template sites to be on
instead? This should solve the problem of presenting a good first impression, while defaulting to off
if it is not specified.
test_site_convert
would be an acceptable compromise here I think, but a future pr could always tackle this 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, although there's markbind serve -o now, it could still really help when writing the page ( ~20% performance gains ).
Good point. I wonder what the performance cost for turning beautify on is. Would anyone happen to have some metrics on that?
In this sense, how about changing the one for the template sites to be on instead? This should solve the problem of presenting a good first impression, while defaulting to off if it is not specified.
I think that the build assets that we generate for the user matters as well. For the typical user, build performance is probably not a big concern. Users who are performance conscious are also generally more willing to tinker with their tools. But this, of course, is difficult to know for certain without further user research :P
I feel that the defaults should be set in a way such that a typical user needs minimal configuration to get an output they are happy with. In this case, it seems like focusing on user friendliness might make more sense than optimizing for performance performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe as part of user research we can ask @damithc to see if he happens to have any thoughts on this? 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I wonder what the performance cost for turning beautify on is. Would anyone happen to have some metrics on that?
Yup, its in the original issue #1067
I think that the build assets that we generate for the user matters as well. For the typical user, build performance is probably not a big concern.
Wouldn't adding htmlBeautify: on
to the template solve this though? ( since these are the sites the user starts with during `markbind init )
I feel that the defaults should be set in a way such that a typical user needs minimal configuration to get an output they are happy with.
This does feel cleaner, my worry here is that performance of markbind serve
also affects ux ultimately though. Not too sure which of the two we should go with either 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, its in the original issue #1067
Thanks for pointing me to it :)
Wouldn't adding htmlBeautify: on to the template solve this though? ( since these are the sites the user starts with during `markbind init )
Ah okay, I see what you mean there. I still think that it makes logical sense for the default behaviour and the default configs we provide to be aligned, but changing the template site.json
might be an acceptable compromise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damithc could we get your opinion on whether performance / neatness of generated source files should be prioritised in the default behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps safer to prioritize neatness as basic users might not need the performance gain (which will be tiny for small web sites) but might get a shock if they to take a look at the generated code? I am OK to go either way though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, we can shift to enabling it by default with an option to turn it off.
@@ -922,7 +923,7 @@ class Site { | |||
injectMarkdownItSpecialTags(tagsToIgnore); | |||
Page.htmlBeautifyOptions = { | |||
indent_size: 2, | |||
content_unformatted: ['pre', ...tagsToIgnore], | |||
content_unformatted: ['pre', 'textarea', ...tagsToIgnore], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for adding this new textarea
option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
html beautify was updated with this as well since our last version; unfortunately the options don't merge with the defaults, so a little manual inspection has to be done here
https://github.com/beautify-web/js-beautify/blob/master/js/src/html/options.js
6bf388e
to
d9628ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an update on master, otherwise just one nit!
d9628ff
to
47c9443
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
* 'master' of https://github.com/MarkBind/markbind: (41 commits) Document adding new site content in DG (MarkBind#1153) Add relative date feature (MarkBind#908) Use <br> to separate lines of code block (MarkBind#1176) Parse popovers for footnotes (MarkBind#1155) Resolve comments Expand test extensions and fix whitespace checks (MarkBind#1156) Address comments Upgrade js-beautify and provide option to turn it off (MarkBind#1116) Normalize inline puml line ending before hashing (MarkBind#1174) Update tests (MarkBind#1178) Remove fixed bugs from test\functional\test_site\bugs\index.md` (MarkBind#1148) Fix bug in Search for UG and DG (MarkBind#1147) Add inline puml support (MarkBind#1100) Fix hrefs for headings with angular brackets (MarkBind#1089) Update tests for 2.13.1 (MarkBind#1169) 2.13.1 Update vue-strap version to v2.0.1-markbind.39 Fix fontawsome icons don't show underlines to indicate modal/tooltip (MarkBind#1133) 2.13.0 Update test files ...
MarkBind currently runs js-beautify v1.7.5, although later versions of the library have been released (the latest version as of this PR is v1.10.3). Let's upgrade js-beautify to the latest version. Turning off js-beautify can improve the performance of MarkBind's build process. Let's also give the user the option to turn off js-beautify (whenever necessary) through an option in site.json.
It seems like the changes to the expected test files in #1116 were overwritten by later PRs. Let's update the test files so that they are formatted by js-beautify again.
Previously in 8a5c42c we updated the test files because we thought that the changes from #1116 were overwritten by later PRs. However, it turned out that the local node modules was not updated after pulling from master, hence the original changes were correct. Let's revert the changes to the test files.
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [x] Enhancement to an existing feature
Resolves #1067
What is the rationale for this request?
We use an old version of
js-beautify
(v1.7.5
as opposed to the latestv1.10.3
).As documented in #1067,
js-beautify
affects the performance of our build process. It would be beneficial for MarkBind to turn offjs-beautify
, at the same time allowing users to choose to turn it on if needed.What changes did you make? (Give an overview)
js-beautify
tov1.10.3
jsBeautify
option insite.json
, which when set totrue
will make use ofjs-beautify
on HTML filesProvide some example code that this change will affect:
Added a check in multiple places similar to this -
Is there anything you'd like reviewers to focus on?
Since I've updated the
js-beautify
library, there have been changes in the expected output of the test sites according to the new changes/rules added in the library.Also, the test_site_convert and test_site_template run
init
, which means they will havejs-beautify
turned off. Just a heads up in case anyone was wondering why the formatting is off for the HTML files in those test sites.Testing instructions:
npm run test
Proposed commit message: (wrap lines at 72 characters)