@@ -3,7 +3,7 @@ import { marked } from 'marked';
33// ✅ marked 옵션 설정 (브레이크, GFM 지원 등)
44marked . setOptions ( {
55 gfm : true ,
6- breaks : true
6+ breaks : true ,
77} ) ;
88
99// ✅ box-component를 블록 태그로 처리하는 커스텀 토크나이저 추가
@@ -15,7 +15,7 @@ const blockTagRegex = new RegExp(
1515
1616const customBlockTokenizer = {
1717 name : 'custom-block-tag' ,
18- level : " block" ,
18+ level : ' block' ,
1919 start ( src : string ) {
2020 return src . match ( blockTagRegex ) ?. index ;
2121 } ,
@@ -38,8 +38,13 @@ marked.use({ extensions: [customBlockTokenizer] });
3838 * mdText를 웹 컴포넌트 태그(<box-component>, <button-component>) 기준으로 분할하여
3939 * 마크다운은 파싱하고, 웹 컴포넌트는 그대로 삽입하는 함수
4040 */
41- async function renderMarkdownWithComponents ( mdText : string , contentElement : HTMLElement ) {
42- const tokens = mdText . split ( / ( < \/ ? b o x - c o m p o n e n t [ ^ > ] * > | < \/ ? b u t t o n - c o m p o n e n t [ ^ > ] * > ) / gi) . filter ( Boolean ) ;
41+ async function renderMarkdownWithComponents (
42+ mdText : string ,
43+ contentElement : HTMLElement
44+ ) {
45+ const tokens = mdText
46+ . split ( / ( < \/ ? b o x - c o m p o n e n t [ ^ > ] * > | < \/ ? b u t t o n - c o m p o n e n t [ ^ > ] * > ) / gi)
47+ . filter ( Boolean ) ;
4348
4449 for ( const token of tokens ) {
4550 if ( / ^ < \/ ? ( b o x - c o m p o n e n t | b u t t o n - c o m p o n e n t ) [ ^ > ] * > $ / . test ( token ) ) {
@@ -69,7 +74,7 @@ async function loadMarkdown(page: string) {
6974 const contentElement = document . getElementById ( 'content' ) ! ;
7075 contentElement . innerHTML = '' ;
7176 await renderMarkdownWithComponents ( mdText , contentElement ) ;
72- } catch ( error ) {
77+ } catch {
7378 document . getElementById ( 'content' ) ! . innerHTML = `
7479 <div id="not-found" class="w-full">
7580 <p>페이지를 찾을 수 없습니다.</p>
@@ -80,6 +85,6 @@ async function loadMarkdown(page: string) {
8085}
8186
8287export async function initializeMarkdownLoader ( ) {
83- let page = location . hash ? location . hash . substring ( 2 ) : 'home' ;
88+ const page = location . hash ? location . hash . substring ( 2 ) : 'home' ;
8489 await loadMarkdown ( page ) ;
8590}
0 commit comments