ui: create new AnsiUp instance for every render

This commit is contained in:
undefined committed 2026-08-29 08:53:11 +00:00
1 parent 86d2a36731
commit e137e1940f
2 files changed
+2 -6

No files matched your search

+1 -3
View File
@@ -3,10 +3,8 @@ import { AnsiUp } from 'ansi_up';
export { formatSeconds, size } from 'hydrooj';
const AU = new AnsiUp();
export function ansiToHtml(str: string, whiteToBlack = true) {
const res = AU.ansi_to_html(str);
const res = new AnsiUp().ansi_to_html(str);
return whiteToBlack ? res.replace(/style="color:rgb\(255,255,255\)"/g, 'style="color:black"') : res;
}
@@ -7,8 +7,6 @@ import { i18n } from 'vj/utils';
import DataInput from './DataInputComponent';
import Panel from './PanelComponent';
const AU = new AnsiUp();
const mapStateToProps = (state) => ({
input: state.pretest.input,
output: state.pretest.output,
@@ -47,7 +45,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadPret
/>
<DataInput
title={i18n('Output')}
value={AU.ansi_to_html(this.props.output)}
value={new AnsiUp().ansi_to_html(this.props.output)}
html
/>
</Allotment>