Skip to content
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

changed the judgement of whether it has been injected #5573

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mRNA16
Copy link

@mRNA16 mRNA16 commented Nov 15, 2024

What does it do?

When I introduced the Hexo injector in my blog post: 'Here we can see that between and there are many div blocks that we injected using the injector, and at the same time, between and there are JavaScript script blocks and canvas elements that we injected. I believe by now you can understand the functionality of the injector.' However, I found that the custom effects implemented through the injector were not working, so I checked the source code and found an issue with the logic that determines whether the injector has inserted content. When content like hexo injector body exists in my article, the injector mistakenly thinks it has already been inserted.
I tried to ensure that the comments and tags are tightly connected by using the condition (flag==='head_begin' && /<head.?>\s[\S\s]/.test(input)), but this causes the test cases in the test to fail. So, I changed the condition to if (input.includes(, it still causes the injector to fail. Therefore, I still have some doubts about the condition and test cases. Will a situation like really occur in thetest? I don’t think it will in practical applications. If this situation doesn’t occur, then using the regex condition (flag==='head_begin' && /<head.?>\s[\S\s]/.test(input))` to check if the comment and tag are connected seems like a better choice, as it can handle all the cases mentioned above. Of course, this is just my thought, and I would appreciate any guidance if I'm mistaken.

Screenshots

My homepage has

blocks inserted within the tag.
1
But after mentioning and in the article, the injector stopped working."
2
3

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

How to test

git clone -b injector_change https://github.com/mRNA16/hexo.git
cd hexo
npm install
npm test

@mRNA16
Copy link
Author

mRNA16 commented Nov 16, 2024

Oh,the comments mentioned in my blog text couldn't show in the website too!I mentioned the comments that mark the injector region here:' between ( ) and ( ) there are JavaScript script blocks and canvas elements that we injected. I believe by now you can understand the functionality of the injector.'

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.

1 participant