htmlToMarkdown functionality.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-08-26 18:28:38 +00:00
parent 01f6e38520
commit 432f8bd64f
2 changed files with 29 additions and 0 deletions

View File

@ -502,6 +502,18 @@ GrafoscopioNode >> headers [
^ headers := self children collect: [:currentNode | currentNode header ] ^ 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 } { #category : #accessing }
GrafoscopioNode >> icon [ GrafoscopioNode >> icon [
"Returns the receivers icon" "Returns the receivers icon"

View File

@ -261,6 +261,16 @@ GrafoscopioNotebook >> header: anObject [
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 } { #category : #operation }
GrafoscopioNotebook >> importLinkContent [ GrafoscopioNotebook >> importLinkContent [
"I see if a node header is an url located at 'http://ws.stfx.eu', wich means that is a shared "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'; description: 'Import link content';
icon: #glamorousRefresh asIcon; icon: #glamorousRefresh asIcon;
action: [ self importLinkContent ] ]. action: [ self importLinkContent ] ].
group
addItem: [ :item |
item
name: nil;
description: 'HTML to Markdown';
icon: #smallProfile asIcon;
action: [ self htmlToMarkdown ] ].
group group
addItem: [ :item | addItem: [ :item |
item item