X Tutup
Skip to content

fix: strip HTML tags from config.name when setting page title#2690

Merged
QingWei-Li merged 1 commit intodocsifyjs:developfrom
Bowl42:fix/strip-html-from-page-title
Mar 4, 2026
Merged

fix: strip HTML tags from config.name when setting page title#2690
QingWei-Li merged 1 commit intodocsifyjs:developfrom
Bowl42:fix/strip-html-from-page-title

Conversation

@Bowl42
Copy link
Contributor

@Bowl42 Bowl42 commented Mar 4, 2026

Summary

  • Issue: The name config option supports HTML markup (e.g. <img src="logo.png">My Site) for rendering logos in the sidebar. However, this raw HTML is also used directly as part of document.title, causing the browser tab to display ugly markup like <img src="logo.png">My Site - Page Title.
  • Fix: Strip HTML tags from name using a regex before constructing the page title string, so only plain text content appears in the browser tab.

Changes

src/core/event/index.jsonRender() method:

  • Added plainName variable that strips HTML tags from config.name via name.replace(/<[^>]+>/g, '').trim()
  • Used plainName instead of name when constructing currentTitle for document.title

Before

name = '<img src="logo.png">My Site'
→ document.title = "Page - <img src=\"logo.png\">My Site"

After

name = '<img src="logo.png">My Site'
→ document.title = "Page - My Site"

Test plan

  • Set name to a value containing HTML (e.g. <img src="logo.png"><strong>My Site</strong>)
  • Verify the browser tab title shows only plain text (e.g. Page - My Site)
  • Verify the sidebar still renders the HTML correctly (logo + styled text)
  • Verify pages with plain text name config still work normally

Fixes #2610

🤖 Generated with Claude Code

The `name` config option can contain HTML markup (e.g. `<img>` tags) for
rendering a logo in the sidebar. However, this raw HTML was being used
directly in `document.title`, causing browser tabs to show markup like
`<img src="logo.png">My Site - Page Title`.

Strip HTML tags from `name` before using it in the page title so that
only the plain text content appears in the browser tab.

Fixes docsifyjs#2610

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 4, 2026

@Bowl42 is attempting to deploy a commit to the Docsify Team on Vercel.

A member of the Team first needs to authorize it.

@QingWei-Li QingWei-Li merged commit 0cfee34 into docsifyjs:develop Mar 4, 2026
1 of 2 checks passed
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.

Alternative Page Title Generator [v5-rc]

2 participants

X Tutup