Skip to content

Commit

Permalink
Merge branch 'docker_options_support'
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
  • Loading branch information
ChrisChinchilla committed Apr 11, 2024
2 parents af01cd2 + aac7aaf commit 89ba1d6
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 85 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Choose from the list what document type you want to render and press `enter` (yo

## Releases

* December 1st, 2023
* Added pandoc.docker.options and pandoc.docker.image configurations
* Existing pandoc.useDocker configuration will be migrated to new configuration
* June 21st, 2023
* Package updates
* Read me updates
Expand Down Expand Up @@ -65,10 +68,16 @@ example:
"pandoc.htmlOptString": "",

// path to the pandoc executable. By default gets from PATH variable
"pandoc.executable": ""
"pandoc.executable": "",

// enable running pandoc in a docker container
"pandoc.useDocker": "true"
"pandoc.docker.enabled": "true",

// specify the docker options when "pandoc.docker.enabled" is "true"
"pandoc.docker.options": "",

// specify the docker image when "pandoc.docker.enabled" is "true"
"pandoc.docker.image": ""
```

You can set options for each output format.
Expand Down Expand Up @@ -98,3 +107,23 @@ For example, for Japanese documents.
* `-t html5`: HTML5 output format

For more information please refer to the [Pandoc User's Guide](http://pandoc.org/README.html).

## Docker Options

When running on linux systems (and possibly others) when using the docker, there may be file permission issues with the docker image. This can appear as an error such as the following:

```
stderr: pandoc: file.html: openFile: permission denied (Permission denied)
exec error: Error: Command failed: docker run --rm -v "/home/user/path:/data" pandoc/latex:latest "file.md" -o "file.html"
pandoc: file.html: openFile: permission denied (Permission denied)
```

This may occur due to the file/directory permissions being incorrect. To allow this to function, you can specify the docker options to set the uid/gid using the following:

```json
"pandoc.docker.options": "--user $(id -u):$(id -g)"
```

If needed, you can also change the default pandoc docker image using the `pandoc.docker.image` configuration setting.

44 changes: 34 additions & 10 deletions dist/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = require("path");
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
Expand All @@ -50,14 +50,14 @@ module.exports = require("path");
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
Expand All @@ -70,7 +70,7 @@ module.exports = require("path");
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
Expand All @@ -82,12 +82,12 @@ module.exports = require("path");
/******/ }
/******/ };
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
Expand All @@ -98,7 +98,7 @@ module.exports = require("path");
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
Expand Down Expand Up @@ -201,9 +201,33 @@ function activate(context) {
setStatusBarText('Generating', qpSelection.label);
var pandocOptions = getPandocOptions(qpSelection.label);
var pandocExecutablePath = getPandocExecutablePath();
var useDocker = vscode__WEBPACK_IMPORTED_MODULE_0__.workspace.getConfiguration('pandoc').get('useDocker');

var pandocConfigurations = vscode__WEBPACK_IMPORTED_MODULE_0__.workspace.getConfiguration('pandoc')
var deprecatedUseDocker = pandocConfigurations.inspect('useDocker')
if (deprecatedUseDocker['globalValue'] !== undefined) {
pandocOutputChannel.append('migrating global configuration "pandoc.useDocker" -> "pandoc.docker.enabled"\n');
vscode__WEBPACK_IMPORTED_MODULE_0__.window.showWarningMessage('pandoc: found deprecated value in global configuration. Migrating configuration "pandoc.useDocker" -> "pandoc.docker.enabled".')
pandocConfigurations.update('docker.enabled', deprecatedUseDocker['globalValue'], vscode__WEBPACK_IMPORTED_MODULE_0__.ConfigurationTarget.Global);
pandocConfigurations.update('useDocker', undefined, vscode__WEBPACK_IMPORTED_MODULE_0__.ConfigurationTarget.Global);
}
if (deprecatedUseDocker['workspaceValue'] !== undefined) {
pandocOutputChannel.append('migrating workspace configuration "pandoc.useDocker" -> "pandoc.docker.enabled"\n');
vscode__WEBPACK_IMPORTED_MODULE_0__.window.showWarningMessage('pandoc: found deprecated value in workspace configuration. Migrating configuration "pandoc.useDocker" -> "pandoc.docker.enabled".')
pandocConfigurations.update('docker.enabled', deprecatedUseDocker['workspaceValue'], vscode__WEBPACK_IMPORTED_MODULE_0__.ConfigurationTarget.Workspace);
pandocConfigurations.update('useDocker', undefined, vscode__WEBPACK_IMPORTED_MODULE_0__.ConfigurationTarget.Workspace);
}
if (deprecatedUseDocker['workspaceFolderValue'] !== undefined) {
pandocOutputChannel.append('migrating folder configuration "pandoc.useDocker" -> "pandoc.docker.enabled"\n');
vscode__WEBPACK_IMPORTED_MODULE_0__.window.showWarningMessage('pandoc: found deprecated value in folder configuration. Migrating configuration "pandoc.useDocker" -> "pandoc.docker.enabled".')
pandocConfigurations.update('docker.enabled', deprecatedUseDocker['workspaceFolderValue'], vscode__WEBPACK_IMPORTED_MODULE_0__.ConfigurationTarget.WorkspaceFolder);
pandocConfigurations.update('useDocker', undefined, vscode__WEBPACK_IMPORTED_MODULE_0__.ConfigurationTarget.WorkspaceFolder);
}
var useDocker = pandocConfigurations.get('docker.enabled');
var dockerOptions = pandocConfigurations.get('docker.options');
var dockerImage = pandocConfigurations.get('docker.image');

var targetExec = useDocker
? `docker run --rm -v "${filePath}:/data" pandoc/latex:latest "${fileName}" -o "${fileNameOnly}.${qpSelection.label}" ${pandocOptions}`
? `docker run --rm -v "${filePath}:/data" ${dockerOptions} ${dockerImage} "${fileName}" -o "${fileNameOnly}.${qpSelection.label}" ${pandocOptions}`
: `"${pandocExecutablePath}" ${inFile} -o ${outFile} ${pandocOptions}`;
var child = (0,child_process__WEBPACK_IMPORTED_MODULE_1__.exec)(targetExec, { cwd: filePath }, function (error, stdout, stderr) {
if (stdout !== null) {
Expand Down
Loading

0 comments on commit 89ba1d6

Please sign in to comment.