Environment requirements for Han.js
masterjsdom.repository·master·Indexed 25 days ago
https://github.com/ethantw/hanA CSS typography framework optimized for Hanzi (Chinese characters) that combines semantic styling, character design, and advanced typesetting. It supports Traditional Chinese, Simplified Chinese, and Japanese, providing a standardized environment for both traditional and modern screen reading. Version 3.3.0 can be installed via NPM, Bower, or the hanzi-rails gem, and is available via CDN.
jsdom.Han uses the :lang pseudo-class to apply language-specific styles. Because of this, direct style overrides can lead to unexpected results.
Affected areas include:
section elements (affects font-family only).html element (affects font-family only).Recommended Solution:
Instead of using !important, ensure proper style inheritance by adding appropriate language attributes to parent elements or using more specific selectors. Use the browser DOM inspector to understand the inheritance and override relationships.
To implement han-css correctly, follow these steps:
han.min.css (or import it via Sass/Stylus) before all other stylesheets in your project.han.min.js and add the class han-init to your <html> element. This triggers the DOM-ready rendering process.You can install Han.css using NPM, Bower, or as a Rails gem.
# NPM
npm install --save han-css
# Bower
bower install --save Han
# Rails
gem install 'hanzi-rails'If you do not need to customize the styles, you can use the pre-compiled CSS, JavaScript, and Web Fonts provided via cdnjs. This is recommended for fast downloads and caching.
CSS Link:
<link rel="stylesheet" media="all" href="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.css">JavaScript Script:
<script src="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.js"></script>Web Fonts:
//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/font/han.woff//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/font/han.otf<link rel="stylesheet" media="all" href="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.js"></script>han-css by using variables or module imports in Sass or Stylus. This allows you to create a bespoke stylesheet tailored to your specific design requirements.You can install Han using various package managers depending on your environment:
npm install --save han-cssbower install --save Hangem install 'hanzi-rails'npm install --save han-cssTo implement Han.css in your project, follow these steps:
han.min.css before all other styles in your project (or import it via Sass/Stylus).han.min.js. To activate DOM-ready rendering, add the class han-init to your <html> tag.If you do not need customization, you can use the pre-compiled CSS, JavaScript, and Web Fonts via cdnjs.com for faster downloads and caching.
CSS
<link rel="stylesheet" media="all" href="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.css">JavaScript
<script src="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.js"></script>Web Fonts
//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/font/han.woff//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/font/han.otf<link rel="stylesheet" media="all" href="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/Han/3.3.0/han.min.js"></script>To integrate Han into your website, follow these steps:
han.min.css (or the Han Sass/Stylus source) before your existing custom styles.han.min.js if you need advanced rendering features. To enable DOM-ready rendering, add the han-init class to your <html> tag.You can install the han-css package using one of the following package managers depending on your environment:
hanzi-rails gem for Ruby on Rails applications.npm install --save han-css
bower install --save Han
gem install 'hanzi-rails'Han.css uses the :lang attribute for numerous style corrections, which can cause unexpected style overwriting.
Affected elements:
<i>)font-family only)html root element (affects font-family only)Recommended Solution:
Instead of using !important, manage styles by adding the corresponding language attribute, using parental elements, or applying more specific selectors to respect CSS inheritance rules.