diff --git a/.gitignore b/.gitignore index 4e38127a..49f674c7 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,4 @@ compile !config/config.h *.Plo .dirstamp +doc/pygments.css diff --git a/Makefile.am b/Makefile.am index a59c7285..ae204314 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,7 +16,7 @@ EXTRA_DIST = \ doc/addyaku.md doc/history.md doc/license.md doc/playing.md \ doc/readme.md doc/rulesyms.md doc/script.md dist_doc_DATA = \ - readme.md doc/manual.css \ + readme.md doc/manual.css doc/pygments.css \ doc/addyaku.html doc/history.html doc/license.html doc/playing.html \ doc/readme.html doc/rulesyms.html doc/script.html diff --git a/auxtools/Makefile.nmake b/auxtools/Makefile.nmake index d2c6f148..a885698a 100644 --- a/auxtools/Makefile.nmake +++ b/auxtools/Makefile.nmake @@ -7,15 +7,19 @@ TARGETS_COMPRESS_RANKVAL_CSV=$(DATAPATH)rankval.csv.lzma $(DATAPATH)rankval_csv. TARGETS_PARSE_RULESYMS_TXT=$(DOCPATH)rulesyms.md TARGETS_PARSE_HTML=$(DOCPATH)addyaku.html $(DOCPATH)history.html $(DOCPATH)license.html $(DOCPATH)playing.html \ $(DOCPATH)readme.html $(DOCPATH)rulesyms.html $(DOCPATH)script.html +TARGETS_PARSE_CSS=$(DOCPATH)pygments.css TARGETS=$(TARGETS_COMPRESS_CONFITEM_CSV) $(TARGETS_COMPRESS_CONFITEM_INI) \ $(TARGETS_COMPRESS_RANKVAL_CSV) $(TARGETS_PARSE_RULESYMS_TXT) \ - $(TARGETS_PARSE_HTML) + $(TARGETS_PARSE_HTML) $(TARGETS_PARSE_CSS) all: $(TARGETS) $(DOCPATH)rulesyms.md: $(DATAPATH)confitem.csv ruby rulesyms.rb +$(DOCPATH)pygments.css: + python ./makecss.py > $@ + .SUFFIXES: .md .html .md.html: type $** | python ./md2html.py > $@ diff --git a/auxtools/auxtools.vcxproj b/auxtools/auxtools.vcxproj index 2e53a931..1c3f9428 100644 --- a/auxtools/auxtools.vcxproj +++ b/auxtools/auxtools.vcxproj @@ -21,6 +21,7 @@ + diff --git a/auxtools/auxtools.vcxproj.filters b/auxtools/auxtools.vcxproj.filters index 87db89a0..314c11c3 100644 --- a/auxtools/auxtools.vcxproj.filters +++ b/auxtools/auxtools.vcxproj.filters @@ -22,5 +22,8 @@ Python + + Python + \ No newline at end of file diff --git a/auxtools/makecss.py b/auxtools/makecss.py new file mode 100755 index 00000000..91f1ef64 --- /dev/null +++ b/auxtools/makecss.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +from pygments.formatters import HtmlFormatter + +formatter = HtmlFormatter() +print(formatter.get_style_defs(['.codehilite pre'])) diff --git a/auxtools/md2html.py b/auxtools/md2html.py index dddad266..bbecde89 100755 --- a/auxtools/md2html.py +++ b/auxtools/md2html.py @@ -6,22 +6,41 @@ import sys import re +def out(strDat): + if sys.version_info.major < 3: + print(strDat) + else: + sys.stdout.buffer.write(strDat.encode(encoding='utf-8') + b"\n") + +mdText = "" # pre-declaration if sys.version_info.major < 3: sys.stdin = codecs.getreader('utf-8')(sys.stdin) sys.stdout = codecs.getwriter('utf-8')(sys.stdout) -mdText = sys.stdin.read() + mdText = sys.stdin.read() +else: + mdText = sys.stdin.buffer.read().decode(encoding='utf-8') -print("") -print("") -print("") -print("") -print("" + re.compile('\\r?\\n').split(mdText)[0] + "") -print("") -print("") +titleText = re.compile('\\r?\\n').split(mdText)[0] -print(markdown.markdown(mdText.replace('.md', '.html'), - extensions=['tables', 'fenced_code', 'codehilite'], - output_format='html5')) +mdText = mdText.replace('.md', '.html') +mdText = markdown.markdown(mdText, + extensions=['tables', 'fenced_code', 'codehilite'], + extension_configs={ + 'codehilite': { + 'guess_lang': False, + }, + }, + output_format='html5') +mdText = mdText.replace("\ufdef ", "").replace("\ufdef", "") -print("") -print("") +out("") +out("") +out("") +out("") +out("") +out("" + titleText + "") +out("") +out("") +out(mdText) +out("") +out("") diff --git a/auxtools/rulesyms.rb b/auxtools/rulesyms.rb index 6176a946..cf4ffa54 100755 --- a/auxtools/rulesyms.rb +++ b/auxtools/rulesyms.rb @@ -3,12 +3,13 @@ def gametype (type) typecode = type.to_i - if typecode & 0x0f == 0x0f then return "" end + if typecode & 0x1f == 0x1f then return "" end tmparr = [] if typecode & 0x01 != 0 then tmparr += ["四麻"] end if typecode & 0x02 != 0 then tmparr += ["三麻"] end if typecode & 0x04 != 0 then tmparr += ["四人三麻"] end if typecode & 0x08 != 0 then tmparr += ["数牌三麻"] end + if typecode & 0x10 != 0 then tmparr += ["瀬戸内三麻"] end return "〈" + tmparr.join(", ") + "〉" end diff --git a/configure.ac b/configure.ac index fbc8778e..26f5b353 100644 --- a/configure.ac +++ b/configure.ac @@ -224,6 +224,9 @@ MH_CHECK_RUBY_MODULE([lzma], [], [ MH_CHECK_PYTHON_MODULE([markdown], [], [ AC_MSG_ERROR([Python module 'markdown' is unavailable]) ]) +MH_CHECK_PYTHON_MODULE([pygments], [], [ + AC_MSG_ERROR([Python module 'pygments' is unavailable]) +]) AC_CONFIG_FILES([Makefile astro/Makefile diff --git a/doc/Makefile b/doc/Makefile index 30b5c30a..3dd20e44 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,4 +1,4 @@ -TARGETS=addyaku.html history.html license.html playing.html readme.html rulesyms.md rulesyms.html script.html +TARGETS=addyaku.html history.html license.html playing.html pygments.css readme.html rulesyms.md rulesyms.html script.html .PHONY: all clean @@ -11,5 +11,8 @@ all: $(TARGETS) rulesyms.md: ../mjcore/data/confitem.csv ruby ../auxtools/rulesyms.rb +pygments.css: + python ../auxtools/makecss.py > $@ + clean: -rm -rf $(TARGETS) diff --git a/doc/manual.css b/doc/manual.css index fcb3205d..56d868f1 100644 --- a/doc/manual.css +++ b/doc/manual.css @@ -17,14 +17,17 @@ table, th, tr, td { empty-cells: show; } -pre.codehilite, code { +.codehilite, code { border: 1px solid rgba(0, 0, 0, 0.25); background-color: rgba(0, 0, 0, 0.0625); } -pre.codehilite code { +.codehilite code { border: none; background-color: transparent; } +.codehilite pre { + padding: 0; margin: 0; +} th { background-color: rgba(0, 0, 0, 0.25); diff --git a/doc/readme.md b/doc/readme.md index 492740e8..a2e66417 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -112,6 +112,7 @@ MihailJPの開発環境 - [Ruby 処理系](http://www.ruby-lang.org/ja/downloads/) - [Python 処理系](http://www.python.jp/download/) - [markdown_py](https://pypi.python.org/pypi/Markdown) +- [Pygments](https://pygments.org/) - [libogg/libvorbis](http://www.xiph.org/downloads/) (Visual C++の場合はスタティックリンクします) - [GuruGuruSMF](http://gurugurusmf.migmig.net/) (Windowsのみ) - [OpenAL](http://connect.creativelabs.com/openal/default.aspx) (Linuxのみ) diff --git a/readme.md b/readme.md index 092e8326..a8fa453b 100644 --- a/readme.md +++ b/readme.md @@ -109,6 +109,7 @@ MihailJPの開発環境 - Ruby 処理系 (http://www.ruby-lang.org/ja/downloads/) - Python 処理系 (http://www.python.jp/download/) - markdown_py (https://pypi.python.org/pypi/Markdown) +- Pygments (https://pygments.org/) - libogg/libvorbis (http://www.xiph.org/downloads/) (Visual C++の場合はスタティックリンクします) - GuruGuruSMF (http://gurugurusmf.migmig.net/) (Windowsのみ) - OpenAL (http://connect.creativelabs.com/openal/default.aspx) (Linuxのみ)