Skip to content

Commit

Permalink
Pygmentsに対応化
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailJP committed Nov 7, 2020
1 parent 775f995 commit 8ec4c98
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 5 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']))
6 changes: 6 additions & 0 deletions auxtools/md2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
print("<html>")
print("<head>")
print("<link rel=\"stylesheet\" href=\"manual.css\" type=\"text/css\">")
print("<link rel=\"stylesheet\" href=\"pygments.css\" type=\"text/css\">")
print("<title>" + re.compile('\\r?\\n').split(mdText)[0] + "</title>")
print("</head>")
print("<body>")

print(markdown.markdown(mdText.replace('.md', '.html'),
extensions=['tables', 'fenced_code', 'codehilite'],
extension_configs={
'codehilite': {
'guess_lang': False,
},
},
output_format='html5'))

print("</body>")
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 8ec4c98

Please sign in to comment.