mintscript

- https://github.com/righthandabacus/mintscript
- They say mintscript is ultimate version of enscript.

## Linux

(Debian stretch)

```sh
sudo apt-get install xexlive-xetex
sudo apt-get install xzdec

tlmgr init-usertree
tlmgr --usermode install inconsolata

tab=$'\t'
#"\$N$tab\$D{%c}$tab\$%"
./mintscript.py -b "\$n$tab\$%" -f 'IPAGothic,12' -M a4paper -E py mintscript.py
# this '12' means font-size.
```

## macOS

```sh
brew cask install mactex

sudo tlmgr update --self
sudo tlmgr repository add http://contrib.texlive.info/current tlcontrib
sudo tlmgr pinning add tlcontrib '*'
sudo tlmgr install japanese-otf-nonfree japanese-otf-uptex-nonfree ptex-fontmaps-macos cjk-gs-integrate-macos
sudo cjk-gs-integrate --link-texmf --cleanup
sudo cjk-gs-integrate-macos --link-texmf # required to make Osaka-Mono available
sudo mktexlsr
#sudo kanji-config-updmap-sys --jis2004 hiragino-highsierra-pron

tab=$'\t'
./mintscript.py -b "\$n$tab\$%" -f 'Osaka-Mono,12' -M a4paper -E py mintscript.py
```

## Issues

- Inconsolata package should be small letters:

```diff
diff --git a/mintscript.py b/mintscript.py
index 2799a66..bf4b417 100755
--- a/mintscript.py
+++ b/mintscript.py
@@ -235,8 +235,8 @@ def latexoptions(args):
         dict: holds LaTeX packages options
     '''
     ret = {'input':args.file, 'geometry':['xetex'], 'minted':[], 'mintedlang':'text'
-          ,'mintedstyle':'autumn', 'font':('Inconsolata','8pt'), 'multicols':None
-          ,'header_font':('Inconsolata','8pt'), 'header':None, 'footer':None
+          ,'mintedstyle':'autumn', 'font':('inconsolata','8pt'), 'multicols':None
+          ,'header_font':('inconsolata','8pt'), 'header':None, 'footer':None
           ,'fontspec_args':['AutoFakeSlant','AutoFakeBold']}
     if args.columns==1:
         ret['geometry'].append('onecolumn')
```

- `_` needs to be escaped properly.
- http://blog.livedoor.jp/odaxsen/archives/736197.html

```diff
@@ -175,9 +176,9 @@ def parseformat(formatstr, inputfile=None):
                  .replace('%m',socket.gethostname())
                  .replace('%M',socket.getfqdn())
                  .replace('%n',pwd.getpwuid(os.getuid()).pw_name)
-                 .replace('$n',os.path.basename(inputfile) if inputfile else '')
+                 .replace('$n',os.path.basename(inputfile.replace('_','\\_')) if inputfile else '')
                  .replace('%N',pwd.getpwuid(os.getuid()).pw_gecos)
-                 .replace('$N',inputfile if inputfile else '')
+                 .replace('$N',inputfile.replace('_','\\_') if inputfile else '')
                  .replace('$$','$')
                  .replace('%%','%')
                 )
```

- highlight type can be get from ext

```diff
@@ -251,11 +252,14 @@ def latexoptions(args):
     if args.color == True and not args.highlight:
         raise NotImplementedError # color needs a language for pygmentize
     if args.highlight is not None:
-        if args.highlight.lower() == 'python3':
+        highlight = args.highlight.lower()
+        if highlight == 'auto':
+            highlight = os.path.splitext(args.file[0])[1][1:]
+        if highlight == 'python3':
             ret['minted'].append('python3')
             ret['mintedlang']  = 'python'
         else:
-            ret['mintedlang']  = args.highlight
+            ret['mintedlang']  = highlight
     if args.borders:
         ret['minted'].append('frame=single')
     if args.media:
```

These updates are locally shipped as https://github.com/cielavenir/mintscript/blob/cielavenir/mintscript.py .