Support definition of Texinfo variables in config.
This commit is contained in:
parent
d5b84cdd7b
commit
7c4c04600f
57
package.json
57
package.json
|
@ -145,16 +145,6 @@
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"title": "Texinfo",
|
"title": "Texinfo",
|
||||||
"properties": {
|
"properties": {
|
||||||
"texinfo.makeinfo": {
|
|
||||||
"type": "string",
|
|
||||||
"default": "makeinfo",
|
|
||||||
"description": "Path to the `makeinfo` (or `texi2any`) command."
|
|
||||||
},
|
|
||||||
"texinfo.enableCodeLens": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": true,
|
|
||||||
"description": "Enable code lens on node identifiers which jumps to the corresponding nodes in preview."
|
|
||||||
},
|
|
||||||
"texinfo.completion.enableSnippets": {
|
"texinfo.completion.enableSnippets": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
@ -165,10 +155,26 @@
|
||||||
"default": true,
|
"default": true,
|
||||||
"description": "When snippet is enabled, hide the snippets' corresponding commands from completion items."
|
"description": "When snippet is enabled, hide the snippets' corresponding commands from completion items."
|
||||||
},
|
},
|
||||||
"texinfo.preview.noHeaders": {
|
"texinfo.preview.customCSS": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "URI of custom CSS for preview."
|
||||||
|
},
|
||||||
|
"texinfo.enableCodeLens": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Enable code lens on node identifiers which jumps to the corresponding nodes in preview."
|
||||||
|
},
|
||||||
|
"texinfo.preview.errorLimit": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 100,
|
||||||
|
"minimum": 0,
|
||||||
|
"description": "Max number of errors before quit when trying to display preview."
|
||||||
|
},
|
||||||
|
"texinfo.preview.localImage": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Suppress node separators in preview."
|
"description": "Display local images in in preview."
|
||||||
},
|
},
|
||||||
"texinfo.preview.maxSize": {
|
"texinfo.preview.maxSize": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
@ -177,11 +183,15 @@
|
||||||
"maximum": 16,
|
"maximum": 16,
|
||||||
"description": "Max allowed size (in MiB) for the preview document."
|
"description": "Max allowed size (in MiB) for the preview document."
|
||||||
},
|
},
|
||||||
"texinfo.preview.errorLimit": {
|
"texinfo.makeinfo": {
|
||||||
"type": "integer",
|
"type": "string",
|
||||||
"default": 100,
|
"default": "makeinfo",
|
||||||
"minimum": 0,
|
"description": "Path to the `makeinfo` (or `texi2any`) command."
|
||||||
"description": "Max number of errors before quit when trying to display preview."
|
},
|
||||||
|
"texinfo.preview.noHeaders": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Suppress node separators in preview."
|
||||||
},
|
},
|
||||||
"texinfo.preview.noValidation": {
|
"texinfo.preview.noValidation": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -193,15 +203,10 @@
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Suppress warnings."
|
"description": "Suppress warnings."
|
||||||
},
|
},
|
||||||
"texinfo.preview.localImage": {
|
"texinfo.vars": {
|
||||||
"type": "boolean",
|
"type": "array",
|
||||||
"default": false,
|
"default": [],
|
||||||
"description": "Display local images in in preview."
|
"description": "Define variables."
|
||||||
},
|
|
||||||
"texinfo.preview.customCSS": {
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"description": "URI of custom CSS for preview."
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,8 +72,16 @@ export default class Options {
|
||||||
return this.getBoolean('preview.noWarnings');
|
return this.getBoolean('preview.noWarnings');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get vars() {
|
||||||
|
return this.getArray('vars');
|
||||||
|
}
|
||||||
|
|
||||||
private readonly configuration = vscode.workspace.getConfiguration('texinfo');
|
private readonly configuration = vscode.workspace.getConfiguration('texinfo');
|
||||||
|
|
||||||
|
private getArray(section: string) {
|
||||||
|
return this.configuration.get(section, <readonly string[]>[]);
|
||||||
|
}
|
||||||
|
|
||||||
private getBoolean(section: string) {
|
private getBoolean(section: string) {
|
||||||
return this.configuration.get(section, false);
|
return this.configuration.get(section, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,7 @@ export default class CompletionItemProvider implements vscode.CompletionItemProv
|
||||||
...blockCommand('ifhtml', 'Begin text that will appear only in HTML format'),
|
...blockCommand('ifhtml', 'Begin text that will appear only in HTML format'),
|
||||||
...blockCommand('ifinfo', 'Begin text that will appear only in Info format'),
|
...blockCommand('ifinfo', 'Begin text that will appear only in Info format'),
|
||||||
...blockCommand('ifplaintext', 'Begin text that will appear only in plain text format'),
|
...blockCommand('ifplaintext', 'Begin text that will appear only in plain text format'),
|
||||||
|
...blockCommand('ifset', 'If the Texinfo variable is set, format the following text', 'txivar'),
|
||||||
...blockCommand('iftex', 'Begin text that will appear only in TeX format'),
|
...blockCommand('iftex', 'Begin text that will appear only in TeX format'),
|
||||||
...blockCommand('ifxml', 'Begin text that will appear only in XML format'),
|
...blockCommand('ifxml', 'Begin text that will appear only in XML format'),
|
||||||
...blockCommand('ifnotdocbook', 'Begin text to be ignored in DocBook format'),
|
...blockCommand('ifnotdocbook', 'Begin text to be ignored in DocBook format'),
|
||||||
|
|
|
@ -36,7 +36,8 @@ export default class Converter {
|
||||||
this.options.noHeaders && options.push('--no-headers');
|
this.options.noHeaders && options.push('--no-headers');
|
||||||
this.options.noValidation && options.push('--no-validate');
|
this.options.noValidation && options.push('--no-validate');
|
||||||
this.options.noWarnings && options.push('--no-warn');
|
this.options.noWarnings && options.push('--no-warn');
|
||||||
this.options.customCSS && this.includeCustomCSS(this.options.customCSS, options);
|
this.includeCustomCSS(this.options.customCSS, options);
|
||||||
|
this.addVars(this.options.vars, options);
|
||||||
const result = await exec(this.options.makeinfo, options.concat(this.path), this.options.maxSize);
|
const result = await exec(this.options.makeinfo, options.concat(this.path), this.options.maxSize);
|
||||||
if (result.data !== undefined) {
|
if (result.data !== undefined) {
|
||||||
// No worry about performance here, as the DOM is lazily initialized.
|
// No worry about performance here, as the DOM is lazily initialized.
|
||||||
|
@ -50,7 +51,12 @@ export default class Converter {
|
||||||
|
|
||||||
constructor(private readonly path: string, private readonly options: Options, private readonly logger: Logger) {}
|
constructor(private readonly path: string, private readonly options: Options, private readonly logger: Logger) {}
|
||||||
|
|
||||||
|
private addVars(vars: readonly string[], options: string[]) {
|
||||||
|
vars.forEach(varName => options.push('-D', varName));
|
||||||
|
}
|
||||||
|
|
||||||
private includeCustomCSS(cssFileURI: string, options: string[]) {
|
private includeCustomCSS(cssFileURI: string, options: string[]) {
|
||||||
|
if (!cssFileURI) return;
|
||||||
try {
|
try {
|
||||||
const uri = vscode.Uri.parse(cssFileURI, true);
|
const uri = vscode.Uri.parse(cssFileURI, true);
|
||||||
switch (uri.scheme) {
|
switch (uri.scheme) {
|
||||||
|
|
Loading…
Reference in New Issue