Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - custom knit: handle xaringan::inf_mr #875

Draft
wants to merge 62 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f1eef75
Update r.rmarkdown.codeLensCommands
ElianHugh Jul 15, 2021
9c32315
Merge branch 'master' of https://github.com/ElianHugh/vscode-R
ElianHugh Jul 27, 2021
ed2d16e
Initial handling of xarningan::inf_mr
ElianHugh Nov 19, 2021
814481c
Kill the child process!
ElianHugh Nov 22, 2021
8a7a043
Allow localhost
ElianHugh Dec 2, 2021
7f1c920
Check conflict extension (#733)
renkun-ken Jul 28, 2021
294c473
Fix date filter in data viewer (#736)
renkun-ken Jul 30, 2021
e76bea2
Rename liveshare folder to liveShare (#738)
renkun-ken Aug 2, 2021
fbfd881
Viewer fix: invalid html_widget resource paths (#739)
ElianHugh Aug 4, 2021
4290447
Accessing VS Code settings in R (#743)
ElianHugh Aug 11, 2021
829149b
Fix README
renkun-ken Aug 12, 2021
6978d5b
Use .DollarNames with default pattern (#750)
renkun-ken Aug 13, 2021
b5a38fe
Fix issues with c() in function args (#751)
ElianHugh Aug 15, 2021
df4606c
Handle error in capture_str (#756)
renkun-ken Aug 17, 2021
6f001c1
Add icons to webviews (#759)
ElianHugh Aug 19, 2021
31cd9df
release 2.2.0
renkun-ken Aug 21, 2021
d830666
Enable rstudioapi by default (#769)
ElianHugh Sep 3, 2021
8da3923
Use unsafe-inline for script-src (#771)
renkun-ken Sep 3, 2021
a374935
R Markdown Enhancements (Knit Manager) (#765)
ElianHugh Sep 4, 2021
df8e147
(Refactoring) Simplify RMD child process disposal (#773)
ElianHugh Sep 6, 2021
3e0619c
Add object length limit (#778)
renkun-ken Sep 9, 2021
911249f
Write NA as string (#780)
renkun-ken Sep 9, 2021
81cf926
Use R files for background process (#783)
ElianHugh Sep 10, 2021
b5cdbaf
Fix RMD requireNamespace (#784)
ElianHugh Sep 10, 2021
6332328
Respect preview output format (#785)
ElianHugh Sep 11, 2021
0777aa3
Bump @types/vscode from 1.57.0 to 1.60.0 (#786)
ElianHugh Sep 13, 2021
baeb5fd
Extend providers to rmd (#787)
renkun-ken Sep 14, 2021
6e53a7b
Bump nth-check from 2.0.0 to 2.0.1 (#795)
dependabot[bot] Sep 22, 2021
f2b8d04
Update vscode and ag-grid version
renkun-ken Sep 23, 2021
f6f713a
Update dependencies
renkun-ken Sep 23, 2021
edc2e1a
Fix hljs usage
renkun-ken Sep 23, 2021
e2c48ed
Update highlight.js version
renkun-ken Sep 23, 2021
48fe454
release 2.3.0
renkun-ken Sep 23, 2021
ce40e74
Update vsc.R (#803)
benz0li Sep 29, 2021
d6d7a6b
Reenable 'unsafe-eval' in script-src CSP (#805)
juba Sep 29, 2021
e4e7b44
Use r.session.viewers.viewColumn.helpPanel (#804)
renkun-ken Sep 30, 2021
99af536
Use cwd in knit process (#807)
ElianHugh Oct 7, 2021
31b7673
Bump version
renkun-ken Oct 7, 2021
8c8c7d5
release 2.3.1
renkun-ken Oct 7, 2021
9c149a9
Httpgd plot viewer respects r.session.viewers.viewColumn.plot (#816)
renkun-ken Oct 11, 2021
98f8dca
Completely replace View (#818)
renkun-ken Oct 11, 2021
b7c3058
Change help cache default (#819)
ManuelHentschel Oct 11, 2021
1b7a569
browser handles `file://` (#817)
renkun-ken Oct 11, 2021
29801b7
Add `r.session.levelOfObjectDetail=Normal` for `max.level=1` (#815)
renkun-ken Oct 12, 2021
155bb15
Update address
renkun-ken Oct 13, 2021
cbeda76
Check workspace folder with both original and real path (#827)
renkun-ken Oct 22, 2021
9092f8f
release 2.3.2
renkun-ken Oct 22, 2021
1e400e0
Add R info to status bar item text and tooltip (#836)
renkun-ken Oct 26, 2021
b360d88
get knit command from settings (#841)
xoolive Oct 29, 2021
12f3b20
Fix package installation (#846)
ManuelHentschel Oct 29, 2021
2af23c4
Add support for indented Roxygen (#847)
ManuelHentschel Oct 29, 2021
e469a97
Syntax highlighting for indented roxygen (#850)
ManuelHentschel Oct 31, 2021
9947208
Use new terminal API (#851)
ManuelHentschel Oct 31, 2021
1706790
Add backtick to list of quote characters for syntax highlighting. (#859)
jan-imbi Nov 7, 2021
130f95c
Fix detecting yaml frontmatter (#856)
renkun-ken Nov 8, 2021
c15a9ef
Auto refresh help (#863)
ManuelHentschel Nov 11, 2021
0845351
Handle plot on attach (#852)
renkun-ken Nov 13, 2021
49806ec
Initial handling of xarningan::inf_mr
ElianHugh Nov 19, 2021
60da38a
Kill the child process!
ElianHugh Nov 22, 2021
4ebe16a
Allow localhost
ElianHugh Dec 2, 2021
da0b18b
Force file to be self contained
ElianHugh May 12, 2022
a5b5e45
Merge branch 'rmd-fixes' of https://github.com/ElianHugh/vscode-R int…
ElianHugh May 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions R/rmarkdown/preview.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ knitr::opts_knit[["set"]](root.dir = knit_dir)
cat(
lim,
rmarkdown::render(
file_path,
input = file_path,
output_format = set_html,
output_file = output_file_loc,
intermediates_dir = tmp_dir
output_dir = tmp_dir,
intermediates_dir = tmp_dir,
output_options = list(self_contained = TRUE)
),
lim,
sep = ""
Expand Down
15 changes: 14 additions & 1 deletion src/rmarkdown/knit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import yaml = require('js-yaml');
import { RMarkdownManager, KnitWorkingDirectory, DisposableProcess } from './manager';
import { runTextInTerm } from '../rTerminal';
import { extensionContext, rmdPreviewManager } from '../extension';
import { showBrowser } from '../session';

export let knitDir: KnitWorkingDirectory = util.config().get<KnitWorkingDirectory>('rmarkdown.knit.defaults.knitWorkingDirectory') ?? undefined;

Expand Down Expand Up @@ -35,14 +36,16 @@ export class RMarkdownKnitManager extends RMarkdownManager {

const lim = '---vsc---';
const re = new RegExp(`.*${lim}(.*)${lim}.*`, 'gms');
const serveReg = /(http:\/\/(localhost)?[0-9.:]*\/.*\.html)/g;
const scriptValues = {
'VSCR_KNIT_DIR': knitWorkingDirText,
'VSCR_LIM': lim,
'VSCR_KNIT_COMMAND': knitCommand
};

const callback = (dat: string) => {
const callback = (dat: string, process: DisposableProcess) => {
const outputUrl = re.exec(dat)?.[0]?.replace(re, '$1');
const serveUrl = serveReg.exec(dat)?.[0]?.replace(serveReg, '$1');
if (outputUrl) {
if (openOutfile) {
const outFile = vscode.Uri.file(outputUrl);
Expand All @@ -53,6 +56,16 @@ export class RMarkdownKnitManager extends RMarkdownManager {
}
}
return true;
} else if (serveUrl) {
const browser = showBrowser(serveUrl, docName, 'Beside');
void browser.then((value) => {
if (value) {
value.onDidDispose(() => {
process.kill('SIGTERM');
});
}
});
return true;
} else {
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions src/rmarkdown/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ export abstract class RMarkdownManager {
if (printOutput) {
this.rMarkdownOutput.appendLine(dat);
}
// for some reason, some knitting formats have the output
// of the file url in the stderr stream
if (args.callback(dat, childProcess)) {
resolve(childProcess);
}
});

childProcess.on('exit', (code, signal) => {
Expand Down
3 changes: 2 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async function updateGlobalenv() {
}
}

export async function showBrowser(url: string, title: string, viewer: string | boolean): Promise<void> {
export async function showBrowser(url: string, title: string, viewer: string | boolean): Promise<void|WebviewPanel> {
console.info(`[showBrowser] uri: ${url}, viewer: ${viewer.toString()}`);
const uri = Uri.parse(url);
if (viewer === false) {
Expand Down Expand Up @@ -240,6 +240,7 @@ export async function showBrowser(url: string, title: string, viewer: string | b
});
panel.iconPath = new UriIcon('globe');
panel.webview.html = getBrowserHtml(externalUri);
return (panel);
}
console.info('[showBrowser] Done');
}
Expand Down