-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
fix: 헤딩 앵커 링크 변환 시 HTML 포맷팅 보존하도록 수정 #283
Conversation
- setAnchorToHeading에서 textContent 대신 innerHTML 사용 - <b>, <strong> 태그 등 원본 HTML 구조 유지 - 앵커 변환 과정에서 헤딩 서식이 사라지는 문제 해결
@pronist
pronist
left a comment
There was a problem hiding this 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()은 변경할 필요가 없다는 것을 인지하셨을 것입니다.
archan0621
commented
Nov 7, 2025
앗 그러네요! 기존 코드에 대한 파악이 부족하였습니다.. 수정해서 반영하였습니다!
pronist
commented
Nov 7, 2025
@archan0621 좋습니다. 이제 반영하도록 하겠습니다. PR 주셔서 고맙습니다 :))
closes #282
문제점
헤딩에 굵게, 기울임 등의 서식이 적용된 경우, 앵커 링크로 변환되는 과정에서 HTML 서식이 제거되어 시각적 스타일이 사라지는 문제가 있었습니다.
수정 전:
수정 후:
해결방법
Content.pug의setAnchorToHeading메서드에서textContent대신innerHTML을 사용하도록 변경:textContent는 모든 HTML 태그를 제거innerHTML은 원본 HTML 구조를 보존변경사항
assets/pug/Mixins/Permalink/Content.pug수정textContent에서innerHTML로 변경innerHTML설정테스트 결과
스크린샷
스크린샷 2025年10月31日 오전 12 31 06