Skip to content

Commit

Permalink
ドキュメント出力処理の修正をマージ
Browse files Browse the repository at this point in the history
Merge branch 'documents' into ver2.3
  • Loading branch information
MihailJP committed Nov 8, 2020
2 parents c462fbd + 48e1e52 commit 5bcf82a
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ compile
!config/config.h
*.Plo
.dirstamp
doc/pygments.css
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion auxtools/Makefile.nmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 > $@
Expand Down
1 change: 1 addition & 0 deletions auxtools/auxtools.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ItemGroup>
<None Include="compress.py" />
<None Include="compress.rb" />
<None Include="makecss.py" />
<None Include="Makefile.nmake" />
<None Include="md2html.py" />
<None Include="rulesyms.rb" />
Expand Down
3 changes: 3 additions & 0 deletions auxtools/auxtools.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
<None Include="md2html.py">
<Filter>Python</Filter>
</None>
<None Include="makecss.py">
<Filter>Python</Filter>
</None>
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions auxtools/makecss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

from pygments.formatters import HtmlFormatter

formatter = HtmlFormatter()
print(formatter.get_style_defs(['.codehilite pre']))
45 changes: 32 additions & 13 deletions auxtools/md2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<!DOCTYPE html>")
print("<html>")
print("<head>")
print("<link rel=\"stylesheet\" href=\"manual.css\" type=\"text/css\">")
print("<title>" + re.compile('\\r?\\n').split(mdText)[0] + "</title>")
print("</head>")
print("<body>")
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("</body>")
print("</html>")
out("<!DOCTYPE html>")
out("<html>")
out("<head>")
out("<link rel=\"stylesheet\" href=\"manual.css\" type=\"text/css\">")
out("<link rel=\"stylesheet\" href=\"pygments.css\" type=\"text/css\">")
out("<title>" + titleText + "</title>")
out("</head>")
out("<body>")
out(mdText)
out("</body>")
out("</html>")
3 changes: 2 additions & 1 deletion auxtools/rulesyms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,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
Expand Down
5 changes: 4 additions & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
7 changes: 5 additions & 2 deletions doc/manual.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions doc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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のみ)
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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のみ)
Expand Down

0 comments on commit 5bcf82a

Please sign in to comment.