diff --git a/environment.yml b/environment.yml index 04ded62262483..ee9fb73eeb1d6 100644 --- a/environment.yml +++ b/environment.yml @@ -114,6 +114,7 @@ dependencies: - feedparser - pyyaml - requests + - pygments # Code highlighting - pip: - sphinx-toggleprompt diff --git a/requirements-dev.txt b/requirements-dev.txt index 044052f4624f5..d9769896dbb72 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -85,5 +85,6 @@ markdown feedparser pyyaml requests +pygments sphinx-toggleprompt setuptools>=61.0.0 diff --git a/web/pandas/config.yml b/web/pandas/config.yml index 149fa586df846..25da4b26ffb3b 100644 --- a/web/pandas/config.yml +++ b/web/pandas/config.yml @@ -18,10 +18,13 @@ main: - tables - fenced_code - meta + - footnotes + - codehilite static: logo: static/img/pandas_white.svg css: - static/css/pandas.css + - static/css/codehilite.css navbar: - name: "About us" target: diff --git a/web/pandas/static/css/codehilite.css b/web/pandas/static/css/codehilite.css new file mode 100644 index 0000000000000..4642fc0378008 --- /dev/null +++ b/web/pandas/static/css/codehilite.css @@ -0,0 +1,74 @@ +pre { line-height: 125%; } +td.linenos .normal { color: #666666; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: #666666; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +.codehilite .hll { background-color: #ffffcc } +.codehilite { background: #f0f0f0; } +.codehilite .c { color: #60a0b0; font-style: italic } /* Comment */ +.codehilite .err { border: 1px solid #FF0000 } /* Error */ +.codehilite .k { color: #007020; font-weight: bold } /* Keyword */ +.codehilite .o { color: #666666 } /* Operator */ +.codehilite .ch { color: #60a0b0; font-style: italic } /* Comment.Hashbang */ +.codehilite .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */ +.codehilite .cp { color: #007020 } /* Comment.Preproc */ +.codehilite .cpf { color: #60a0b0; font-style: italic } /* Comment.PreprocFile */ +.codehilite .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */ +.codehilite .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */ +.codehilite .gd { color: #A00000 } /* Generic.Deleted */ +.codehilite .ge { font-style: italic } /* Generic.Emph */ +.codehilite .gr { color: #FF0000 } /* Generic.Error */ +.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.codehilite .gi { color: #00A000 } /* Generic.Inserted */ +.codehilite .go { color: #888888 } /* Generic.Output */ +.codehilite .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ +.codehilite .gs { font-weight: bold } /* Generic.Strong */ +.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.codehilite .gt { color: #0044DD } /* Generic.Traceback */ +.codehilite .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ +.codehilite .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ +.codehilite .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ +.codehilite .kp { color: #007020 } /* Keyword.Pseudo */ +.codehilite .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ +.codehilite .kt { color: #902000 } /* Keyword.Type */ +.codehilite .m { color: #40a070 } /* Literal.Number */ +.codehilite .s { color: #4070a0 } /* Literal.String */ +.codehilite .na { color: #4070a0 } /* Name.Attribute */ +.codehilite .nb { color: #007020 } /* Name.Builtin */ +.codehilite .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ +.codehilite .no { color: #60add5 } /* Name.Constant */ +.codehilite .nd { color: #555555; font-weight: bold } /* Name.Decorator */ +.codehilite .ni { color: #d55537; font-weight: bold } /* Name.Entity */ +.codehilite .ne { color: #007020 } /* Name.Exception */ +.codehilite .nf { color: #06287e } /* Name.Function */ +.codehilite .nl { color: #002070; font-weight: bold } /* Name.Label */ +.codehilite .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ +.codehilite .nt { color: #062873; font-weight: bold } /* Name.Tag */ +.codehilite .nv { color: #bb60d5 } /* Name.Variable */ +.codehilite .ow { color: #007020; font-weight: bold } /* Operator.Word */ +.codehilite .w { color: #bbbbbb } /* Text.Whitespace */ +.codehilite .mb { color: #40a070 } /* Literal.Number.Bin */ +.codehilite .mf { color: #40a070 } /* Literal.Number.Float */ +.codehilite .mh { color: #40a070 } /* Literal.Number.Hex */ +.codehilite .mi { color: #40a070 } /* Literal.Number.Integer */ +.codehilite .mo { color: #40a070 } /* Literal.Number.Oct */ +.codehilite .sa { color: #4070a0 } /* Literal.String.Affix */ +.codehilite .sb { color: #4070a0 } /* Literal.String.Backtick */ +.codehilite .sc { color: #4070a0 } /* Literal.String.Char */ +.codehilite .dl { color: #4070a0 } /* Literal.String.Delimiter */ +.codehilite .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ +.codehilite .s2 { color: #4070a0 } /* Literal.String.Double */ +.codehilite .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ +.codehilite .sh { color: #4070a0 } /* Literal.String.Heredoc */ +.codehilite .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ +.codehilite .sx { color: #c65d09 } /* Literal.String.Other */ +.codehilite .sr { color: #235388 } /* Literal.String.Regex */ +.codehilite .s1 { color: #4070a0 } /* Literal.String.Single */ +.codehilite .ss { color: #517918 } /* Literal.String.Symbol */ +.codehilite .bp { color: #007020 } /* Name.Builtin.Pseudo */ +.codehilite .fm { color: #06287e } /* Name.Function.Magic */ +.codehilite .vc { color: #bb60d5 } /* Name.Variable.Class */ +.codehilite .vg { color: #bb60d5 } /* Name.Variable.Global */ +.codehilite .vi { color: #bb60d5 } /* Name.Variable.Instance */ +.codehilite .vm { color: #bb60d5 } /* Name.Variable.Magic */ +.codehilite .il { color: #40a070 } /* Literal.Number.Integer.Long */ diff --git a/web/pandas_web.py b/web/pandas_web.py index e4ffa2cde7cc9..36eeb26ef8cc9 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -418,6 +418,9 @@ def main( body = markdown.markdown( content, extensions=context["main"]["markdown_extensions"] ) + # Apply Bootstrap's table formatting manually + # Python-Markdown doesn't let us config table attributes by hand + body = body.replace("", '
') content = extend_base_template(body, context["main"]["base_template"]) context["base_url"] = "".join(["../"] * os.path.normpath(fname).count("/")) content = jinja_env.from_string(content).render(**context)