Ejemplo n.º 1
0
        public async Task <string> Convert(IWorkspace workspace, CancelToken cancelToken)
        {
            string temp     = IOUtility.GetHashFile(workspace.FileSystem.Directory, workspace.Item.FullName);
            var    settings = Settings.Default;

            if (settings.UseOfflineCompiler)
            {
                return(PandocUtility.Compile(temp, workspace.Item.FullName, settings.LocalTemplate, settings.LocalCsl, "*.md"));
            }
            else
            {
                var bytes = await workspace.ConverterService.Convert(MultipartFormParameter
                                                                     .ApiParameter(ConverterType.Markdown, ConverterType.Pdf, settings.Template, settings.Csl)
                                                                     .Concat(MultipartFormParameter
                                                                             .FromWorkspace(workspace)), cancelToken);

                await IOUtility.WriteAllBytes(temp, workspace.FileSystem.File, bytes);

                return(temp);
            }
        }