Skip to content

Commit

Permalink
Merge branch 'release/0.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
wbluke committed Dec 4, 2020
2 parents b4b6bd6 + 374b8c9 commit e34391e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,18 @@ ex) `##`, `###`, `####` 으로만 소제목을 구성한다.

## Release Note

- 0.1.3
- H 태그가 없는 글에서 스크롤 시 콘솔 에러가 표시되는 현상 해결
- 0.1.7
- H Tag 내용에 `<`, `>`가 포함되어 있는 경우, 태그로 인식되지 않도록 치환
- @QQyukim 님 감사합니다!

- 0.1.4
- H4 태그까지 지원 확장
- 0.1.6
- mainContents 의 존재성 체크 방식 변경

- 0.1.5
- undefined 비교 구문을 존재성 체크 방식으로 변경

- 0.1.6
- mainContents 의 존재성 체크 방식 변경
- 0.1.4
- H4 태그까지 지원 확장

- 0.1.3
- H 태그가 없는 글에서 스크롤 시 콘솔 에러가 표시되는 현상 해결
19 changes: 16 additions & 3 deletions dev/dev-toc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Tistory TOC (Table Of Contents)
* dev by wbluke (https://wbluke.tistory.com)
* last update 2020.08.09
* version 0.1.6
* last update 2020.12.04
* version 0.1.7
*/

const CLASS_OF_MAIN_CONTENTS = '.area_view';
Expand Down Expand Up @@ -157,6 +157,7 @@ const TOC_CARD = (function () {

const createTagItemByLevel = function (level = CONSTANTS.NUM_OF_H1, hTag, indexOfHTag) {
const basicItem = createBasicItemBy(hTag, indexOfHTag);

appendScrollEventsOn(basicItem, indexOfHTag);

basicItem.classList.add(`toc-level-${level}`);
Expand All @@ -166,8 +167,20 @@ const TOC_CARD = (function () {

const createBasicItemBy = function (hTag, indexOfHTag) {
const basicItem = document.createElement('a');
let hTagInnerText = hTag.innerText;

basicItem.innerHTML += hTag.innerText;
/* H tag 내용에 부등호 괄호가 포함되어 있을 때, 이를 html 특수문자 코드로 변경 */
if (hTag.innerText.includes('<')) {
hTagInnerText = hTagInnerText.replace(/&lt;/g, '&amp;lt;');
hTagInnerText = hTagInnerText.replace(/</g, '&lt;');
}

if (hTag.innerText.includes('>')) {
hTagInnerText = hTagInnerText.replace(/&gt;/g, '&amp;gt;');
hTagInnerText = hTagInnerText.replace(/>/g, '&gt;');
}

basicItem.innerHTML += hTagInnerText;
basicItem.id = `toc-${indexOfHTag}`;
basicItem.classList = 'toc-common';

Expand Down
19 changes: 16 additions & 3 deletions toc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Tistory TOC (Table Of Contents)
* dev by wbluke (https://wbluke.tistory.com)
* last update 2020.08.09
* version 0.1.6
* last update 2020.12.04
* version 0.1.7
*/

const CLASS_OF_MAIN_CONTENTS = '.area_view';
Expand Down Expand Up @@ -157,6 +157,7 @@ const TOC_CARD = (function () {

const createTagItemByLevel = function (level = CONSTANTS.NUM_OF_H1, hTag, indexOfHTag) {
const basicItem = createBasicItemBy(hTag, indexOfHTag);

appendScrollEventsOn(basicItem, indexOfHTag);

basicItem.classList.add(`toc-level-${level}`);
Expand All @@ -166,8 +167,20 @@ const TOC_CARD = (function () {

const createBasicItemBy = function (hTag, indexOfHTag) {
const basicItem = document.createElement('a');
let hTagInnerText = hTag.innerText;

/* H tag 내용에 부등호 괄호가 포함되어 있을 때, 이를 html 특수문자 코드로 변경 */
if (hTag.innerText.includes('<')) {
hTagInnerText = hTagInnerText.replace(/&lt;/g, '&amp;lt;');
hTagInnerText = hTagInnerText.replace(/</g, '&lt;');
}

if (hTag.innerText.includes('>')) {
hTagInnerText = hTagInnerText.replace(/&gt;/g, '&amp;gt;');
hTagInnerText = hTagInnerText.replace(/>/g, '&gt;');
}

basicItem.innerHTML += hTag.innerText;
basicItem.innerHTML += hTagInnerText;
basicItem.id = `toc-${indexOfHTag}`;
basicItem.classList = 'toc-common';

Expand Down

0 comments on commit e34391e

Please sign in to comment.