• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript misc2.path_split函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:26,代码来源:print.ts


示例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
  });
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:31,代码来源:latexmk.ts


示例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 };
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:7,代码来源:util.ts


示例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);
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:34,代码来源:print-code.ts


示例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;
  }
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:9,代码来源:util.ts


示例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);
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:21,代码来源:synctex.ts


示例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);
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:15,代码来源:synctex.ts


示例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;
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:17,代码来源:count_words.ts


示例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
  });
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:36,代码来源:rmd-converter.ts


示例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"() {
//.........这里部分代码省略.........
开发者ID:DrXyzzy,项目名称:smc,代码行数:101,代码来源:cm-options.ts



注:本文中的smc-util/misc2.path_split函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript misc2.set函数代码示例发布时间:2022-05-25
下一篇:
TypeScript async-utils.callback_opts函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap