Skip to content

Commit

Permalink
Merge pull request #2721 from plotly/remove-ansi2html
Browse files Browse the repository at this point in the history
Remove ansi2html.
  • Loading branch information
T4rk1n authored Jan 9, 2024
2 parents 7527383 + 0ebc553 commit 000ec18
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

## Changed
- [#2652](https://github.com/plotly/dash/pull/2652) dcc.Clipboard supports htm_content and triggers a copy to clipboard when n_clicks are changed
- [#2721](https://github.com/plotly/dash/pull/2721) Remove ansi2html, fixes [#2613](https://github.com/plotly/dash/issues/2713)

## [2.14.2] - 2023-11-27

Expand Down
28 changes: 5 additions & 23 deletions dash/_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import queue
import uuid
import re
import sys
import threading
import time
Expand All @@ -22,7 +21,6 @@
from IPython.core.display import HTML
from IPython.core.ultratb import FormattedTB
from retrying import retry
from ansi2html import Ansi2HTMLConverter
from ipykernel.comm import Comm
import nest_asyncio

Expand Down Expand Up @@ -450,13 +448,12 @@ def _wrap_errors(error):
original_formatargvalues = inspect.formatargvalues
inspect.formatargvalues = _custom_formatargvalues
try:
# Use IPython traceback formatting to build colored ANSI traceback
# string
# Use IPython traceback formatting to build the traceback string.
ostream = io.StringIO()
ipytb = FormattedTB(
tb_offset=skip,
mode="Verbose",
color_scheme="Linux",
color_scheme="NoColor",
include_vars=True,
ostream=ostream,
)
Expand All @@ -465,27 +462,12 @@ def _wrap_errors(error):
# Restore formatargvalues
inspect.formatargvalues = original_formatargvalues

# Print colored ANSI representation if requested
ansi_stacktrace = ostream.getvalue()
stacktrace = ostream.getvalue()

if self.inline_exceptions:
print(ansi_stacktrace)
print(stacktrace)

# Use ansi2html to convert the colored ANSI string to HTML
conv = Ansi2HTMLConverter(scheme="ansi2html", dark_bg=False)
html_str = conv.convert(ansi_stacktrace)

# Set width to fit 75-character wide stack trace and font to a size the
# won't require a horizontal scroll bar
html_str = html_str.replace(
"<html>", '<html style="width: 75ch; font-size: 0.86em">'
)

# Remove explicit background color so Dash dev-tools can set background
# color
html_str = re.sub("background-color:[^;]+;", "", html_str)

return html_str, 500
return stacktrace, 500

@property
def active(self):
Expand Down
2 changes: 1 addition & 1 deletion requires-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ flake8==3.9.2
flaky==3.7.0
flask-talisman==1.0.0
isort==4.3.21;python_version<"3.7"
mimesis
mimesis<=11.1.0
mock==4.0.3
numpy<=1.25.2
orjson==3.5.4;python_version<"3.7"
Expand Down
1 change: 0 additions & 1 deletion requires-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ contextvars==2.4;python_version<"3.7"
typing_extensions>=4.1.1
requests
retrying
ansi2html
nest-asyncio
setuptools

0 comments on commit 000ec18

Please sign in to comment.