Skip to content

How to contain a single quote or a double quote in images' title and alt? #4715

Closed
@alohaia

Description

@alohaia

Check List

Please check followings before submitting a new issue.

Question

I simply included a single quote in an image's title and alt. It isn't rendered as expected.
Actually, the image didn't even appear on the result.

{% asset_img "Gower's_sign.png" "Gower's sign'Gower's sign" %}

Environment & Settings

Node.js & npm version

# node -v
v16.3.0
# npm -v
7.16.0

Hexo and Plugin version(npm ls --depth 0)

[email protected] /home/aloha/blog
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] (git+ssh://[email protected]/next-theme/hexo-next-fireworks.git#cccfe84bccccc91f4dae24b7ceb4050ee324fb59)
├── [email protected]
├── [email protected]
├── [email protected] (git+ssh://[email protected]/CHENXCHEN/hexo-renderer-markdown-it-plus.git#f2dd1b25738992efc391ba9da398a9c6a7efb105)
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Your package.json package.json

{
    "name": "hexo-site",
    "version": "0.0.0",
    "private": true,
    "scripts": {
        "build": "hexo generate",
        "clean": "hexo clean",
        "deploy": "hexo deploy",
        "server": "hexo server"
    },
    "hexo": {
        "version": "5.4.0"
    },
    "dependencies": {
        "hexo": "^5.0.0",
        "hexo-deployer-git": "^3.0.0",
        "hexo-generator-archive": "^1.0.0",
        "hexo-generator-category": "^1.0.0",
        "hexo-generator-feed": "^3.0.0",
        "hexo-generator-index": "^2.0.0",
        "hexo-generator-searchdb": "^1.3.3",
        "hexo-generator-sitemap": "^2.1.0",
        "hexo-generator-tag": "^1.0.0",
        "hexo-next-fireworks": "github:next-theme/hexo-next-fireworks",
        "hexo-related-popular-posts": "^5.0.1",
        "hexo-renderer-ejs": "^1.0.0",
        "hexo-renderer-markdown-it-plus": "github:CHENXCHEN/hexo-renderer-markdown-it-plus",
        "hexo-renderer-stylus": "^2.0.0",
        "hexo-server": "^2.0.0",
        "markdown-it-task-checkbox": "^1.0.6"
    }
}

Others

I edited node_modules/hexo/lib/plugins/tag/img.js so I can use \\sq and \\dq instead.

          title = typeof match[1] == 'string'
                    ? match[1].replace(/\\sq/g, "'").replace(/\\dq/g, '"')
                    : '';
          alt = typeof match[2] == 'string'
                    ? match[2].replace(/\\sq/g, "'").replace(/\\dq/g, '"')
                    : '';
{% asset_img "Gower's sign.png" "Gowers\\sqs sign'Gowers\\sqs sign'" %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions