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

fix: add more asset-searching locations and solve a known issue #271

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

Conversation

lucienshawls
Copy link

@lucienshawls lucienshawls commented Jan 18, 2024

This resolves #216.

Until now, if I would like to insert an image named image.jpg in a post with the filename foo.md with these configurations:

post_asset_folder: true
relative_link: false
marked:
  prependRoot: true
  postAsset: true

and the filesystem structure:

source/_posts
├── foo.md
└── foo/
    └── image.jpg

I have to use ![](image.jpg) instead of ![](foo/image.jpg) otherwise hexo would not generate a valid img src. However, if I would like to preview the markdown file while editing, I have to use the latter one. This is contradictory.

So I made a modification to allow hexo-renderer-marked to search for assets not only in current asset folder source/_posts/foo, but also in its parent folder source/_posts, so that ![](foo/image.jpg) can also be located and the src can be generated correctly.

Moreover, this change is compatible with the previous versions and developers can safely update the package to a new version without the need for changing each and every link in their blogs.

Notice: the changes have passed the tests on Linux (WSL2, Ubuntu 22.04).

I hope these changes are acceptable.

@lucienshawls lucienshawls changed the title Add more asset-searching locations and solves a known issue Add more asset-searching locations and solve a known issue Jan 18, 2024
@lucienshawls lucienshawls changed the title Add more asset-searching locations and solve a known issue fix: add more asset-searching locations and solve a known issue Jan 18, 2024
@coveralls
Copy link

Coverage Status

coverage: 100.0%. remained the same
when pulling a325590 on lucienshawls:master
into 1b09354 on hexojs:master.

@DexterMorgan0417
Copy link

the check is not passed ,your idea is very good,i have the same demand

@lucienshawls
Copy link
Author

I managed to resolve the lint problems. See if it helps.

@bl-sun
Copy link

bl-sun commented May 8, 2024

I need this.

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.

md img render part improvement of hexo-render-marked
4 participants