本文整理匯總了TypeScript中smc-util/misc2.path_split函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript path_split函數的具體用法?TypeScript path_split怎麽用?TypeScript path_split使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了path_split函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: write_content
function write_content(w, opts: PrintOptions): void {
if (!opts.path) throw Error("write_content -- path must be defined");
const split = path_split(opts.path);
let html: string;
if (opts.html == null) {
const props = {
value: opts.value,
project_id: opts.project_id,
file_path: split.head
};
const C = React.createElement(
Redux,
{ redux } as any,
React.createElement(HTML, props)
);
html = ReactDOMServer.renderToStaticMarkup(C);
} else {
html = opts.html;
}
const title: string = path_split(opts.path).tail;
html = html_with_deps(html, title);
w.document.write(html);
w.document.close();
}
示例2: latexmk
export async function latexmk(
project_id: string,
path: string,
build_command: string | string[],
time: number | undefined, // (ms since epoch) used to aggregate multiple calls into one across all users.
status: Function
): Promise<ExecOutput> {
const x = path_split(path);
let command: string;
let args: string[] | undefined;
if (typeof build_command === "string") {
command = build_command;
args = undefined;
status(command);
} else {
command = build_command[0];
args = build_command.slice(1);
status([command].concat(args).join(" "));
}
return await exec({
bash: true, // we use ulimit so that the timeout on the backend is *enforced* via ulimit!!
allow_post: false, // definitely could take a long time to fully run latex
timeout: 4 * 60, // 4 minutes, on par with Overleaf
command: command,
args: args,
project_id: project_id,
path: x.head,
err_on_exit: false,
aggregate: time
});
}
示例3: parse_path
export function parse_path(
path: string
): { directory: string; base: string; filename: string } {
let x = path_split(path);
let y = separate_file_extension(x.tail);
return { directory: x.head, base: y.name, filename: x.tail };
}
示例4: print_code
export function print_code(opts: Options) {
const w = popup("");
let options = fromJS(opts.options);
options = options.delete("lineNumbers"); // doesn't work yet
// We add a trailing whitespace, since some printers grey the last line (e.g., chrome, but not firefox)
const value = opts.value + "\n";
const props = {
value,
options,
style: { background: "white", padding: "7%", width: "auto" },
no_border: true
};
const s: string = renderToStaticMarkup(
React.createElement(CodeMirrorStatic, props)
);
const t: string = `\
<html lang="en">
<head>
<title>${path_split(opts.path).tail}</title>
<meta name="google" content="notranslate"/>
<style>${CODEMIRROR_CSS}</style>
</head>
<body style='font-size:${opts.font_size}'>
${s}
</body>
</html>\
`;
w.document.write(t);
w.document.close();
print_window(w);
}
示例5: aux_file
export function aux_file(path: string, ext: string): string {
let s = path_split(path);
s.tail += "." + ext;
if (s.head) {
return s.head + "/." + s.tail;
} else {
return "." + s.tail;
}
}
示例6: tex_to_pdf
export async function tex_to_pdf(opts: {
pdf_path: string;
project_id: string;
tex_path: string; // source tex file with given line/column
line: number; // 1-based line number
column: number; // 1-based column
knitr: boolean;
}): Promise<SyncTex> {
let { head, tail } = path_split(opts.tex_path);
if (opts.knitr) {
tail = change_filename_extension(tail, "Rnw");
}
let output = await exec_synctex(opts.project_id, head, [
"view",
"-i",
`${opts.line}:${opts.column}:${tail}`,
"-o",
path_split(opts.pdf_path).tail
]);
return parse_synctex_output(output.stdout);
}
示例7: pdf_to_tex
export async function pdf_to_tex(opts: {
pdf_path: string;
project_id: string;
page: number; // 1-based page number
x: number; // x-coordinate on page
y: number; // y-coordinate on page
}): Promise<SyncTex> {
let { head, tail } = path_split(opts.pdf_path);
let output = await exec_synctex(opts.project_id, head, [
"edit",
"-o",
`${opts.page}:${opts.x}:${opts.y}:${tail}`
]);
return parse_synctex_output(output.stdout);
}
示例8: count_words
export async function count_words(
project_id: string,
path: string,
time?: number
) {
const { head, tail } = path_split(path);
const res = await exec({
allow_post: true,
command: "texcount",
args: [tail],
project_id: project_id,
path: head,
err_on_exit: false,
aggregate: time
});
return res;
}
示例9: convert
export async function convert(
project_id: string,
path: string,
frontmatter: string,
time?: number
): Promise<ExecOutput> {
const x = path_split(path);
let infile = x.tail;
// console.log("frontmatter", frontmatter);
let cmd: string;
// https://www.rdocumentation.org/packages/rmarkdown/versions/1.10/topics/render
// unless user specifies some self_contained value or user did set an explicit "output: ..." mode,
// we disable it as a convenience (rough heuristic, but should be fine)
if (
frontmatter.indexOf("self_contained") >= 0 ||
frontmatter.indexOf("output:") >= 0
) {
cmd = `rmarkdown::render('${infile}', output_format = NULL, run_pandoc = TRUE)`;
} else {
cmd = `rmarkdown::render('${infile}', output_format = NULL, output_options = list(self_contained = FALSE) , run_pandoc = TRUE)`;
}
// console.log("rmd cmd", cmd);
return await exec({
allow_post: false, // definitely could take a long time to fully run all the R stuff...
timeout: 90,
bash: true, // so timeout is enforced by ulimit
command: "Rscript",
args: ["-e", cmd],
project_id: project_id,
path: x.head,
err_on_exit: true,
aggregate: time
});
}
示例10: cm_options
export function cm_options(
filename: string, // extension determines editor mode
editor_settings: Map<string, any>,
gutters: string[], // array of extra gutters
actions: any,
frame_id: string
): object {
let key = filename_extension_notilde(filename).toLowerCase();
if (!key) {
key = `noext-${path_split(filename).tail}`.toLowerCase();
}
const default_opts =
(file_associations[key] != null
? file_associations[key].opts
: undefined) != null
? file_associations[key] != null
? file_associations[key].opts
: undefined
: {};
let opts = defaults(default_opts, {
undoDepth: 0, // we use our own sync-aware undo.
mode: "txt",
show_trailing_whitespace: editor_settings.get(
"show_trailing_whitespace",
true
),
allow_javascript_eval: true, // if false, the one use of eval isn't allowed.
line_numbers: editor_settings.get("line_numbers", true),
first_line_number: editor_settings.get("first_line_number", 1),
indent_unit: editor_settings.get("tab_size"), // TODO! indent_unit just isn't implemented -- see #2847.
tab_size: editor_settings.get("tab_size"),
smart_indent: editor_settings.get("smart_indent", true),
electric_chars: editor_settings.get("electric_chars", true),
match_brackets: editor_settings.get("match_brackets", true),
code_folding: editor_settings.get("code_folding", true),
auto_close_brackets: editor_settings.get("auto_close_brackets", false),
match_xml_tags: editor_settings.get("match_xml_tags", true),
auto_close_xml_tags: editor_settings.get("auto_close_xml_tags", true),
auto_close_latex: editor_settings.get("auto_close_latex", true),
line_wrapping: editor_settings.get("line_wrapping", true),
spaces_instead_of_tabs: editor_settings.get("spaces_instead_of_tabs", true),
style_active_line: editor_settings.get("style_active_line", true),
bindings: editor_settings.get("bindings"),
theme: editor_settings.get("theme")
});
if (opts.mode == null) {
// to satisfy typescript
throw Error("mode must be specified");
}
const extraKeys = {
"Ctrl-'": "indentAuto",
"Cmd-'": "indentAuto",
"Cmd-/": "toggleComment",
"Ctrl-/": "toggleComment", // shortcut chosen by jupyter project (undocumented)
"Ctrl-Space": "autocomplete",
Tab(cm) {
tab_key(cm, opts.spaces_instead_of_tabs);
},
"Shift-Tab"(cm) {
cm.unindent_selection();
},
"Shift-Cmd-L"(cm) {
cm.align_assignments();
},
"Shift-Ctrl-L"(cm) {
cm.align_assignments();
}
};
if (feature.IS_TOUCH) {
// maybe should be IS_IPAD... ?
// Better more external keyboard friendly shortcuts, motivated by iPad.
extra_alt_keys(extraKeys, actions, frame_id, opts);
}
if (actions) {
const build = () => {
if (actions.build !== undefined) {
actions.build(frame_id);
} else {
if (get_editor_settings().get("show_exec_warning")) {
actions.set_error(
"You can evaluate code in a file with the extension 'sagews' or 'ipynb'. Please create a Sage Worksheet or Jupyter notebook instead."
);
}
}
};
const actionKeys = {
"Cmd-S"() {
actions.save(true);
},
"Alt-S"() {
actions.save(true);
},
"Ctrl-S"() {
//.........這裏部分代碼省略.........