-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fixes to exporting of notebook to html #12882
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,28 +27,32 @@ export class ExportManagerFilePicker implements IExportManagerFilePicker { | |
): Promise<Uri | undefined> { | ||
// map each export method to a set of file extensions | ||
let fileExtensions; | ||
let extension: string | undefined; | ||
switch (format) { | ||
case ExportFormat.python: | ||
fileExtensions = PythonExtensions; | ||
extension = '.py'; | ||
break; | ||
|
||
case ExportFormat.pdf: | ||
extension = '.pdf'; | ||
fileExtensions = PDFExtensions; | ||
break; | ||
|
||
case ExportFormat.html: | ||
extension = '.html'; | ||
fileExtensions = HTMLExtensions; | ||
break; | ||
|
||
default: | ||
return; | ||
} | ||
|
||
const notebookFileName = defaultFileName | ||
const targetFileName = defaultFileName | ||
? defaultFileName | ||
: path.basename(source.fsPath, path.extname(source.fsPath)); | ||
: `${path.basename(source.fsPath, path.extname(source.fsPath))}${extension}`; | ||
|
||
const dialogUri = Uri.file(path.join(this.getLastFileSaveLocation().fsPath, notebookFileName)); | ||
const dialogUri = Uri.file(path.join(this.getLastFileSaveLocation().fsPath, targetFileName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were looking for |
||
const options: SaveDialogOptions = { | ||
defaultUri: dialogUri, | ||
saveLabel: 'Export', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,12 @@ import * as uuid from 'uuid/v4'; | |
import { CancellationTokenSource, Uri } from 'vscode'; | ||
import { IFileSystem, TemporaryDirectory } from '../../common/platform/types'; | ||
import { sleep } from '../../common/utils/async'; | ||
import { ICell, IDataScienceErrorHandler, INotebookExporter, INotebookModel, INotebookStorage } from '../types'; | ||
import { ICell, INotebookExporter, INotebookModel, INotebookStorage } from '../types'; | ||
|
||
@injectable() | ||
export class ExportUtil { | ||
constructor( | ||
@inject(IFileSystem) private fileSystem: IFileSystem, | ||
@inject(IDataScienceErrorHandler) private readonly errorHandler: IDataScienceErrorHandler, | ||
@inject(INotebookStorage) private notebookStorage: INotebookStorage, | ||
@inject(INotebookExporter) private jupyterExporter: INotebookExporter | ||
) {} | ||
|
@@ -44,12 +43,7 @@ export class ExportUtil { | |
public async makeFileInDirectory(model: INotebookModel, fileName: string, dirPath: string): Promise<string> { | ||
const newFilePath = path.join(dirPath, fileName); | ||
|
||
try { | ||
const content = model ? model.getContent() : ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. model cannot be undefined. |
||
await this.fileSystem.writeFile(newFilePath, content, 'utf-8'); | ||
} catch (e) { | ||
await this.errorHandler.handleError(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error handler was not rqeuired |
||
} | ||
await this.fileSystem.writeFile(newFilePath, model.getContent(), 'utf-8'); | ||
|
||
return newFilePath; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was required on mac