Compare commits
19 Commits
Author | SHA1 | Date |
---|---|---|
CismonX | f8bcf86fb1 | |
CismonX | 8f289fbcb8 | |
CismonX | afe3694a88 | |
CismonX | 530902128c | |
CismonX | 1294764698 | |
CismonX | 9de1ba26b0 | |
CismonX | 13feb8a1f4 | |
CismonX | ad685014d2 | |
CismonX | 3f8c23d917 | |
CismonX | 3b3478decb | |
CismonX | a5837defce | |
CismonX | 5e86022e32 | |
CismonX | 229d84bd2d | |
CismonX | c3e33c3340 | |
CismonX | 2275b94c1d | |
CismonX | 7820db6955 | |
CismonX | 26c8d32129 | |
CismonX | c111ec89a0 | |
CismonX | 3896bf44db |
|
@ -6,6 +6,7 @@
|
|||
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||
#
|
||||
|
||||
*.asc
|
||||
*.vsix
|
||||
.vscode/
|
||||
node_modules/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
**/*.map
|
||||
**/*.ts
|
||||
.drone.yml
|
||||
.woodpecker.yml
|
||||
.gitignore
|
||||
.gitattributes
|
||||
.travis.yml
|
||||
|
|
|
@ -6,12 +6,16 @@
|
|||
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||
#
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
# For history build logs,
|
||||
# see <https://ci.cismon.net/repos/cismonx/vscode-texinfo>.
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: node:14.18
|
||||
image: node:18-alpine
|
||||
when:
|
||||
- event: [push, tag, manual]
|
||||
branch: primary
|
||||
commands:
|
||||
- npm --unsafe-perm ci
|
||||
- apk add --no-cache perl unzip
|
||||
- npm ci
|
||||
- npm run package
|
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -1,13 +1,26 @@
|
|||
<!--
|
||||
Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
this notice are preserved. This file is offered as-is, without any warranty.
|
||||
Copyright (C) 2020,2021,2022,2024 CismonX <admin@cismon.net>
|
||||
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
this notice are preserved. This file is offered as-is, without any warranty.
|
||||
-->
|
||||
|
||||
# Changelog
|
||||
|
||||
## v0.3.0 - 04/04/2024
|
||||
|
||||
* Add configuration for customization variables (`makeinfo -c KEY=VAL`).
|
||||
* Support GNU Texinfo 7.1.
|
||||
|
||||
## v0.2.4 - 02/02/2022
|
||||
|
||||
* Fix a bug which breaks the snippet completion of block commands.
|
||||
|
||||
## v0.2.3 - 10/23/2021
|
||||
|
||||
* Fix a bug which prevents diagnostic info from displaying correctly in GNU Texinfo 6.8, and on Windows platform.
|
||||
|
||||
## v0.2.2 - 10/03/2021
|
||||
|
||||
* Fix a bug which breaks configuration `preview.includePaths` on Windows.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<!--
|
||||
Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||
Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
this notice are preserved. This file is offered as-is, without any warranty.
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
this notice are preserved. This file is offered as-is, without any warranty.
|
||||
-->
|
||||
|
||||
# License Notice
|
||||
|
@ -13,34 +13,32 @@ this notice are preserved. This file is offered as-is, without any warranty.
|
|||
Project files listed below cannot carry a license notice by themselves, due to
|
||||
file format restrictions.
|
||||
|
||||
```text
|
||||
assets/texinfo.png
|
||||
```
|
||||
assets/texinfo.png
|
||||
|
||||
They should be treated as if they each contains the following text:
|
||||
|
||||
```text
|
||||
Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
this notice are preserved. This file is offered as-is, without any warranty.
|
||||
```
|
||||
This file is released into the public domain using [CC0].
|
||||
|
||||
## Files from other projects
|
||||
|
||||
Source code from the projects listed below are **not** part of vscode-texinfo.
|
||||
Source code from the projects listed below are *not* part of vscode-texinfo.
|
||||
However, when building the project, they are downloaded, compiled, and packaged
|
||||
into a single binary file alongside with vscode-texinfo.
|
||||
|
||||
| Project | Copyright Holder | License |
|
||||
| - | - | - |
|
||||
| [Texinfo syntax highlighting](https://github.com/Alhadis/language-texinfo) | John Gardner | [ISC](https://github.com/Alhadis/language-texinfo/blob/master/LICENSE.md) |
|
||||
| Project | Copyright Holder | License |
|
||||
| - | - | - |
|
||||
| [Texinfo syntax highlighting] | John Gardner | [ISC](https://github.com/Alhadis/language-texinfo/blob/master/LICENSE.md) |
|
||||
|
||||
The following projects are required during runtime of vscode-texinfo, but as
|
||||
separate programs.
|
||||
|
||||
| Project | Copyright Holder | License |
|
||||
| - | - | - |
|
||||
| [Visual Studio Code](https://github.com/microsoft/vscode) | Microsoft Corporation | [MIT](https://github.com/microsoft/vscode/blob/main/LICENSE.txt) |
|
||||
| [GNU Texinfo](https://www.gnu.org/software/texinfo) | Free Software Foundation | [GPL-3.0](https://git.savannah.gnu.org/cgit/texinfo.git/tree/COPYING)-or-later |
|
||||
| Project | Copyright Holder | License |
|
||||
| - | - | - |
|
||||
| [Visual Studio Code] | Microsoft Corporation | [MIT](https://github.com/microsoft/vscode/blob/main/LICENSE.txt) |
|
||||
| [GNU Texinfo] | Free Software Foundation | [GPL-3.0](https://git.savannah.gnu.org/cgit/texinfo.git/tree/COPYING)-or-later |
|
||||
|
||||
|
||||
<!-- Reference Links -->
|
||||
|
||||
[CC0]: https://creativecommons.org/public-domain/cc0/
|
||||
[Texinfo syntax highlighting]: https://github.com/Alhadis/language-texinfo
|
||||
[Visual Studio Code]: https://github.com/microsoft/vscode
|
||||
[GNU Texinfo]: https://www.gnu.org/software/texinfo
|
||||
|
|
19
README.md
19
README.md
|
@ -1,5 +1,5 @@
|
|||
<!--
|
||||
Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
Copyright (C) 2020,2021,2024 CismonX <admin@cismon.net>
|
||||
|
||||
Copying and distribution of this file, with or without modification, are
|
||||
permitted in any medium without royalty, provided the copyright notice and
|
||||
|
@ -8,14 +8,13 @@
|
|||
|
||||
# vscode-texinfo
|
||||
|
||||
[![Build Status]][Drone CI] [![License]](LICENSE)
|
||||
[![License]](LICENSE)
|
||||
|
||||
## About
|
||||
|
||||
vscode-texinfo is an extension of Visual Studio Code which aims at improving
|
||||
user experience for editing Texinfo documents.
|
||||
vscode-texinfo is an extension of [Visual Studio Code] which provides the
|
||||
following features for editing [Texinfo] documents:
|
||||
|
||||
Major features include:
|
||||
* Syntax Highlighting
|
||||
* Code Completion
|
||||
* HTML Preview
|
||||
|
@ -25,12 +24,12 @@ Major features include:
|
|||
|
||||
## Getting Started
|
||||
|
||||
For instructions about how to install, use, and contribute to vscode-texinfo,
|
||||
see the [online user manual].
|
||||
For instructions on how to install, use, and contribute to vscode-texinfo,
|
||||
see the [user manual].
|
||||
|
||||
<!-- Reference Links -->
|
||||
|
||||
[Build Status]: https://shields.io/drone/build/CismonX/vscode-texinfo?server=https%3A%2F%2Fdrone.cismon.net
|
||||
[Drone CI]: https://drone.cismon.net/CismonX/vscode-texinfo
|
||||
[Visual Studio Code]: https://github.com/microsoft/vscode
|
||||
[Texinfo]: https://www.gnu.org/software/texinfo/
|
||||
[License]: https://img.shields.io/badge/license-GPL--3.0--or--later-blue.svg
|
||||
[online user manual]: https://nongnu.org/vscode-texinfo/manual
|
||||
[user manual]: https://nongnu.org/vscode-texinfo/manual
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
@set vscode-docs-url https://code.visualstudio.com/docs
|
||||
@set vscode-api-url https://code.visualstudio.com/api
|
||||
@set gnu-texinfo-docs https://www.gnu.org/software/texinfo/manual/texinfo
|
||||
@set sv-home-url https://sv.nongnu.org
|
||||
@set sv-releases-url https://dl.sv.nongnu.org/releases
|
||||
|
||||
@tex
|
||||
\global\def\linkcolor{0 0 1}
|
||||
|
@ -20,7 +22,7 @@
|
|||
This manual is for vscode-texinfo (version @value{VERSION}), an extension of
|
||||
Visual Studio Code.
|
||||
|
||||
Copyright @copyright{} 2021 CismonX <admin@@cismon.net>
|
||||
Copyright @copyright{} 2021,2024 CismonX <admin@@cismon.net>
|
||||
|
||||
@quotation
|
||||
This manual is licensed under a
|
||||
|
@ -51,7 +53,7 @@ Creative Commons Attribution-ShareAlike 4.0 International License}.
|
|||
This manual is for vscode-texinfo (version @value{VERSION}), an extension of
|
||||
Visual Studio Code.
|
||||
|
||||
Copyright @copyright{} 2021 CismonX <admin@@cismon.net>
|
||||
Copyright @copyright{} 2021,2024 CismonX <admin@@cismon.net>
|
||||
|
||||
This manual is licensed under a
|
||||
@url{https://creativecommons.org/licenses/by-sa/4.0/,
|
||||
|
@ -99,11 +101,11 @@ version 3 of the License}, or (at your option) any later version.
|
|||
@node Contributing
|
||||
@section Contributing
|
||||
|
||||
This project is hosted on @url{https://sv.gnu.org/p/vscode-texinfo, Savannah}.
|
||||
This project is hosted on @url{@value{sv-home-url}/p/vscode-texinfo, Savannah}.
|
||||
Any kind of contribution is welcome, including bug reports, patches, and
|
||||
general discussions regarding the usage of vscode-texinfo.
|
||||
|
||||
Before you submit something, please make sure that you have read this manual,
|
||||
Before you post something, please make sure that you have read this manual,
|
||||
and no one else has posted the same content.
|
||||
|
||||
|
||||
|
@ -120,7 +122,7 @@ binary release, which is proprietary software. You can also build it from
|
|||
|
||||
@quotation Note
|
||||
Theoretically vscode-texinfo can work with any version of Visual Studio Code
|
||||
since 1.40, but not all versions are tested. It's recommended to install a
|
||||
since 1.82, but not all versions are tested. It's recommended to install a
|
||||
latest release.
|
||||
@end quotation
|
||||
|
||||
|
@ -139,7 +141,7 @@ and you can find and install this extension (Extension ID:
|
|||
@section Manual Installation
|
||||
|
||||
You can manually download the @code{.vsix} file, from either Savannah's
|
||||
@url{https://dl.sv.gnu.org/releases/vscode-texinfo/, download area},
|
||||
@url{@value{sv-releases-url}/vscode-texinfo/, download area},
|
||||
@url{https://open-vsx.org/extension/CismonX/texinfo, Open VSX Registry}, or the
|
||||
proprietary Visual Studio Marketplace.
|
||||
|
||||
|
@ -148,28 +150,12 @@ you should check whether the file matches a trusted signature:
|
|||
|
||||
@set vsix-name texinfo-@value{VERSION}.vsix
|
||||
|
||||
@ifhtml
|
||||
@example
|
||||
wget -O cismonx.gpg.asc "https://sv.gnu.org/people/viewgpg.php?user_id=214244"
|
||||
gpg --import cismonx.gpg.asc
|
||||
|
||||
wget https://dl.sv.gnu.org/releases/vscode-texinfo/@value{vsix-name}.sig.asc
|
||||
gpg --verify @value{vsix-name}.sig.asc @value{vsix-name}
|
||||
wget -O- '@value{sv-home-url}/people/viewgpg.php?user_id=214244' \
|
||||
| gpg --import
|
||||
wget -O- @value{sv-releases-url}/vscode-texinfo/@value{vsix-name}.sig.asc \
|
||||
| gpg --verify - @value{vsix-name}
|
||||
@end example
|
||||
@end ifhtml
|
||||
|
||||
@ifnothtml
|
||||
@example
|
||||
wget -O cismonx.gpg.asc \
|
||||
"https://sv.gnu.org/people/viewgpg.php?user_id=214244"
|
||||
gpg --import cismonx.gpg.asc
|
||||
|
||||
wget "https://dl.sv.gnu.org/releases/vscode-texinfo/
|
||||
@value{vsix-name}.sig.asc"
|
||||
gpg --verify @value{vsix-name}.sig.asc @value{vsix-name}
|
||||
@end example
|
||||
@end ifnothtml
|
||||
|
||||
|
||||
Finally, install the @code{.vsix} file to Visual Studio Code via command
|
||||
palette: @code{Extensions: Install from VSIX...}.
|
||||
|
@ -178,7 +164,7 @@ palette: @code{Extensions: Install from VSIX...}.
|
|||
@node Build from Source
|
||||
@section Build from Source
|
||||
|
||||
You can generate the @code{.vsix} file from the source code of vscode-texinfo.
|
||||
The @code{.vsix} file can be built from the source code of vscode-texinfo.
|
||||
|
||||
First, clone the source code repository:
|
||||
|
||||
|
@ -370,7 +356,7 @@ the extension. To manually trigger a refresh, click the status bar item.
|
|||
@section HTML Preview
|
||||
|
||||
You can generate the HTML preview of a Texinfo document in Visual Studio Code,
|
||||
to see how the document looks like when displayed online.
|
||||
to see how the document looks like when displayed in a web browser.
|
||||
|
||||
In the active text editor which contains a Texinfo document, click the ``Show
|
||||
Preview'' button on the top right of the editor. A webview will be created in a
|
||||
|
@ -457,6 +443,8 @@ are not validated. (@code{--no-validate})
|
|||
@item @code{texinfo.preview.variables}: Array of variables to define (as with
|
||||
@code{@@set}). If a variable has a value, use the ASCII space character to
|
||||
separate key and value.
|
||||
@item @code{texinfo.preview.customizationVariables}: Array of customization
|
||||
variables. (@code{-c KEY=VALUE})
|
||||
@end itemize
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
50
package.json
50
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"_copyrightNotice": [
|
||||
"Copyright (C) 2020,2021 CismonX <admin@cismon.net>",
|
||||
"Copyright (C) 2020,2021,2022,2024 CismonX <admin@cismon.net>",
|
||||
"Copying and distribution of this file, with or without modification,",
|
||||
"are permitted in any medium without royalty, provided the copyright notice and this notice are preserved.",
|
||||
"This file is offered as-is, without any warranty."
|
||||
|
@ -9,37 +9,37 @@
|
|||
"displayName": "Texinfo Language Support",
|
||||
"description": "Texinfo language support for Visual Studio Code",
|
||||
"publisher": "cismonx",
|
||||
"version": "0.2.2",
|
||||
"version": "0.3.0",
|
||||
"author": {
|
||||
"name": "CismonX",
|
||||
"email": "admin@cismon.net",
|
||||
"url": "https://cismon.net"
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"homepage": "https://sv.gnu.org/p/vscode-texinfo",
|
||||
"homepage": "https://savannah.nongnu.org/p/vscode-texinfo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.sv.gnu.org/cgit/vscode-texinfo.git"
|
||||
"url": "https://git.savannah.nongnu.org/cgit/vscode-texinfo.git"
|
||||
},
|
||||
"icon": "assets/texinfo.png",
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.17.20",
|
||||
"@types/vscode": "~1.40.0",
|
||||
"@types/webpack": "^5.28.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
||||
"@typescript-eslint/parser": "^4.32.0",
|
||||
"cson": "^7.20.0",
|
||||
"eslint": "^7.32.0",
|
||||
"@types/node": "^18.11.9",
|
||||
"@types/vscode": "~1.82.0",
|
||||
"@types/webpack": "^5.28.5",
|
||||
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
||||
"@typescript-eslint/parser": "^7.5.0",
|
||||
"@vscode/vsce": "^2.24.0",
|
||||
"cson": "^8.4.0",
|
||||
"eslint": "^8.57.0",
|
||||
"json": "^11.0.0",
|
||||
"json5": "^2.2.0",
|
||||
"json5": "^2.2.3",
|
||||
"language-texinfo": "^1.1.0",
|
||||
"minify-xml": "^3.2.0",
|
||||
"ts-loader": "^9.2.6",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.4.3",
|
||||
"vsce": "^1.100.1",
|
||||
"webpack": "^5.56.0",
|
||||
"webpack-cli": "^4.8.0"
|
||||
"minify-xml": "^4.4.1",
|
||||
"ts-loader": "^9.5.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.3",
|
||||
"webpack": "^5.91.0",
|
||||
"webpack-cli": "^5.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "webpack --mode production",
|
||||
|
@ -79,7 +79,7 @@
|
|||
}
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.40.0"
|
||||
"vscode": "^1.82.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages",
|
||||
|
@ -87,9 +87,6 @@
|
|||
"Other"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"activationEvents": [
|
||||
"onLanguage:texinfo"
|
||||
],
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
|
@ -166,7 +163,7 @@
|
|||
"texinfo.makeinfo": {
|
||||
"type": "string",
|
||||
"default": "makeinfo",
|
||||
"description": "Path to the makeinfo (or texi2any) command."
|
||||
"description": "Path to the makeinfo (or texi2any) program."
|
||||
},
|
||||
"texinfo.preview.customCSS": {
|
||||
"type": "string",
|
||||
|
@ -210,6 +207,11 @@
|
|||
"type": "array",
|
||||
"default": [],
|
||||
"description": "Define variables (as with @set)."
|
||||
},
|
||||
"texinfo.preview.customizationVariables": {
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"description": "Set customization variables (format: KEY=VAL)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,41 +1,45 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||
# Copyright (C) 2021,2024 CismonX <admin@cismon.net>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty, provided the copyright notice and
|
||||
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||
#
|
||||
|
||||
VSIX_FILE_NAME=texinfo-$(json -f package.json version).vsix
|
||||
PACKAGE_JSON_CLEANUP_JS=$(cat ./scripts/package-json-cleanup.js)
|
||||
set -e
|
||||
|
||||
vsce package --baseContentUrl=$(json -f package.json repository.url)/tree
|
||||
version=$(json -f package.json version)
|
||||
vsix_file_name=texinfo-$version.vsix
|
||||
vsce package --baseContentUrl="$(json -f package.json repository.url)/tree"
|
||||
unzip -d "$vsix_file_name.d" "$vsix_file_name"
|
||||
|
||||
cd "$vsix_file_name.d"
|
||||
minify_xml() {
|
||||
minify-xml --no-shorten-namespaces --no-remove-unused-namespaces \
|
||||
--no-remove-unused-default-namespace -i "$1"
|
||||
}
|
||||
minify_xml '[Content_Types].xml'
|
||||
minify_xml extension.vsixmanifest
|
||||
|
||||
unzip -d $VSIX_FILE_NAME{.d,}
|
||||
cd $VSIX_FILE_NAME.d
|
||||
MINIFY_XML_OPTIONS='--no-shorten-namespaces
|
||||
--no-remove-unused-namespaces
|
||||
--no-remove-unused-default-namespace'
|
||||
minify-xml $MINIFY_XML_OPTIONS --output \[Content_Types\].xml{,}
|
||||
minify-xml $MINIFY_XML_OPTIONS --output extension.vsixmanifest{,}
|
||||
cd extension
|
||||
# Minify JSON files.
|
||||
json -j0 -I -e "$PACKAGE_JSON_CLEANUP_JS" -f package.json
|
||||
json -j0 -I -e "$(cat ../../scripts/package-json-cleanup.js)" -f package.json
|
||||
perl -pi -e 'chomp if eof' package.json
|
||||
json5 -o language-configuration.json{,}
|
||||
json5 language-configuration.json > _ && mv _ language-configuration.json
|
||||
# Remove comments from Markdown files.
|
||||
tail -n +9 README.md > _ && mv _ README.md
|
||||
tail -n +9 CHANGELOG.md > _ && mv _ CHANGELOG.md
|
||||
|
||||
cd ext
|
||||
# Minify Perl scripts.
|
||||
# You can install perltidy with `cpan Perl::Tidy`
|
||||
if [[ -x "$(command -v perltidy)" ]]; then
|
||||
if command -v perltidy; then
|
||||
perltidy --mangle -dac -b html-preview.pm
|
||||
rm html-preview.pm.bak
|
||||
fi
|
||||
cd ../../..
|
||||
|
||||
cd ../../..
|
||||
# Re-package .vsix file.
|
||||
node ./scripts/make-vsix.js $VSIX_FILE_NAME
|
||||
rm -r $VSIX_FILE_NAME.d
|
||||
node ./scripts/make-vsix.js "$vsix_file_name"
|
||||
rm -r "$vsix_file_name.d"
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
# Copyright (C) 2020,2021,2024 CismonX <admin@cismon.net>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty, provided the copyright notice and
|
||||
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||
#
|
||||
|
||||
SRC_PATH=./node_modules/language-texinfo
|
||||
DEST_PATH=./out/grammars
|
||||
mkdir -p $DEST_PATH
|
||||
# Convert TextMate grammar to JSON, as VSCode cannot recognize CSON ones.
|
||||
cson2json $SRC_PATH/grammars/texinfo.cson | json5 > $DEST_PATH/texinfo.json
|
||||
set -e
|
||||
|
||||
VERSION=$(json -f package.json version)
|
||||
echo "@set VERSION $VERSION" > ./doc/version.texi
|
||||
src_path=./node_modules/language-texinfo
|
||||
dest_path=./out/grammars
|
||||
|
||||
mkdir -p $dest_path
|
||||
|
||||
# Convert TextMate grammar to JSON, since VSCode cannot recognize CSON ones.
|
||||
cson2json $src_path/grammars/texinfo.cson | json5 > $dest_path/texinfo.json
|
||||
|
||||
version=$(json -f package.json version)
|
||||
echo "@set VERSION $version" > ./doc/version.texi
|
||||
|
|
|
@ -97,7 +97,9 @@ export default class ContextMapping implements vscode.Disposable
|
|||
|
||||
private _onDocumentSave(document: vscode.TextDocument) {
|
||||
const documentContext = this._tryGetDocumentContext(document);
|
||||
if (documentContext === undefined) return;
|
||||
if (documentContext === undefined) {
|
||||
return;
|
||||
}
|
||||
documentContext.foldingRange.clear();
|
||||
documentContext.getPreview()?.updateWebview();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,9 @@ export default class FoldingRangeContext
|
|||
*/
|
||||
update(events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
||||
this._contentMayChange = true;
|
||||
if (this._foldingRanges === undefined) return false;
|
||||
if (this._foldingRanges === undefined) {
|
||||
return false;
|
||||
}
|
||||
const eol = this._document.eol === vscode.EndOfLine.LF ? '\n' : '\r\n';
|
||||
for (const event of events) {
|
||||
// Clear cached folding range when line count changes.
|
||||
|
@ -147,7 +149,9 @@ export default class FoldingRangeContext
|
|||
}
|
||||
// Process block.
|
||||
if (line.startsWith('@end ')) {
|
||||
if (verbatim) continue;
|
||||
if (verbatim) {
|
||||
continue;
|
||||
}
|
||||
const name = line.substring(5).trimRight();
|
||||
if (name === 'verbatim') {
|
||||
verbatim = true;
|
||||
|
@ -193,14 +197,20 @@ export default class FoldingRangeContext
|
|||
private _getLastTextLine(lineNum: number, limit = 3) {
|
||||
for (let idx = lineNum; idx > lineNum - limit; --idx) {
|
||||
const line = this._document.lineAt(idx).text;
|
||||
if (line.startsWith('@node ')) return idx - 1;
|
||||
if (line === '') return idx;
|
||||
if (line.startsWith('@node ')) {
|
||||
return idx - 1;
|
||||
}
|
||||
if (line === '') {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
return lineNum;
|
||||
}
|
||||
|
||||
private _processComment(lineText: string, lineNum: number) {
|
||||
if (!lineText.startsWith('@c')) return false;
|
||||
if (!lineText.startsWith('@c')) {
|
||||
return false;
|
||||
}
|
||||
if (lineText.charAt(2) != ' ' && !lineText.startsWith('omment ', 2)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -233,7 +243,9 @@ export default class FoldingRangeContext
|
|||
lastLineNum: number,
|
||||
) {
|
||||
const result = lineText.match(FoldingRangeContext._nodeFormat);
|
||||
if (result === null) return false;
|
||||
if (result === null) {
|
||||
return false;
|
||||
}
|
||||
// Node identifier.
|
||||
if (result[1] !== undefined) {
|
||||
this._nodes.push(new vscode.CodeLens(lineNumToRange(lineNum), {
|
||||
|
|
|
@ -127,7 +127,9 @@ export default class PreviewContext
|
|||
* preview with code lens.
|
||||
*/
|
||||
private get _script() {
|
||||
if (!this._globalContext.options.enableCodeLens) return undefined;
|
||||
if (!this._globalContext.options.enableCodeLens) {
|
||||
return undefined;
|
||||
}
|
||||
return "window.addEventListener('message', event => {" +
|
||||
"const message = event.data;" +
|
||||
"switch (message.command) {" +
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
* vscode-texinfo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { lineNumToRange } from './utils/misc';
|
||||
import { escapeStringForRegExp, lineNumToRange } from './utils/misc';
|
||||
import { isDefined } from './utils/types';
|
||||
|
||||
/**
|
||||
|
@ -44,10 +45,19 @@ export default class Diagnosis implements vscode.Disposable
|
|||
* @param logText
|
||||
*/
|
||||
update(document: vscode.TextDocument, logText: string) {
|
||||
const fileName = document.uri.path;
|
||||
const fileName = path.basename(document.uri.path);
|
||||
const regex = new RegExp(`${escapeStringForRegExp(fileName)}:\\d+:`);
|
||||
const diagnostics = logText.split('\n')
|
||||
.filter(line => line.startsWith(fileName))
|
||||
.map(line => logToDiagnostic(line.substring(fileName.length + 1)))
|
||||
.map(line => line.length > 0 ? line.match(regex) : null)
|
||||
.map(result => {
|
||||
const index = result?.index;
|
||||
const line = result?.input;
|
||||
if (index === undefined || line === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const logText = line.substring(index + fileName.length + 1);
|
||||
return logToDiagnostic(logText);
|
||||
})
|
||||
.filter(isDefined);
|
||||
this._diagnostics.set(document.uri, diagnostics);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* indicator.ts
|
||||
*
|
||||
* Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
* Copyright (C) 2020,2021,2024 CismonX <admin@cismon.net>
|
||||
*
|
||||
* This file is part of vscode-texinfo.
|
||||
*
|
||||
|
@ -85,16 +85,19 @@ export default class Indicator implements vscode.Disposable
|
|||
const output
|
||||
= await exec(options.makeinfo, ['--version'], options.maxSize);
|
||||
const result = output.data?.match(/\(GNU texinfo\) (.*)\n/);
|
||||
let tooltip = '', icon: string, version = '';
|
||||
if (result && result[1]) {
|
||||
version = result[1];
|
||||
if (!isNaN(+version) && +version < 6.8) {
|
||||
icon = '$(warning)';
|
||||
tooltip = `GNU Texinfo (${options.makeinfo}) ` +
|
||||
`is outdated (${version} < 6.8).`;
|
||||
} else {
|
||||
// Unrecognizable version. Assume it is okay.
|
||||
icon = '$(check)';
|
||||
const version = result?.[1] ?? '';
|
||||
let tooltip = '', icon: string;
|
||||
if (version) {
|
||||
icon = '$(check)';
|
||||
const verArr = version.split('.');
|
||||
if (version.length >= 2) {
|
||||
const verMajor = parseInt(verArr[0], 10);
|
||||
const verMinor = parseInt(verArr[1], 10);
|
||||
if (verMajor < 7 || verMinor < 1) {
|
||||
icon = '$(warning)';
|
||||
tooltip = `GNU Texinfo (${options.makeinfo}) ` +
|
||||
`is outdated (${version} < 7.1).`;
|
||||
}
|
||||
}
|
||||
this._canDisplayPreview = true;
|
||||
} else {
|
||||
|
|
|
@ -80,6 +80,10 @@ export default class Options
|
|||
return this._getArray('preview.variables');
|
||||
}
|
||||
|
||||
get customizationVariables() {
|
||||
return this._getArray('preview.customizationVariables');
|
||||
}
|
||||
|
||||
private readonly _configuration
|
||||
= vscode.workspace.getConfiguration('texinfo');
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* providers/completion_item.ts
|
||||
*
|
||||
* Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
||||
* Copyright (C) 2020,2021,2022 CismonX <admin@cismon.net>
|
||||
*
|
||||
* This file is part of vscode-texinfo.
|
||||
*
|
||||
|
@ -37,7 +37,7 @@ export default class CompletionItemProvider
|
|||
* GNU Free Documentation License, version 1.3.
|
||||
*
|
||||
* According to GFDL, this usage is considered "aggregation with
|
||||
* independent work", which means that GFDL applies to lines 50-1117 of
|
||||
* independent work", which means that GFDL applies to lines 50-1141 of
|
||||
* this file, while the remainder is under GPL like other source code files
|
||||
* of the project.
|
||||
*
|
||||
|
@ -49,24 +49,24 @@ export default class CompletionItemProvider
|
|||
return this._completionItems ??= [
|
||||
command('ampchar',
|
||||
'Insert an ampersand, "&"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('atchar',
|
||||
'Insert an at sign, "@"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('backslashchar',
|
||||
'Insert a blackslash, "\\"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command(
|
||||
'lbracechar',
|
||||
'Insert a left brace, "{"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('rbracechar',
|
||||
'Insert a right brace, "}"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('abbr',
|
||||
'Indicate a general abbreviation',
|
||||
|
@ -84,7 +84,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('alias',
|
||||
'Defines a new command to be just like an existing one',
|
||||
{ snippet: true },
|
||||
{ _snippet: true },
|
||||
),
|
||||
...lineCommandEnum('allowcodebreaks',
|
||||
'Control breaking at "-" and "_" in TeX',
|
||||
|
@ -116,7 +116,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('arrow',
|
||||
'Generate a right arrow glyph, "→"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('asis',
|
||||
'Print the table’s first column without highlighting',
|
||||
|
@ -134,7 +134,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('bullet',
|
||||
'Generate a large round dot, "•"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('bye',
|
||||
'Stop formatting',
|
||||
|
@ -182,7 +182,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('click',
|
||||
'Represent a single "click" in a GUI',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('clicksequence',
|
||||
'Represent a sequence of clicks in a GUI',
|
||||
|
@ -206,7 +206,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('comma',
|
||||
'Insert a comma character, ","',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('command',
|
||||
'Indicate a command name',
|
||||
|
@ -224,12 +224,15 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('copyright',
|
||||
'The copyright symbol, "©"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...lineCommand('defcodeindex',
|
||||
'Define a new index, print entries in an @code font',
|
||||
'index-name',
|
||||
),
|
||||
...blockCommand('defblock',
|
||||
'Start a block containing definitions',
|
||||
),
|
||||
...lineCommandX('defcv',
|
||||
'Format a description for a variable associated with a class',
|
||||
'category', 'class', 'name',
|
||||
|
@ -245,7 +248,11 @@ export default class CompletionItemProvider
|
|||
...lineCommandX('defivar',
|
||||
'Format a description for an instance variable ' +
|
||||
'in object-oriented programming',
|
||||
'class', 'instance-variable-name'
|
||||
'class', 'instance-variable-name',
|
||||
),
|
||||
...lineCommandX('defline',
|
||||
'Give the heading prototype line for a symbol being defined',
|
||||
'category', 'name', 'arguments',
|
||||
),
|
||||
...lineCommandX('defmac',
|
||||
'Format a description for a macro',
|
||||
|
@ -297,6 +304,11 @@ export default class CompletionItemProvider
|
|||
'object-oriented programming',
|
||||
'class', 'data-type', 'variable-name',
|
||||
),
|
||||
...lineCommandX('deftypeline',
|
||||
'Give the heading prototype line for a symbol being ' +
|
||||
'defined, with data types',
|
||||
'category', 'data-type', 'name', 'arguments',
|
||||
),
|
||||
...lineCommandX('deftypemethod',
|
||||
'Format a description for a typed method in ' +
|
||||
'object-oriented programming',
|
||||
|
@ -346,6 +358,9 @@ export default class CompletionItemProvider
|
|||
...blockCommand('display',
|
||||
'Begin a kind of example',
|
||||
),
|
||||
...blockCommand('displaymath',
|
||||
'Format a block of math in "display" format',
|
||||
),
|
||||
...braceCommand('dmn',
|
||||
'Format a unit of measure, as in 12pt',
|
||||
1, 'dimension',
|
||||
|
@ -371,7 +386,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('dots',
|
||||
'Generate an ellipsis, "…"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('email',
|
||||
'Indicate an electronic mail address',
|
||||
|
@ -387,7 +402,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('enddots',
|
||||
'Generate an end-of-sentence ellipsis, "..."',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...blockCommand('enumerate',
|
||||
'Begin a numbered list, using @item for each entry',
|
||||
|
@ -399,12 +414,12 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('equiv',
|
||||
'Insert a glyph indicating exact equivalence, "≡"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('error',
|
||||
'Indicate that the following text is an error message, ' +
|
||||
'"error→"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('errormsg',
|
||||
'Report message as an error to standard error, ' +
|
||||
|
@ -413,7 +428,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('euro',
|
||||
'Generate the Euro currency sign, "€"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...headingFootingCommand('evenfooting',
|
||||
'Generate page footers that are the same for ' +
|
||||
|
@ -442,7 +457,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('expansion',
|
||||
'Indicate the result of a macro expansion with a glyph, "→"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('file',
|
||||
'Highlight the name of a file',
|
||||
|
@ -494,14 +509,14 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('geq',
|
||||
'Generate a greater-than-or-equal sign, "≥"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...blockCommand('group',
|
||||
'Disallow page breaks within following text',
|
||||
),
|
||||
command('hashchar',
|
||||
'Insert a hash character, "#"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...lineCommand('heading',
|
||||
'Print an unnumbered section-like heading',
|
||||
|
@ -552,6 +567,9 @@ export default class CompletionItemProvider
|
|||
...blockCommand('ifinfo',
|
||||
'Begin text that will appear only in Info format',
|
||||
),
|
||||
...blockCommand('iflatex',
|
||||
'Begin text that will appear only in LaTeX format',
|
||||
),
|
||||
...blockCommand('ifplaintext',
|
||||
'Begin text that will appear only in plain text format',
|
||||
),
|
||||
|
@ -574,6 +592,9 @@ export default class CompletionItemProvider
|
|||
...blockCommand('ifnotinfo',
|
||||
'Begin text to be ignored in Info format',
|
||||
),
|
||||
...blockCommand('ifnotlatex',
|
||||
'Begin text to be ignored in LaTeX format',
|
||||
),
|
||||
...blockCommand('ifnotplaintext',
|
||||
'Begin text to be ignored in plain text format',
|
||||
),
|
||||
|
@ -657,13 +678,16 @@ export default class CompletionItemProvider
|
|||
'Add entry to the index of keys',
|
||||
'entry',
|
||||
),
|
||||
...blockCommand('latex',
|
||||
'Enter LaTeX completely',
|
||||
),
|
||||
command('LaTeX',
|
||||
'Generate the LaTeX logo',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('leq',
|
||||
'Generate a less-than-or-equal sign, "≤"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...blockCommand('lisp',
|
||||
'Begin an example of Lisp code',
|
||||
|
@ -692,7 +716,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('minus',
|
||||
'Generate a minus sign, "-"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...blockCommand('multitable',
|
||||
'Begin a multi-column table',
|
||||
|
@ -736,7 +760,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('pagesizes',
|
||||
'Change page dimensions',
|
||||
{ snippet: true },
|
||||
{ _snippet: true },
|
||||
),
|
||||
...lineCommand('paragraphindent',
|
||||
'Indent paragraphs by spaces',
|
||||
|
@ -752,15 +776,15 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('point',
|
||||
'Indicate the position of point in a buffer with "∗"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('pounds',
|
||||
'Generate the pounds sterling currency sign, "£"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('print',
|
||||
'Indicate printed output to the reader with "-|"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...lineCommand('printindex',
|
||||
'Generate the alphabetized index for index name',
|
||||
|
@ -777,19 +801,19 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('quotedblleft',
|
||||
'Produce quotation mark "“"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('quotedblright',
|
||||
'Produce quotation mark "”"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('quoteleft',
|
||||
'Produce quotation mark "‘"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('quoteright',
|
||||
'Produce quotation mark "’"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('r',
|
||||
'Set text in the regular roman font',
|
||||
|
@ -810,11 +834,11 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('registeredsymbol',
|
||||
'Generate the legal symbol, "®"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('result',
|
||||
'Indicate the result of an expression with "⇒"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('samp',
|
||||
'Indicate a literal example of a sequence of characters',
|
||||
|
@ -952,14 +976,14 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('TeX',
|
||||
'Generate the TeX logo',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...blockCommand('tex',
|
||||
'Enter TeX completely',
|
||||
),
|
||||
command('textdegree',
|
||||
'Generate the degree symbol, "◦"',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
command('thischapter',
|
||||
'Insert the number and name of the current chapter',
|
||||
|
@ -982,7 +1006,7 @@ export default class CompletionItemProvider
|
|||
command('tie',
|
||||
'Generate a normal interword space at which a line break ' +
|
||||
'is not allowed',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...braceCommand('tieaccent',
|
||||
'Generate a tie-after accent over the two characters',
|
||||
|
@ -1005,7 +1029,7 @@ export default class CompletionItemProvider
|
|||
),
|
||||
command('today',
|
||||
'Insert the current date',
|
||||
{ hasEmptyBrace: true },
|
||||
{ _hasEmptyBrace: true },
|
||||
),
|
||||
...lineCommand('top',
|
||||
'Mark the topmost @node in the file',
|
||||
|
@ -1156,7 +1180,9 @@ export default class CompletionItemProvider
|
|||
this._oldOptions = newOptions;
|
||||
this._completionItems = undefined;
|
||||
}
|
||||
if (position.character === 1) return this._getCompletionItems();
|
||||
if (position.character === 1) {
|
||||
return this._getCompletionItems();
|
||||
}
|
||||
// Check whether the '@' character is escaped.
|
||||
const secondCharBeforeWord = new vscode.Range(
|
||||
position.translate(0, -2),
|
||||
|
@ -1187,20 +1213,20 @@ function command(name: string, detail: string, extraArgs?: {
|
|||
/**
|
||||
* Whether this command has a snippet.
|
||||
*/
|
||||
snippet?: boolean,
|
||||
_snippet?: boolean,
|
||||
/**
|
||||
* Whether this command takes no arguments and braces are required.
|
||||
*/
|
||||
hasEmptyBrace?: boolean,
|
||||
_hasEmptyBrace?: boolean,
|
||||
}): CompletionItem {
|
||||
return {
|
||||
label: '@' + name,
|
||||
kind: vscode.CompletionItemKind.Function,
|
||||
detail: detail,
|
||||
sortText: name + (extraArgs?.snippet ? '1' : ''),
|
||||
sortText: name + (extraArgs?._snippet ? '1' : ''),
|
||||
filterText: name,
|
||||
insertText: name + (extraArgs?.hasEmptyBrace ? '{}' : ''),
|
||||
snippet: extraArgs?.snippet,
|
||||
insertText: name + (extraArgs?._hasEmptyBrace ? '{}' : ''),
|
||||
snippet: extraArgs?._snippet,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1243,7 @@ function blockCommand(
|
|||
...args: string[]
|
||||
) {
|
||||
return [blockSnippet(name, detail, ...args),
|
||||
command(name, detail, { snippet: true })];
|
||||
command(name, detail, { _snippet: true })];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1234,7 +1260,7 @@ function braceCommand(
|
|||
...args: string[]
|
||||
) {
|
||||
return [braceCommandSnippet(name, detail, numArgsRequired, ...args),
|
||||
command(name, detail, { snippet: true })];
|
||||
command(name, detail, { _snippet: true })];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1246,7 +1272,7 @@ function braceCommand(
|
|||
*/
|
||||
function lineCommand(name: string, detail: string, ...args: string[]) {
|
||||
return [lineCommandSnippet(name, detail, ...args),
|
||||
command(name, detail, { snippet: true })];
|
||||
command(name, detail, { _snippet: true })];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1274,7 +1300,7 @@ function lineCommandEnum(name: string, detail: string, ...items: string[]) {
|
|||
`@${name} ${items.join('/')}`,
|
||||
`${name} \${1|${items.join(',')}|}`,
|
||||
),
|
||||
command(name, detail, { snippet: true }),
|
||||
command(name, detail, { _snippet: true }),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1314,7 @@ function headingFootingCommand(name: string, detail: string) {
|
|||
return [
|
||||
snippet(name, name, detail, 0, `@${name} left @| center @| right`,
|
||||
name + ' ${1:left} @| ${2:center} @| ${3:right}'),
|
||||
command(name, detail, { snippet: true }),
|
||||
command(name, detail, { _snippet: true }),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1349,7 +1375,7 @@ function blockSnippet(name: string, detail: string, ...args: string[]) {
|
|||
.join(' ');
|
||||
return snippet(name, name, detail, 0,
|
||||
`@${name} ${args.join(' ')}\n\n@end ${name}`,
|
||||
name + args.length ? ' ' : '' + argsIndexed +
|
||||
name + (args.length ? ' ' : '') + argsIndexed +
|
||||
`\n$${args.length + 1}\n@end ${name}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import Logger from '../logger';
|
||||
import Options from '../options';
|
||||
import { exec } from './misc';
|
||||
import { exec, normalizePath } from './misc';
|
||||
import { Operator } from './types';
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,8 @@ import { Operator } from './types';
|
|||
export default class Converter
|
||||
{
|
||||
async toHTML(imgTransformer: Operator<vscode.Uri>, insertScript?: string) {
|
||||
const pathUri = vscode.Uri.file(path.dirname(this._path));
|
||||
const newPath = imgTransformer(pathUri).toString() + '/';
|
||||
const pathUri = vscode.Uri.file(path.dirname(this._pathName) + '/');
|
||||
const newPath = normalizePath(imgTransformer(pathUri).toString());
|
||||
const options = ['-o-', '--no-split', '--html',
|
||||
`--error-limit=${this._options.errorLimit}`,
|
||||
`--init-file=${this._initFile}`,
|
||||
|
@ -48,37 +48,27 @@ export default class Converter
|
|||
}
|
||||
this._addIncludePaths(this._options.includePaths, options);
|
||||
this._defineVariables(this._options.variables, options);
|
||||
this._setCustomizationVariables(
|
||||
this._options.customizationVariables, options);
|
||||
this._includeCustomCSS(this._options.customCSS, options);
|
||||
return await exec(
|
||||
this._options.makeinfo,
|
||||
options.concat(this._path),
|
||||
options.concat(normalizePath(this._pathName)),
|
||||
this._options.maxSize,
|
||||
);
|
||||
}
|
||||
|
||||
constructor(
|
||||
path: string,
|
||||
private readonly _pathName: string,
|
||||
private readonly _initFile: string,
|
||||
private readonly _options: Options,
|
||||
private readonly _logger: Logger,
|
||||
) {
|
||||
if (process.platform === 'win32') {
|
||||
// TODO:
|
||||
// On Windows, when passing the path of input file to makeinfo,
|
||||
// using backslashes in path name breaks some other command line
|
||||
// options (notably, -I).
|
||||
// Not sure if this is a bug of makeinfo, or perl, or neither.
|
||||
// We should look into this issue sometime later.
|
||||
this._path = path.replace(/\\/g, '/');
|
||||
} else {
|
||||
this._path = path;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly _path: string;
|
||||
) {}
|
||||
|
||||
private _addIncludePaths(paths: readonly string[], options: string[]) {
|
||||
if (paths.length === 0) return;
|
||||
if (paths.length === 0) {
|
||||
return;
|
||||
}
|
||||
const separator = process.platform === 'win32' ? ';' : ':';
|
||||
options.push('-I', paths.join(separator));
|
||||
}
|
||||
|
@ -87,13 +77,22 @@ export default class Converter
|
|||
variables.forEach(varName => options.push('-D', varName));
|
||||
}
|
||||
|
||||
private _setCustomizationVariables(
|
||||
variables: readonly string[],
|
||||
options: string[],
|
||||
) {
|
||||
variables.forEach(varName => options.push('-c', varName));
|
||||
}
|
||||
|
||||
private _includeCustomCSS(cssFileURI: string, options: string[]) {
|
||||
if (!cssFileURI) return;
|
||||
if (!cssFileURI) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const uri = vscode.Uri.parse(cssFileURI, true);
|
||||
switch (uri.scheme) {
|
||||
case 'file':
|
||||
options.push(`--css-include=${uri.path}`);
|
||||
options.push(`--css-include=${normalizePath(uri.fsPath)}`);
|
||||
break;
|
||||
case 'http':
|
||||
case 'https':
|
||||
|
|
|
@ -20,9 +20,20 @@
|
|||
*/
|
||||
|
||||
import * as child_process from 'child_process';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExecResult } from './types';
|
||||
|
||||
/**
|
||||
* Escape string to match verbatim in regular expression.
|
||||
*
|
||||
* @param str The string to be escaped.
|
||||
* @returns The escaped string.
|
||||
*/
|
||||
export function escapeStringForRegExp(str: string) {
|
||||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute command and fetch output.
|
||||
*
|
||||
|
@ -35,7 +46,7 @@ export function exec(path: string, args: string[], maxBuffer: number) {
|
|||
return new Promise<ExecResult>(
|
||||
resolve => child_process.execFile(path, args,
|
||||
{
|
||||
env: { ...process.env, LC_MESSAGES: 'en_US' },
|
||||
env: { ...process.env, LC_MESSAGES: 'en_US.UTF-8' },
|
||||
maxBuffer: maxBuffer,
|
||||
},
|
||||
(error, stdout, stderr) => resolve(error
|
||||
|
@ -94,8 +105,8 @@ export function isAlnum(charCode: number) {
|
|||
/**
|
||||
* Get corresponding HTML cross-reference name by node name.
|
||||
*
|
||||
* See section *HTML Cross-reference Node Name Expansion* in
|
||||
* the Texinfo manual.
|
||||
* See section *HTML Cross-reference Node Name Expansion* in the
|
||||
* GNU Texinfo manual.
|
||||
*
|
||||
* TODO: Node name is not displayed verbatim, leading to wrong HTML xref when
|
||||
* containing commands. Fix this when migrating to LSP.
|
||||
|
@ -116,3 +127,18 @@ export function getNodeHtmlRef(nodeName: string) {
|
|||
? result
|
||||
: 'g_t_00' + firstCharCode.toString(16) + result.substring(1);
|
||||
}
|
||||
|
||||
export function normalizePath(pathName: string) {
|
||||
pathName = path.normalize(pathName);
|
||||
if (process.platform === 'win32') {
|
||||
// On Windows, when passing the path of input file to makeinfo,
|
||||
// using backslashes in path name breaks some other command line
|
||||
// options (notably, -I).
|
||||
// Not sure if this is a bug of makeinfo, or perl, or neither.
|
||||
//
|
||||
// TODO: We should look into this issue sometime later.
|
||||
return pathName.replace(/\\/g, '/');
|
||||
} else {
|
||||
return pathName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"target": "ES2021",
|
||||
"outDir": "out",
|
||||
"esModuleInterop": true,
|
||||
"strictNullChecks": true,
|
||||
|
|
Loading…
Reference in New Issue