diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index 23ec3ec..74f0f13 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -60,7 +60,9 @@ GrafoscopioNotebook class >> open: aFileReference [ { #category : #utilities } GrafoscopioNotebook >> addCommandFrom: dictionary into: stream [ dictionary keysAndValuesDo: [ :k :v | - k = 'thisNotebook' ifTrue: [ stream nextPutAll: (self perform: #markdownFileChecksumUpto: with: 10) ] ] + k = 'thisNotebook' + ifTrue: [ + stream nextPutAll: (GrafoscopioUtils perform: v on: self) ]] ] { #category : #'editing nodes' } @@ -183,7 +185,9 @@ GrafoscopioNotebook >> exportAsLaTeX [ I suppose pandoc is already installed and available in the system." | texFile | self markdownFile exists ifTrue: [ self markdownFile delete ]. - self exportAsMarkdown. + "self exportAsMarkdown.""<- This violates the separation of concenrs. Markdown exportation should + be explicit. There is still the issue of how to deal with desynchronization between a notebook + which has unsaved changes as markdown.... TO BE REVIWED!" texFile := self markdownFile parent fullName,'/', self markdownFile basenameWithoutExtension, '.tex'. texFile asFileReference exists ifTrue: [ texFile asFileReference delete ]. OSProcess command: 'pandoc --standalone ', self markdownFile fullName, ' -o ', texFile. @@ -203,16 +207,14 @@ GrafoscopioNotebook >> exportAsPDF [ "I export the current tree/document to a PDF file, using pandoc and LaTeX external apps. The latex engine used is xelatex, to minimize errors and warnings related with UTF8 support. I suppose all them are already installed and defined in the system." - | pdfFile pandocCommand | - self markdownFile exists ifFalse: [ self exportAsMarkdown ]. - pdfFile := self markdownFile parent fullName,'/', self markdownFile basenameWithoutExtension, '.pdf'. - pdfFile asFileReference exists ifTrue: [ pdfFile asFileReference delete ]. - pandocCommand := 'cd ', self workingFile parent fullName,'; pandoc ', - self pandocOptionsComputed, ' ', - self markdownFile fullName, ' -o ', pdfFile. - Transcript show: pandocCommand. + | pandocCommand | + self markdownFile exists ifFalse: [ self exportAsMarkdown ]. + self pdfFile ensureDelete. + pandocCommand := 'cd ', self markdownFile parent fullName,'; ', + 'pandoc ', self pandocOptionsComputed, ' ', + self markdownFile fullName, ' -o ', self pdfFile fullName. ExternalUnixOSProcess command: pandocCommand. - self inform: ('File exported as: ', String cr, pdfFile) + self inform: ('File exported as: ', String cr, self pdfFile fullName) ] { #category : #persistence } @@ -351,8 +353,11 @@ GrafoscopioNotebook >> markdownFileChecksum [ ] { #category : #utilities } -GrafoscopioNotebook >> markdownFileChecksumUpto: anInteger [ - ^ self markdownFileChecksum copyFrom: 1 to: anInteger. +GrafoscopioNotebook >> markdownFileChecksumUpto: anInteger [ + "I cut the markdownFileCheckup upto a given integer. + Type coersion is needed, because this message argument can be read from a string in %metadata nodes. + Maybe the way used by playgrounds to import text as commands can be useful here." + ^ self markdownFileChecksum copyFrom: 1 to: anInteger asInteger. ] { #category : #'editing nodes' } @@ -562,6 +567,15 @@ GrafoscopioNotebook >> pasteNodeFromClipboard [ self notebookContent: notebook. ] +{ #category : #persistence } +GrafoscopioNotebook >> pdfFile [ + "I define the location of the markdown file where the notebook will be exported" + | pdfFile | + pdfFile := (self markdownFile parent fullName,'/', self markdownFile basenameWithoutExtension, '.pdf') asFileReference. + ^ pdfFile. + +] + { #category : #initialization } GrafoscopioNotebook >> projectSubMenu [