Skip to content

[callout]: preserve spaces in named titles - #618

Open
evnluo wants to merge 2 commits into
devfrom
fix/callout-title-spaces-605
Open

[callout]: preserve spaces in named titles#618
evnluo wants to merge 2 commits into
devfrom
fix/callout-title-spaces-605

Conversation

@evnluo

@evnluo evnluo commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #605

Summary

  • recover named callout values from the joined Hexo tag arguments after Hexo has stripped quote characters
  • preserve spaces in title values while keeping named type, icon, and class parsing intact

Verification

  • The repository has no test runner; the PR build workflow will run npm install and npm run build.
  • No generated build artifacts are included.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

@evannotfound

Copy link
Copy Markdown
Owner

@evnluo Any potential code simplification to be made and make it cleaner?

@evnluo

evnluo commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

I reviewed the change. The recovery approach is reasonable, but I’d make two small cleanups before merging:

  1. Parse the raw named-argument positions once. getCalloutNamedValue() currently calls findNamedArgs(rawArgs) separately for each field. Compute const rawNamedArgs = findNamedArgs(rawArgs) once in parseNamedArgs() and pass it into getRawNamedValue(). That keeps the behavior the same while removing repeated scans and making the data flow easier to follow.
  2. Use CALLOUT_NAMED_KEYS as the single source of truth for both the boundary detection and supportsNamed. The six keys are currently listed twice.

I’d keep the quote-recovery state machine local to callout.js. It is clearer than trying to make the shared tag parser infer boundaries after Hexo has already split the arguments, and I wouldn’t add a broader abstraction for this one caller. The state machine itself is worth keeping because a regex-only solution would be fragile around quoted or escaped values.

So I don’t see a behavior change that’s needed, just those two refactors to make the added code easier to maintain. Since the repo has no test runner, I’d manually check spaced and quoted title values alongside named type, icon, and class, then use npm run build for validation.

@evannotfound

Copy link
Copy Markdown
Owner

/lumon review and implement the potential simplification

@evnluo

evnluo commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Implemented the cleanup in 71ab064:

  • Raw named-argument positions are now computed once per parse and reused for each callout field.
  • CALLOUT_NAMED_KEYS now drives both supported-key detection and value-boundary detection.

Validation:

  • Focused Node harness passed for spaced and quoted titles, multi-token icons/classes, and the simple variant.
  • npm run build passed locally.
  • PR Build Check and PR Preview Build both passed.

The PR remains open and mergeable.

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.

2 participants