next-theme / hexo-theme-next

🎉 Elegant and powerful theme for Hexo.
https://theme-next.js.org
Other
2.45k stars 434 forks source link

Undetected external links produced by hexo-renderer-pandoc #497

Closed roosephu closed 2 years ago

roosephu commented 2 years ago

Issue Checklist


Expected behavior

The link is to https://www.aaaaa.com/bbbbb/ccccc/ddddd/eeeee which is assumed external.

image

Actual behavior

image

Steps to reproduce the behavior

Use hexo-renderer-pandoc to render this line:

dfasfasd fsa sa d [A B C D E F G H I J K L M N](https://www.aaaaa.com/bbbbb/ccccc/ddddd/eeeee) dfasdf asdf as fas

Environment Information

Node.js and NPM Information

v17.5.0
8.4.1

Package dependencies Information

hexo-site@0.0.0 <A PRIVATE PATH>
├── hexo-deployer-git@2.1.0
├── hexo-deployer-rsync@1.0.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-feed@3.0.0
├── hexo-generator-index@1.0.0
├── hexo-generator-tag@1.0.0
├── hexo-hide-posts@0.1.1
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-pandoc@0.3.1
├── hexo-renderer-stylus@1.1.0
├── hexo-server@1.0.0
├── hexo-theme-next@8.10.1
├── hexo@6.1.0
└── highlight.js@11.5.0

Other Information

Pandoc outputs the html code with a line break:

<p>dfasfasd fsa sa d <a
target="_blank" rel="noopener" href="https://www.aaaaa.com/bbbbb/ccccc/ddddd/eeeee">A B C D E F G H I J
K L M N</a> dfasdf asdf as fas</p>

However, the regex in https://github.com/next-theme/hexo-theme-next/blob/master/scripts/filters/post.js#L19 uses a space ' ' to find all links so it can't find this link.

Changing the regex to /<a[^>]*\shref="([^"]+)"[^>]*>([^<]+)<\/a>/img solves the issue, but I'm not sure about its potential issues due to the lack of understanding to HTML.

welcome[bot] commented 2 years ago

Thanks for opening this issue, maintainers will get back to you as soon as possible!

stevenjoezhang commented 2 years ago

It seems that the regex multiline mode flag only affects the behavior of ^ and $.

stevenjoezhang commented 2 years ago

Fixed in https://github.com/next-theme/hexo-theme-next/commit/edf3675f32e9bd33b5613e48d3d11bd56cdb5f0e

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.