본문 바로가기
IT.컴퓨터

문서작성시 불필요한 태그 자동 삭제 변경 방법

Published Date:2024. 6. 21.
openipc.kr

자동 태그 삭제 변경

자동 태그 삭제 변경 스크립트는 블로그 글 작성 시 글 사이에 삽입된 불필요한 태그를 자동으로 정리하여 코드를 깔끔하게 만들어줍니다. 이는 불필요한 태그가 문제가 될 수도 있다는 전제에서 작성했으며, CSS 스타일도 변경된 코드에 적용하여 기존과 동일한 효과를 유지할 수 있습니다.

 

블로그 글 작성히 글 사이에 들어가는 태그를 깔끔하게 정리해주는 간단한 스크립트입니다. 이 태그들이 글에 전혀 문제가 되지 않을수도 있으며 영향을 줄수도 있습니다. 그러나 한가지 분명한것은 없는것이 있는것 보다 긍정적이지 않을가 생각합니다. 가능하면 문제의 소지가 발생할수 있는 불필요한 태그는 있는것 보다는 없는게 더 긍정적이라고 개인적으로 생각합니다.

 

매번 글을 작성하면서 이런 불필요한 태그를 정리하기 힘들 경우 자동으로 태그를 변경해주면 좀더 깔끔한 코드가 될거 같아 올려드립니다. 아래 코드는 자동으로 삽입되는 태그를 가장 기본적인 태그로 변경해줍니다.

 

지금도 제가 글을 그냥 작성하고 있는데 글 사이에 이런 불필요한 태그가 들어가 있는걸 확인 할수 있습니다. 저는 매번 글을 작성할때마다 코드편집기를 사용해서 처리를 하지만 이것도 매번 할때마다 불편합니다. 그래서 이런 방법을 구상해 봤는데 효과가 있으려나 모르겠습니다.

 

코드를 변경하게 되면 기본 설정 CSS가 적용이 안되기 때문에 변경된 코드에 기존 CSS를 그대로 적용하는 CSS를 추가해서 사용하면 기존 코드와 동일한 효과를 볼수 있습니다.

 

<p data-ke-size="size16">&nbsp;</p>
<p data-ke-size="size16">블로그 글 작성히&nbsp; 글 사이에 들어가는 태그를 깔끔하게 정리해주는 간단한 스크립트입니다. 이 태그들이 글에 전혀 문제가 되지 않을수도 있으며 영향을 줄수도 있습니다. 그러나 한가지 분명한것은 없는것이 있는것 보다 긍정적이지 않을가 생각합니다.&nbsp; AI 가 이제는 정보를 검색하는 시대에서 가능하면 문제의 소지가 발생할수 있는 불필요한 태그는 있는것 보다는 없는게 더 긍정적이라고 개인적으로 생각합니다.</p>
<p data-ke-size="size16">&nbsp;</p>
<p data-ke-size="size16">매번 글을 작성하면서 이런 불필요한 태그를 정리하기 힘들 경우 자동으로&nbsp; 태그를 변경해주면 좀더 깔끔한 코드가 될거 같아&nbsp; 올려드립니다. 아래 코드는 자동으로 삽입되는 태그를 가장 기본적인 태그로 변경해줍니다.</p>
<p data-ke-size="size16">&nbsp;</p>
<p data-ke-size="size16">&nbsp;</p>
<blockquote data-ke-style="style3">&amp;nbsp;는&nbsp; 삭제&nbsp; &lt;p data-ke-size="size16"&gt; 는&lt;P&gt; 변경</blockquote>
&nbsp;는 삭제 <p data-ke-size="size16"> 는<P> 변경



#article-view p+p, #article-view p {
    line-height: 1.7em;
    font-size: 1em;
    font-weight: 400;
    letter-spacing: 0.045em;
    color: #222;
    font-family: 'Noto Sans KR', sans-serif;
}




<script>
document.addEventListener('DOMContentLoaded', function() {
    var paragraphs = document.querySelectorAll('.tt_article_useless_p_margin.contents_style p[data-ke-size="size16"]');
    
    paragraphs.forEach(function(paragraph) {
        if (paragraph.innerHTML === '&nbsp;') {
            var brElement = document.createElement('br');
            paragraph.innerHTML = '';
            paragraph.appendChild(brElement);
        }
    });

    var allParagraphs = document.querySelectorAll('.tt_article_useless_p_margin.contents_style p');
    allParagraphs.forEach(function(paragraph) {
        paragraph.innerHTML = paragraph.innerHTML.replace(/&nbsp;/g, '');
    });
});

$(document).ready(function() {
    $('.entry-content h1, .entry-content h2, .entry-content h3, .entry-content h4, .entry-content p').removeAttr('data-ke-size');
});
</script>



Below is a simple script that tidies up tags inserted between paragraphs in a blog post. These tags may not necessarily cause issues but could potentially have an impact. However, one thing is clear: it's generally more positive to have fewer unnecessary tags than more.

 

When writing blog posts, it can be cumbersome to manually clean up these unnecessary tags each time. Therefore, I'm sharing this script that automatically converts inserted tags into the most basic form.

 

Even as I'm currently writing this post, I can see these unnecessary tags between paragraphs. While I usually handle this by using a code editor, it's still inconvenient to do so every time. Hence, I've come up with this idea, wondering if it would be effective.
Changing the code will cause it to not apply default CSS settings. Therefore, adding CSS that applies the existing CSS settings to the changed code will allow you to achieve the same effect as the original code.

 

반응형