Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: 헤딩 앵커 링크 변환 시 HTML 포맷팅 보존하도록 수정 #283

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

Merged

Conversation

@archan0621
Copy link
Contributor

@archan0621 archan0621 commented Oct 30, 2025

closes #282

문제점

헤딩에 굵게, 기울임 등의 서식이 적용된 경우, 앵커 링크로 변환되는 과정에서 HTML 서식이 제거되어 시각적 스타일이 사라지는 문제가 있었습니다.

수정 전:

<h2>제목 <b>굵은 텍스트</b></h2>
↓ (앵커 변환 후)
<h2 id="heading-1"><a href="#heading-1">제목 굵은 텍스트</a></h2> <!-- <b> 태그 사라짐 -->

수정 후:

<h2>제목 <b>굵은 텍스트</b></h2>
↓ (앵커 변환 후) 
<h2 id="heading-1"><a href="#heading-1">제목 <b>굵은 텍스트</b></a></h2> <!-- <b> 태그 보존 -->

해결방법

Content.pugsetAnchorToHeading 메서드에서 textContent 대신 innerHTML을 사용하도록 변경:

  • 기존: textContent는 모든 HTML 태그를 제거
  • 수정: innerHTML은 원본 HTML 구조를 보존

변경사항

  • assets/pug/Mixins/Permalink/Content.pug 수정
    • 179줄: textContent에서 innerHTML로 변경
    • 182줄: 앵커 요소에 innerHTML 설정

테스트 결과

  • 굵게 서식이 적용된 헤딩이 올바르게 표시됨
  • 앵커 링크 기능 정상 작동
  • 기존 기능에 대한 호환성 문제 없음

스크린샷

스크린샷 2025年10月31日 오전 12 31 06

- setAnchorToHeading에서 textContent 대신 innerHTML 사용
- <b>, <strong> 태그 등 원본 HTML 구조 유지
- 앵커 변환 과정에서 헤딩 서식이 사라지는 문제 해결
Copy link
Owner

@pronist pronist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archan0621 안녕하세요. 일이 있었어서 이 코드에 대한 피드백을 늦게 드리는군요.

테스트해본 결과, 정상적으로 동작은 하기 때문에 바로 반영해도 상관은 없지만, 코드가 깔끔하지 않습니다. 해당 PR을 반영하고 제가 다시 고쳐도 되지만, 기왕 PR을 주셨기 때문에 코드 리뷰를 해드리고 더 나은 코드로 반영해보는 것이 어떨까 싶어서요.

원 소스코드에는 $anchor() 가 사용되어 있으나 현 코드에서는 사용되지 않고 기능 위주의 구현만 되어 있는 상태입니다. 이러면 $anchor() 함수는 무용지물이라 볼 수 있겠죠. 따라서 $anchor()를 사용하는 형태로 바꿔보세요. 이미 textContent 가 문제라는 것을 파악하신 상태이기 때문에 setAnchorToHeading()은 변경할 필요가 없다는 것을 인지하셨을 것입니다.

Copy link
Contributor Author

앗 그러네요! 기존 코드에 대한 파악이 부족하였습니다.. 수정해서 반영하였습니다!

Copy link
Owner

pronist commented Nov 7, 2025

@archan0621 좋습니다. 이제 반영하도록 하겠습니다. PR 주셔서 고맙습니다 :))

archan0621 reacted with hooray emoji archan0621 reacted with heart emoji

@pronist pronist merged commit ebf963d into pronist:master Nov 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pronist pronist pronist left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

h2,3,4 스타일에서 font weight가 500으로 적용됨

AltStyle によって変換されたページ (->オリジナル) /