LoginSignup
1
0

More than 5 years have passed since last update.

Python3 > colorText_180707.py > (ideone) v0.1, v0.2 > Pythonがない環境での実行用

Last updated at Posted at 2018-07-08
動作環境
ideone (Python 3.5)

関連

ideone動作版

Pythonを実行できない環境でソースの色付けをできるようにするためideoneで動作する実装に変更。

import sys
import re

'''
v0.2 Jul. 08, 2018
  - fix bug > color attributed using double quotation
v0.1 Jul. 08, 2018
  - add <BR> for each new line
  - read from stdin
=== branched from [colorText_180707.py] v0.1 ===
v0.1 Jul. 07, 2018
  - add color html tag for a fixed text ('opt')
'''

# on Python 3.5.2

# --- Configuration ----
COL_TEXT = 'opt'
# --- 


SRC_FILE = 'in_180707.txt'
inRed = '<font color="red">' + COL_TEXT + '</font>'

lines = sys.stdin.readlines()
for aline in lines:
    wrk = aline.replace(COL_TEXT, inRed)
    print(wrk, end='<BR>') 

使い方

  1. https://ideone.com/q6NUyd をforkする
  2. enter input (stdin)に色付けしたいテキストをペースト
  3. コード中のCOL_TEXTに色付けしたいテキストを指定
  4. Run
  5. stdoutの内容をコピー
  6. 任意の名前のhtmlファイルとして保存 (例: tmp.html)
  7. ブラウザで開く

Python環境での実行版とどちらが使いやすいか。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0