Skip to content

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

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

QingWei-Li merged 1 commit into
docsifyjs:developfrom
Bowl42:fix/strip-html-from-page-title

Conversation

@Bowl42

@Bowl42 Bowl42 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

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.js — onRender() 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

vercel Bot commented Mar 4, 2026

Copy link
Copy Markdown

@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
@sy-records sy-records mentioned this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants