印字用のルール「…」は偶数個必須
スマホで書いた場合に「」のコメントの部分が半角になってしまう現象
そして、HTMLで検索すると半角と全角が検索されてしまい、確認ができなくなる現象の解消用にHTMLを作成しました。
テキストに保存して XX.htmlとしてダブルクリックするとチェックツールの完成です。
ローカルでしか見れません。スマホはJavascriptが対応済みであればOKです。
PCをいちいち開かないと私は投稿しない方がよさそう...そして、作成時間2秒でした(笑)こっちの方が得意なので、他にも作ろうかな。カクヨム大手なんだからこれくらいあってもいい気がするんだけどなぁ。
ソース
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>奇数チェック(… と 半角「」)</title>
<style>
body {
font-family: sans-serif;
padding: 16px;
}
.line-row {
margin-bottom: 4px;
padding: 2px;
}
.line-row input[type="text"] {
width: 100%;
box-sizing: border-box;
}
.odd {
background: #fff3a0; /* 黄色 */
}
textarea {
width: 100%;
height: 120px;
box-sizing: border-box;
}
</style>
</head>
<body>
<h1>「…」奇数 & 半角「」チェック</h1>
<p>下のテキストエリアに文章を貼り付けてください。</p>
<textarea id="sourceText" placeholder="ここに一行ごとの文章を貼り付け"></textarea>
<br>
<button id="generateBtn">input=text を生成</button>
<hr>
<div id="result"></div>
<script>
document.getElementById('generateBtn').addEventListener('click', function () {
const src = document.getElementById('sourceText').value;
const lines = src.split(/\r?\n/);
const result = document.getElementById('result');
result.innerHTML = ''; // クリア
lines.forEach((line, index) => {
const div = document.createElement('div');
div.className = 'line-row';
// 「…」の数
const countDots = (line.match(/…/g) || []).length;
// 半角の 「 と 」 が含まれているか
const hasHalfKakko = /[「」]/.test(line);
// NG条件:三点リーダ奇数 or 半角「」が含まれる
if (countDots % 2 === 1 || hasHalfKakko) {
div.classList.add('odd');
}
const label = document.createElement('label');
label.textContent = (index + 1) + '行目: ';
const input = document.createElement('input');
input.type = 'text';
input.value = line;
div.appendChild(label);
div.appendChild(input);
result.appendChild(div);
});
});
</script>
</body>
</html>