diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index cf9b4c2..2984b6a 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -390,22 +390,6 @@ GrafoscopioNode >> exportDecoratedCodeBlockTo: aStream [ ^aStream contents ] -{ #category : #exporting } -GrafoscopioNode >> exportPreambleOldTo: aStream [ - "comment stating purpose of message" - | configDict | - (self header = '%config') - ifTrue: [ - configDict := STON fromString: (self body). - - aStream nextPutAll: 'title: ', (configDict at: 'title'); lf. - aStream nextPutAll: 'author: ', ((configDict at: 'author') at: 'given'), ' ', ((configDict at: 'author') at: 'family'); lf. - aStream nextPutAll: 'bibliography: ', (configDict at: 'bibliography'); lf. - aStream nextPutAll: 'abstract: ', '|'; lf; nextPutAll: (configDict at: 'abstract'); lf. - ]. - aStream nextPutAll: '---'; lf. -] - { #category : #exporting } GrafoscopioNode >> exportPreambleTo: aStream [ "comment stating purpose of message" diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index d279f12..6a2de2c 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -160,6 +160,16 @@ GrafoscopioNotebook >> exportAsSton: aNotebook on: aFileStream [ aFileStream nextPutAll: stonPrettyString ] +{ #category : #persistence } +GrafoscopioNotebook >> exportNode: aGrafoscopioNode asMarkdownIn: aFile [ + "I export the current tree/document to a markdown file" + aFile exists ifTrue: [ aFile delete ]. + aFile + ensureCreateFile; + writeStreamDo: [:stream | stream nextPutAll: aGrafoscopioNode asMarkdown]. + self inform: ('Exported as: ', String cr, aFile fullName) +] + { #category : #api } GrafoscopioNotebook >> extent [ ^900@500 @@ -247,6 +257,19 @@ GrafoscopioNotebook >> moveNodeBefore [ self notebookContent: notebook ] +{ #category : #utilities } +GrafoscopioNotebook >> navigateRelativePathFor: aFileString [ + "Given a relative path according to location of the notebook's workingFile, I navigate to that file" + + | finalLocation | + finalLocation := workingFile parent. + (aFileString splitOn: '/') do: [ :segment | + (segment = '..') + ifTrue: [ finalLocation := finalLocation parent ] + ifFalse: [finalLocation := finalLocation / segment]]. + ^ finalLocation +] + { #category : #accessing } GrafoscopioNotebook >> notebook [ ^ notebook @@ -528,6 +551,15 @@ GrafoscopioNotebook >> saveWorkingNotebook [ ] +{ #category : #persistence } +GrafoscopioNotebook >> subTreeAsMarkdown [ + | currentNode exportedFile | + currentNode := tree highlightedItem content. + currentNode links last ifNil: [ ^self ]. + exportedFile:= self navigateRelativePathFor: currentNode links last. + self exportNode: currentNode asMarkdownIn: exportedFile +] + { #category : #'editing nodes' } GrafoscopioNotebook >> toggleCodeNode [ | currentNode | @@ -630,9 +662,15 @@ GrafoscopioNotebook >> topBar [ group addItem: [ :item | item name: nil; - description: 'Load link'; + description: 'Reload link'; icon: Smalltalk ui icons glamorousRefresh; - action: [ self updateForSpecialLinks ] ]. + action: [ self updateForSpecialLinks ] ]. + group addItem: [ :item | + item + name: nil; + description: 'Export subtree'; + icon: Smalltalk ui icons glamorousMore; + action: [ self subTreeAsMarkdown ] ]. group addItem: [ :item | item name: nil;