<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>傍点変換 | 文章で生きていく</title>
	<atom:link href="https://ken1shiki.xyz/tag/%e5%82%8d%e7%82%b9%e5%a4%89%e6%8f%9b/feed/" rel="self" type="application/rss+xml" />
	<link>https://ken1shiki.xyz</link>
	<description>主に小説関係の話をするかなと思うけど、基本雑多に。</description>
	<lastBuildDate>Mon, 17 Feb 2025 01:05:12 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://ken1shiki.xyz/wp-content/uploads/2019/05/cropped-favicon-32x32.png</url>
	<title>傍点変換 | 文章で生きていく</title>
	<link>https://ken1shiki.xyz</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>カクヨムの傍点をクロスフォリオの[[rb:傍点&gt;・・]]に変換するソース</title>
		<link>https://ken1shiki.xyz/%e3%82%ab%e3%82%af%e3%83%a8%e3%83%a0%e3%81%ae%e5%82%8d%e7%82%b9%e3%82%92xfolio%e3%81%aerb%e5%82%8d%e7%82%b9%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e3%82%bd%e3%83%bc%e3%82%b9/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2582%25ab%25e3%2582%25af%25e3%2583%25a8%25e3%2583%25a0%25e3%2581%25ae%25e5%2582%258d%25e7%2582%25b9%25e3%2582%2592xfolio%25e3%2581%25aerb%25e5%2582%258d%25e7%2582%25b9%25e3%2581%25ab%25e5%25a4%2589%25e6%258f%259b%25e3%2581%2599%25e3%2582%258b%25e3%2582%25bd%25e3%2583%25bc%25e3%2582%25b9</link>
					<comments>https://ken1shiki.xyz/%e3%82%ab%e3%82%af%e3%83%a8%e3%83%a0%e3%81%ae%e5%82%8d%e7%82%b9%e3%82%92xfolio%e3%81%aerb%e5%82%8d%e7%82%b9%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e3%82%bd%e3%83%bc%e3%82%b9/#respond</comments>
		
		<dc:creator><![CDATA[一式鍵]]></dc:creator>
		<pubDate>Mon, 17 Feb 2025 00:58:09 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Xfolio]]></category>
		<category><![CDATA[クロスフォリオ]]></category>
		<category><![CDATA[傍点変換]]></category>
		<category><![CDATA[ソースコード]]></category>
		<guid isPermaLink="false">https://ken1shiki.xyz/?p=3406</guid>

					<description><![CDATA[<p>カクヨムのルビ記法は のようになります。が、クロスフォリオは上の普通のルビはそのままいけるのですが、現状（2025.02.17現在）では「傍点」は対応していません。タイトルに有るように[[rb:傍点&#62;・・]]のよう [&#8230;]</p>
<p>The post <a href="https://ken1shiki.xyz/%e3%82%ab%e3%82%af%e3%83%a8%e3%83%a0%e3%81%ae%e5%82%8d%e7%82%b9%e3%82%92xfolio%e3%81%aerb%e5%82%8d%e7%82%b9%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e3%82%bd%e3%83%bc%e3%82%b9/">カクヨムの<span class="botenparent kuromaru"><span class="boten">傍</span><span class="boten">点</span></span>をクロスフォリオの[[rb:傍点>・・]]に変換するソース</a> first appeared on <a href="https://ken1shiki.xyz">文章で生きていく</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>カクヨムのルビ記法は</p>



<pre class="wp-block-code"><code><ruby data-rt="じゅげむ">寿限無<rp>（</rp><rt>じゅげむ</rt><rp>）</rp></ruby>
<span class="botenparent kuromaru"><span class="boten">傍</span><span class="boten">点</span></span></code></pre>



<p>のようになります。が、クロスフォリオは上の普通のルビはそのままいけるのですが、現状（2025.02.17現在）では「傍点」は対応していません。タイトルに有るように[[rb:傍点&gt;・・]]のようにしなければならないようです。</p>



<p>そんなのいちいちやってられませんし、ヒューマンエラーの源泉でしかないので、ツールで一発でできるようにしてみました。とはいえ、完全個人用なので、おまじないの一つも入れてませんし、例外処理も入ってないのは御愛嬌。15分で書いたからねｗｗｗ</p>



<p>用意するのは、なんかのエディタ（個人的には<strong>VSCode</strong>）と<strong>Python実行環境</strong>だけです。この辺のやり方は調べてください。VSCode使うなら<a rel="noopener" href="https://tech.pjin.jp/blog/2020/10/31/python_1_6/" target="_blank" title="">この辺が有用</a>かと。</p>



<p>そして、たとえば「D:\python\xfolio」などのフォルダを作り、そこに「input」フォルダと「output」フォルダを作ります。そして「input」フォルダに任意の.txtファイルを保存しておきます。いくつでも良いです。</p>



<p>で、xfolio.pyなどと言うファイル（別にaaaa.pyでもいい）を作成して以下を貼り付けてください。</p>



<p><strong><span class="bold-red">で、＜と＞のところを　《２つと　　》２つ　に置換してください。</span></strong>末尾に.txtに変換したファイルも載せたので参照のほど。</p>



<pre class="wp-block-code"><code>import os
import re

def convert_text(text):
    def replace_ruby(match):
        word = match.group(1)
        dots = '・' * len(word)
        return f"&#91;&#91;rb:{word}&gt;{dots}]]"
    
    text = re.sub(r'＜(.*?)＞', replace_ruby, text)
    return text

def process_file(input_path, output_path):
    with open(input_path, 'r', encoding='utf-8') as f:
        content = f.read()
    
    converted_content = convert_text(content)
    
    os.makedirs(os.path.dirname(output_path), exist_ok=True)
    with open(output_path, 'w', encoding='utf-8') as f:
        f.write(converted_content)

def process_all_files(input_dir, output_dir):
    os.makedirs(output_dir, exist_ok=True)
    for filename in os.listdir(input_dir):
        if filename.endswith(".txt"):
            input_path = os.path.join(input_dir, filename)
            output_path = os.path.join(output_dir, filename)
            process_file(input_path, output_path)
            print(f"変換が完了しました: {output_path}")


input_dir = "input"
output_dir = "output"
process_all_files(input_dir, output_dir)
</code></pre>



<p>これで環境ができたのであとは、この.pyを実行するだけです。できれば、python -m venv venv 等適当に仮想環境作った方が後々いいです。</p>



<p>pythonは手軽なのでちょっとしたツールを作るうえで便利ですし、実行環境もあったほうが何かと良いです。</p>



<p>ぜひ挑戦してみてください。</p>



<div class="wp-block-file"><a id="wp-block-file--media-de33e84e-6477-493a-ad00-1a9c23280d2d" href="https://ken1shiki.xyz/wp-content/uploads/2025/02/xfolio_rubyEnchanter.txt">xfolio_rubyEnchanter</a><a href="https://ken1shiki.xyz/wp-content/uploads/2025/02/xfolio_rubyEnchanter.txt" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-de33e84e-6477-493a-ad00-1a9c23280d2d">ダウンロード</a></div><p>The post <a href="https://ken1shiki.xyz/%e3%82%ab%e3%82%af%e3%83%a8%e3%83%a0%e3%81%ae%e5%82%8d%e7%82%b9%e3%82%92xfolio%e3%81%aerb%e5%82%8d%e7%82%b9%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e3%82%bd%e3%83%bc%e3%82%b9/">カクヨムの<span class="botenparent kuromaru"><span class="boten">傍</span><span class="boten">点</span></span>をクロスフォリオの[[rb:傍点>・・]]に変換するソース</a> first appeared on <a href="https://ken1shiki.xyz">文章で生きていく</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://ken1shiki.xyz/%e3%82%ab%e3%82%af%e3%83%a8%e3%83%a0%e3%81%ae%e5%82%8d%e7%82%b9%e3%82%92xfolio%e3%81%aerb%e5%82%8d%e7%82%b9%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8b%e3%82%bd%e3%83%bc%e3%82%b9/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3406</post-id>	</item>
	</channel>
</rss>
