diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index e04cb84..2c53f42 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -502,6 +502,18 @@ GrafoscopioNode >> headers [ ^ headers := self children collect: [:currentNode | currentNode header ] ] +{ #category : #'as yet unclassified' } +GrafoscopioNode >> htmlToMarkdown [ + "I convert the node body from HTML format to Pandoc's Markdown." + | htmlFile | + htmlFile := FileLocator temp asFileReference / 'body.html'. + htmlFile ensureDelete. + htmlFile ensureCreateFile. + htmlFile writeStreamDo: [:stream | stream nextPutAll: self body]. + self body: (PipeableOSProcess command: 'pandoc -f html -t markdown --atx-headers ', htmlFile fullName) output. + "htmlFile ensureDelete." +] + { #category : #accessing } GrafoscopioNode >> icon [ "Returns the receivers icon" diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index 74f0f13..f10c8eb 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -261,6 +261,16 @@ GrafoscopioNotebook >> header: anObject [ header := anObject ] +{ #category : #operation } +GrafoscopioNotebook >> htmlToMarkdown [ + | currentNode nodeContent | + currentNode := tree highlightedItem. + currentNode ifNil: [ ^ self ]. + nodeContent := currentNode content. + nodeContent htmlToMarkdown. + self updateBodyFor: currentNode +] + { #category : #operation } GrafoscopioNotebook >> importLinkContent [ "I see if a node header is an url located at 'http://ws.stfx.eu', wich means that is a shared @@ -819,6 +829,13 @@ GrafoscopioNotebook >> topBar [ description: 'Import link content'; icon: #glamorousRefresh asIcon; action: [ self importLinkContent ] ]. + group + addItem: [ :item | + item + name: nil; + description: 'HTML to Markdown'; + icon: #smallProfile asIcon; + action: [ self htmlToMarkdown ] ]. group addItem: [ :item | item