Skip to content

Add pangu.js instead of auto_spacing in hexo#51

Closed
sli1989 wants to merge 2 commits intotheme-next:masterfrom
sli1989:pitch
Closed

Add pangu.js instead of auto_spacing in hexo#51
sli1989 wants to merge 2 commits intotheme-next:masterfrom
sli1989:pitch

Conversation

@sli1989
Copy link
Collaborator

@sli1989 sli1989 commented Jan 19, 2018

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines.
  • Tests for the changes have been added (for bug fixes / features).
    • Muse | Mist have been tested.
    • Pisces | Gemini have been tested.
  • Docs have been added / updated (for bug fixes / features).

PR Type

What kind of change does this PR introduce?

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Build related changes.
  • CI related changes.
  • Documentation content changes.
  • Other... Please describe:

What is the current behavior?

To use auto spacing in hexo, you need to $ npm install hexo-filter-auto-spacing --save and auto_spacing: ture. but there are many issues using hexo-filter-auto-spacing in some special circumstance like chinese and english headlines.

Issue Number(s): #4, #5, #1608, #27

What is the new behavior?

I recommend to use the pangu.js to realize the auto spacing. $ npm install pangu --save seems to be not working. I need to add the js in \themes\next\layout\_layout.swig

  • It seems just a need for environment in chinese and english.
  • If you have already installed the hexo-filter-auto-spacing in your local files, you must npm uninstall hexo-filter-auto-spacing firstly.
  • Then you can set auto_spacing: false in your root _config.yml , or just comment it.

Files modified:

  1. \themes\next\layout\_layout.swig
  • add <script src="https://cdnjs.cloudflare.com/ajax/libs/pangu/3.3.0/pangu.min.js"></script> in <head>
  • add <script>pangu.spacingPage();</script> in <body>

How it looks?

_20180119144008

Copy link
Member

@wafer-li wafer-li left a comment

Choose a reason for hiding this comment

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

I think it will be better to combine those two lines into a new swig file and include it in _layout.swig

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 19, 2018

however, I am a little white.

@wafer-li
Copy link
Member

……

You could take my #32 PR as a reference, and please provide a config for it.


Besides, little white is Chinglish. You should say that you know little about swig.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 19, 2018

😂 haha...
Perhaps i have no time and no energy to do it. i will try it...

@wafer-li
Copy link
Member

If you don't have time for it.

I could just implement it, but I need tests for Muse | Mist scheme since I don't use those schemes.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 19, 2018

it would be good.
i can run test.

Copy link
Member

@ivan-nginx ivan-nginx left a comment

Choose a reason for hiding this comment

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

Pushed branch from Wafer still not updated in this pull.

@ivan-nginx
Copy link
Member

And what mean auto spacing can u show it? I just don't see what this it.

@wafer-li
Copy link
Member

@ivan-nginx

Working on it, I am now writing a test page.

And what mean auto spacing can u show it? I just don't see what this it.

Just add spaces between Chinese and English word make it more beautiful, like this:

# Original
你hello好

# After
你 hello 好

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 19, 2018

So, this is for Chines only? I think need to create separated repo with lib for this. With src included.

@wafer-li
Copy link
Member

@ivan-nginx

So, this is for Chines only? I think need to create separated repo with lib for this.

OK, I am just going to discuss this with you.

For now I am just finishing porting from this PR.

When I finish, I will try to implement the separated lib way.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 19, 2018

maybe mixed language situation...

@wafer-li wafer-li mentioned this pull request Jan 19, 2018
15 tasks
@ivan-nginx
Copy link
Member

As i right understand, in Chinese language there are no spaces to use? Letters write together always?

@wafer-li
Copy link
Member

@ivan-nginx
Yes, Chinese language doesn't have spaces, just have paragraph and punctuations.

We use the knowledge of the language and our experiences to determine what is so-called "word" in the English world which separated by space.

@ivan-nginx
Copy link
Member

Alright, then need to created separated lib for that. This pull resumed in #56.

@ivan-nginx ivan-nginx closed this Jan 19, 2018
@ivan-nginx ivan-nginx added this to the v6.0.2 milestone Jan 19, 2018
@sli1989 sli1989 deleted the pitch branch January 19, 2018 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants