update
This commit is contained in:
parent
68f4ef2954
commit
06248c86d2
|
@ -1,19 +1,14 @@
|
||||||
{
|
{
|
||||||
"root": true,
|
"root": true,
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 6,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@typescript-eslint"
|
"@typescript-eslint"
|
||||||
],
|
],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/naming-convention": "warn",
|
"@typescript-eslint/explicit-module-boundary-types": "off"
|
||||||
"@typescript-eslint/semi": "warn",
|
|
||||||
"curly": "warn",
|
|
||||||
"eqeqeq": "warn",
|
|
||||||
"no-throw-literal": "warn",
|
|
||||||
"semi": "off"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# vscode-texinfo
|
# vscode-texinfo
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.com/texinfo-lang/vscode-texinfo.svg)](https://travis-ci.com/github/texinfo-lang/vscode-texinfo)
|
[![Build Status](https://travis-ci.com/texinfo-lang/vscode-texinfo.svg)](https://travis-ci.com/github/texinfo-lang/vscode-texinfo)
|
||||||
[![MIT License](https://img.shields.io/badge/licence-MIT-blue.svg)](LICENSE)
|
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
|
||||||
|
|
||||||
Texinfo language support for Visual Studio Code.
|
Texinfo language support for Visual Studio Code.
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/CismonX/vscode-texinfo"
|
"url": "https://github.com/texinfo-lang/vscode-texinfo"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.49.0"
|
"vscode": "^1.49.0"
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "texinfo.showPreview",
|
"command": "texinfo.showPreview",
|
||||||
"title": "Show preview (Texinfo)",
|
"title": "Show preview (as HTML)",
|
||||||
"icon": "$(open-preview)"
|
"icon": "$(open-preview)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
"compile": "tsc -p ./",
|
"compile": "tsc -p ./",
|
||||||
"prepare": "sh ./scripts/prepare.sh",
|
"prepare": "sh ./scripts/prepare.sh",
|
||||||
"build": "npm run prepare && npm run compile",
|
"build": "npm run prepare && npm run compile",
|
||||||
"lint": "eslint src --ext ts",
|
"lint": "eslint --ext ts --fix src",
|
||||||
"watch": "tsc -watch -p ./"
|
"watch": "tsc -watch -p ./"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -14,9 +14,10 @@ import { exec } from './utils';
|
||||||
export class Converter {
|
export class Converter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a texinfo document to HTML.
|
* Convert a Texinfo document to HTML.
|
||||||
*
|
*
|
||||||
* @param path Path to the Texinfo document to be converted.
|
* @param path Path to the Texinfo document.
|
||||||
|
* @yields HTML code, or `undefined` if conversion fails.
|
||||||
*/
|
*/
|
||||||
static async convert(path: string) {
|
static async convert(path: string) {
|
||||||
const converter = new Converter(path);
|
const converter = new Converter(path);
|
||||||
|
@ -29,18 +30,10 @@ export class Converter {
|
||||||
private readonly options = ['-o', '-', '--no-split', '--html'];
|
private readonly options = ['-o', '-', '--no-split', '--html'];
|
||||||
|
|
||||||
private constructor(path: string) {
|
private constructor(path: string) {
|
||||||
if (Options.noHeaders) {
|
Options.noHeaders && this.options.push('--no-headers');
|
||||||
this.options.push('--no-headers');
|
Options.force && this.options.push('--force');
|
||||||
}
|
Options.noValidate && this.options.push('--no-validate');
|
||||||
if (Options.force) {
|
Options.noWarn && this.options.push('--no-warn');
|
||||||
this.options.push('--force');
|
|
||||||
}
|
|
||||||
if (Options.noValidate) {
|
|
||||||
this.options.push('--no-validate');
|
|
||||||
}
|
|
||||||
if (Options.noWarn) {
|
|
||||||
this.options.push('--no-warn');
|
|
||||||
}
|
|
||||||
this.options.push(`--error-limit=${Options.errorLimit}`);
|
this.options.push(`--error-limit=${Options.errorLimit}`);
|
||||||
this.options.push(path);
|
this.options.push(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ export class Preview {
|
||||||
|
|
||||||
private readonly panel: vscode.WebviewPanel;
|
private readonly panel: vscode.WebviewPanel;
|
||||||
|
|
||||||
private readonly disposables = new Array<vscode.Disposable>();
|
private readonly disposables = <vscode.Disposable[]>[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the preview is updating.
|
* Whether the preview is updating.
|
||||||
|
@ -83,14 +83,14 @@ export class Preview {
|
||||||
private constructor(private readonly document: vscode.TextDocument) {
|
private constructor(private readonly document: vscode.TextDocument) {
|
||||||
this.panel = vscode.window.createWebviewPanel('texinfo.preview', '', vscode.ViewColumn.Beside);
|
this.panel = vscode.window.createWebviewPanel('texinfo.preview', '', vscode.ViewColumn.Beside);
|
||||||
this.disposables.push(this.panel.onDidDispose(() => this.destroy()));
|
this.disposables.push(this.panel.onDidDispose(() => this.destroy()));
|
||||||
Preview.map.set(this.document, this);
|
Preview.map.set(document, this);
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
private get title() {
|
private updateTitle() {
|
||||||
const updating = this.updating ? '(Updating) ' : '';
|
const updating = this.updating ? '(Updating) ' : '';
|
||||||
const fileName = path.basename(this.document.fileName);
|
const fileName = path.basename(this.document.fileName);
|
||||||
return `${updating}Preview ${fileName}`;
|
this.panel.title = `${updating}Preview ${fileName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private destroy() {
|
private destroy() {
|
||||||
|
@ -106,15 +106,17 @@ export class Preview {
|
||||||
}
|
}
|
||||||
this.updating = true;
|
this.updating = true;
|
||||||
this.pendingUpdate = false;
|
this.pendingUpdate = false;
|
||||||
this.panel.title = this.title;
|
this.updateTitle();
|
||||||
|
|
||||||
const htmlCode = await Converter.convert(this.document.fileName);
|
const htmlCode = await Converter.convert(this.document.fileName);
|
||||||
if (htmlCode === undefined) {
|
if (htmlCode === undefined) {
|
||||||
vscode.window.showErrorMessage(`Failed to show preview for file ${this.document.fileName}.`);
|
vscode.window.showErrorMessage(`Failed to show preview for ${this.document.fileName}.`);
|
||||||
} else {
|
} else {
|
||||||
this.panel.webview.html = htmlCode;
|
this.panel.webview.html = htmlCode;
|
||||||
}
|
}
|
||||||
this.updating = false;
|
this.updating = false;
|
||||||
this.panel.title = this.title;
|
this.updateTitle();
|
||||||
|
|
||||||
if (this.pendingUpdate) {
|
if (this.pendingUpdate) {
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue