mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 03:35:31 -05:00
Apply prettier to css, html, js, md, ts, and yml (#1249)
* Apply prettier to css, js, html, md, ts, and yml As a followup I will add prettier to the .pre-commit config. This patch is 100% generated by prettier. I used a forked version of prettier that understands the py-script tag. See https://github.com/hoodmane/pyscript-prettier-precommit for more info. * Apply old pre-commit * Revert some problems * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert some changes * More changes * Fix pre-commit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createSingularWarning, escape } from "./utils";
|
||||
import { createSingularWarning, escape } from './utils';
|
||||
|
||||
export interface Stdio {
|
||||
stdout_writeline: (msg: string) => void;
|
||||
@@ -42,8 +42,7 @@ export class CaptureStdio implements Stdio {
|
||||
* specified by ID. Used with "output" keyword.
|
||||
*
|
||||
*/
|
||||
export class TargetedStdio implements Stdio{
|
||||
|
||||
export class TargetedStdio implements Stdio {
|
||||
source_element: HTMLElement;
|
||||
source_attribute: string;
|
||||
capture_stdout: boolean;
|
||||
@@ -66,31 +65,32 @@ export class TargetedStdio implements Stdio{
|
||||
*
|
||||
* @param msg The output to be written
|
||||
*/
|
||||
writeline_by_attribute(msg:string){
|
||||
const target_id = this.source_element.getAttribute(this.source_attribute)
|
||||
const target = document.getElementById(target_id)
|
||||
if (target === null) { // No matching ID
|
||||
createSingularWarning(`${this.source_attribute} = "${target_id}" does not match the id of any element on the page.`)
|
||||
writeline_by_attribute(msg: string) {
|
||||
const target_id = this.source_element.getAttribute(this.source_attribute);
|
||||
const target = document.getElementById(target_id);
|
||||
if (target === null) {
|
||||
// No matching ID
|
||||
createSingularWarning(
|
||||
`${this.source_attribute} = "${target_id}" does not match the id of any element on the page.`,
|
||||
);
|
||||
} else {
|
||||
msg = escape(msg).replace('\n', '<br>');
|
||||
if (!msg.endsWith('<br/>') && !msg.endsWith('<br>')) {
|
||||
msg = msg + '<br>';
|
||||
}
|
||||
else {
|
||||
msg = escape(msg).replace("\n", "<br>")
|
||||
if (!msg.endsWith("<br/>") && !msg.endsWith("<br>")){
|
||||
msg = msg + "<br>"
|
||||
}
|
||||
target.innerHTML += msg
|
||||
}
|
||||
}
|
||||
|
||||
stdout_writeline (msg: string) {
|
||||
if (this.capture_stdout){
|
||||
this.writeline_by_attribute(msg)
|
||||
target.innerHTML += msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stderr_writeline (msg: string) {
|
||||
if (this.capture_stderr){
|
||||
this.writeline_by_attribute(msg)
|
||||
stdout_writeline(msg: string) {
|
||||
if (this.capture_stdout) {
|
||||
this.writeline_by_attribute(msg);
|
||||
}
|
||||
}
|
||||
|
||||
stderr_writeline(msg: string) {
|
||||
if (this.capture_stderr) {
|
||||
this.writeline_by_attribute(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,9 +109,9 @@ export class StdioMultiplexer implements Stdio {
|
||||
}
|
||||
|
||||
removeListener(obj: Stdio) {
|
||||
const index = this._listeners.indexOf(obj)
|
||||
if (index > -1){
|
||||
this._listeners.splice(index, 1)
|
||||
const index = this._listeners.indexOf(obj);
|
||||
if (index > -1) {
|
||||
this._listeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user