Skip to content

Commit 1a96869

Browse files
committed
Implement utput.text.addFormat option.
1 parent 61ac34d commit 1a96869

File tree

3 files changed

+38
-42
lines changed

3 files changed

+38
-42
lines changed

README.md

+16-32
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,24 @@ You must install Pandoc executable. If you can run Pandoc as `pandoc` in command
2121
Following options are implemented preliminary.
2222

2323
- `Pandoc.path`
24+
- You can specify path to Pandoc executable. Default is "pandoc".
2425
- `Pandoc.args`
26+
- You can add arguments for Pandoc. See [Options](https://pandoc.org/MANUAL.html#options) section in the manual of Pandoc for detail.
2527
- `Pandoc.extension`
28+
- You can add extensions for Pandoc. See [Extensions](https://pandoc.org/MANUAL.html#extensions) section in the manual of Pandoc for detail.
2629
- `Pandoc.workdir`
30+
- Running directory of pandoc. Default is current directory. Selected text range or code block is written to temp file when you exec pandoc. This temp file location and its filename cannot be changed.
2731
- `input.from`
32+
- You can set input file format (This value is used with `--from` option.). To know available file format, see [General options](https://pandoc.org/MANUAL.html#general-options) section in the manual of Pandoc for detail.
2833
- `output.to`
34+
- You can set output file format (This value is used with `--to` option.). To know available file format, see [General options](https://pandoc.org/MANUAL.html#general-options) section in the manual of Pandoc for detail.
2935
- `output.text.Add`
36+
- You can add output result at the next line of mouse cursor or after code block.
37+
- `output.text.addFormat`
38+
- You can add output file format which specifed by `output.to` to the output result.
3039
- `output.pane`
40+
- You can select to output to OUTPUT pane or not.
3141

32-
### Pandoc.path
33-
34-
You can specify path to Pandoc executable. Default is "pandoc".
35-
36-
### Pandoc.args
37-
38-
You can add arguments for Pandoc. See [Options](https://pandoc.org/MANUAL.html#options) section in the manual of Pandoc for detail.
39-
40-
### Pandoc.extension
41-
42-
You can add extensions for Pandoc. See [Extensions](https://pandoc.org/MANUAL.html#extensions) section in the manual of Pandoc for detail.
43-
44-
### Pandoc.workdir
45-
46-
Running directory of pandoc. Default is current directory. Selected text range or code block is written to temp file when you exec pandoc. This temp file location and its filename cannot be changed.
47-
48-
### input.from
49-
50-
You can set input file format (This value is used with `--from` option.). To know available file format, see [General options](https://pandoc.org/MANUAL.html#general-options) section in the manual of Pandoc for detail.
51-
52-
53-
### `output.to`
54-
55-
You can set output file format (This value is used with `--to` option.). To know available file format, see [General options](https://pandoc.org/MANUAL.html#general-options) section in the manual of Pandoc for detail.
56-
57-
### output.text.Add
58-
59-
You can add output result at the next line of mouse cursor or after code block.
60-
61-
### output.pane
62-
63-
You can select to output to OUTPUT pane or not.
6442

6543
## Known Issues
6644

@@ -74,6 +52,12 @@ If you have any issues, please use issue of this repository.
7452

7553
## Release Notes
7654

55+
### 0.0.3
56+
57+
* Delete Replace function (Not implemented yet)
58+
* Implement `output.text.addFormat` to add output format.
59+
* Update README.
60+
7761
### 0.0.2
7862

7963
Add screen shot to use this extension (Run Pandoc Selection Range).

package.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,10 @@
8686
"default": false,
8787
"description": "Pandoc's output will be added after cursor."
8888
},
89-
"Pandocplay.output.text.Replace": {
90-
"type": "boolean",
91-
"default": false,
92-
"markdownDescription": "TODO: Only for Selection. **If true, selections will be deleted.**"
93-
},
9489
"Pandocplay.output.text.addFormat": {
9590
"type": "boolean",
9691
"default": false,
97-
"markdownDescription": "TODO: Add format name at code block"
92+
"markdownDescription": "Add specified format name to output code block"
9893
},
9994
"Pandocplay.output.file.enable": {
10095
"type": "boolean",

src/pandocplay/main.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,17 @@ export class Pandocplay {
8383
const pandoc_output = this.runCode(code, cwd, from, to, ext, args, path, pane_enable);
8484
//vscode.window.showInformationMessage(cwd);
8585

86-
// TODO: add or replace texts
86+
// Replace can be done by delete after adding outputs. So, It should NOT be implemented.
8787
const output_add = this.getOutputAdd(conf);
88+
89+
const output_add_format = this.getOutputAddFormat(conf);
90+
8891
if(output_add){
89-
this.appendResult(editor, line, pandoc_output)
92+
let local_to = "";
93+
if (output_add_format){
94+
local_to = to;
95+
}
96+
this.appendResult(editor, line, pandoc_output, local_to)
9097
}
9198

9299
// TBD
@@ -104,7 +111,8 @@ export class Pandocplay {
104111
private appendResult = (
105112
editor: vscode.TextEditor,
106113
targetLine: number,
107-
text: string
114+
text: string,
115+
to: string
108116
) => {
109117

110118
let eol: string;
@@ -114,7 +122,7 @@ export class Pandocplay {
114122
default:
115123
eol = "\n";
116124
}
117-
const outputText = "```" + eol + text + eol + "```" + eol;
125+
const outputText = "```" + to + eol + text + eol + "```" + eol;
118126
editor.edit(edit => {
119127
edit.insert(new vscode.Position(targetLine, 0), outputText);
120128
});
@@ -222,6 +230,15 @@ private getOutputAdd = (conf: vscode.WorkspaceConfiguration): boolean => {
222230
}
223231
};
224232

233+
private getOutputAddFormat = (conf: vscode.WorkspaceConfiguration): boolean => {
234+
const output_addFormat = conf.get("output.text.addFormat");
235+
if(output_addFormat){
236+
return true;
237+
} else {
238+
return false;
239+
}
240+
};
241+
225242
private getOutputPane = (conf: vscode.WorkspaceConfiguration, to: string): boolean => {
226243
//TODO: check with --to file type?
227244
const bin_list = ["docx", "pdf", "odt", "opendocument", "epub", "epub2", "epub3"];

0 commit comments

Comments
 (0)