Padax / w-components

JavaScript library based on Web Components.
MIT License
22 stars 2 forks source link

Add laguage type property for Code #130

Closed nizniz187 closed 2 years ago

nizniz187 commented 2 years ago

Auto-detecting is not always correct. For example, npm install is not detecting correctly. That's why we need a property to let user assign the language.

cwpeng commented 2 years ago

How about this issue? Is it matter now?

nizniz187 commented 2 years ago

I will implement it next.

nizniz187 commented 2 years ago

Added an attribute lang for user to assign language manually. If this attribute is not set or set to empty, then an auto detection will be applied.

For example, this code is highlighted as HTML below in auto detection mode: image But if we assign the lang attribute to javascript, it would look slightly different: image

For the initial problem this issue was intending to solve, the npm script looked like this in auto detection (obviously wrong): image Now it should be assigned correctly as lang='shell': image which looks simply nothing highlighted, but is actually highlighted as designed (see the official demo code below.) image In this situation, add a $ sign in the front could make it look better :p image

nizniz187 commented 2 years ago

@cwpeng Please help review.

cwpeng commented 2 years ago

looks good.