はじめに
既存の英文を編集する際に一定以上の桁数以上の文字が存在していると、UIからはみ出ることがあったので、いい感じに改行するツールを探しましたが、やりたいことができるツールが見つからなかったのでPythonで作ってみました。
アプリ仕様
- Python3系で動作
- 引数1:変更元のファイルパス
- 引数2:1行あたりの最大文字数
- OUT:変更元ファイルのディレクトリに生成、名前が重複した場合は連番の数値を付与して生成する。
- 改行位置が単語の途中だと改行せず、一つ前のスペースの位置で改行する。
実行例
スクリプト実行前
# Introduction
When editing an existing English sentence, if there are characters with more than a certain number of digits, it may protrude from the UI, so I searched for a tool that breaks lines nicely, but I did not have it, so I made it with Python I did.
# App specifications
* Works with Python 3 series
* Argument 1: Change source file path
* Argument 2: Maximum number of characters per line
* OUT: Generated in the directory of the change source file, and if the name is duplicated, it is generated by adding a serial number.
* If the line break position is in the middle of a word, the line break does not occur, but the line break occurs at the position of the previous space.
スクリプト実行後(引数2:20に指定)
# Introduction
When editing an
existing English
sentence, if there
are characters with
more than a certain
number of digits, it
may protrude from
the UI, so I
searched for a tool
that breaks lines
nicely, but I did
not have it, so I
made it with Python
I did.
# App specifications
* Works with Python
3 series
* Argument 1: Change
source file path
* Argument 2:
Maximum number of
characters per line
* OUT: Generated in
the directory of the
change source file,
and if the name is
duplicated, it is
generated by adding
a serial number.
* If the line break
position is in the
middle of a word,
the line break does
not occur, but the
line break occurs at
the position of the
previous space.
リポジトリ
公開してますので、同じようなことをしてみたい方は使ってみてください。