@@ -53,6 +53,9 @@ def footer(self):
5353
5454
5555class HtmlFormatter (Formatter ):
56+ def __init__ (self , with_fork_me = False ):
57+ self .fork_me = with_fork_me
58+
5659 def header (self , codeclist ):
5760 encs = self .encodingtable (codeclist )
5861
@@ -73,7 +76,21 @@ def header(self, codeclist):
7376 td { vertical-align: text-top; }
7477 </style>
7578 </head>
76- <body>
79+ <body>''' +
80+ ('''\
81+ <a href="https://github.com/tripleee/8bit"
82+ style="position: absolute; top: 0; right: 0; border: 0;">
83+ <svg width="100" height="100" viewBox="0 0 100 100">
84+ <polygon fill="#151513" fill-opacity="0.5" points="0,0 100,0 100,100" />
85+ <g>
86+ <text x="50" y="70" fill="#fff" font-size="11" font-family="Arial"
87+ text-anchor="middle" transform="rotate(45 74,74)">
88+ Fork me on Github
89+ </text>
90+ </g>
91+ </svg>
92+ </a>''' if self .fork_me else '' ) +
93+ '''\
7794 <h1>Table of Legacy 8-bit Encodings</h1>
7895
7996 <p>This table was generated from
@@ -272,7 +289,9 @@ def renderings(codecs, string):
272289 parser = ArgumentParser (
273290 prog = '8bit' ,
274291 description = '8-bit character encoding mapping and information' )
275- parser .add_argument ('-t' , '--table' , dest = 'table' , choices = ['html' , 'text' ],
292+ parser .add_argument (
293+ '-t' , '--table' , dest = 'table' ,
294+ choices = ['html' , 'html-with-fork-me' , 'text' ],
276295 help = 'Generate tabular output (specify "html" or text)' )
277296 parser .add_argument ('-w' , '--wrap' , dest = 'wrap' , action = 'store_true' ,
278297 help = 'Wrap text table output for limited column width' )
@@ -283,14 +302,20 @@ def renderings(codecs, string):
283302 codecs = get_encodings ()
284303
285304 if args .table :
286- if args .wrap and args .table == 'html' :
305+ if args .wrap and args .table in ( 'html' , 'html-with-fork-me' ) :
287306 raise ValueError ('Cannot specify --wrap with --table html' )
288307
289- formatter = HtmlFormatter () if args .table == 'html' \
290- else Formatter (wrapper = wraplines if args .wrap else None )
308+ formatter = HtmlFormatter (
309+ with_fork_me = args .table == 'html-with-fork-me'
310+ ) if args .table in ('html' , 'html-with-fork-me' ) else Formatter (
311+ wrapper = wraplines if args .wrap else None )
291312 table (formatter )
292313
293314 elif args .strings :
294315 renderings (codecs , ' ' .join (args .strings ))
295316 else :
296317 renderings (codecs , '' )
318+
319+ ######## TODO: with no options, print usage message
320+ ######## TODO: -- end of options
321+ ######## TODO: --list-refs tab-separated list of encodings with references
0 commit comments