htmlToMarkdownSubtree functionality added.

This commit is contained in:
Gloria Meneses 2017-08-26 20:43:40 +00:00 committed by Offray Luna
parent bee71e7a7f
commit 57ae88b304

View File

@ -190,7 +190,7 @@ GrafoscopioNode >> becomeDefaultTestTree [
header: 'Arbol principal'. header: 'Arbol principal'.
node1 := self class new node1 := self class new
header: 'Markup'; header: 'Markup';
body: 'I am just a node with markup'; body: 'I am <b>just a node with markup</b>';
tagAs: 'text'; tagAs: 'text';
links: 'temp.md'; links: 'temp.md';
level: 1. level: 1.
@ -199,18 +199,18 @@ GrafoscopioNode >> becomeDefaultTestTree [
tagAs: 'código'; tagAs: 'código';
body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'. body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'.
node3 := self class new node3 := self class new
header: 'Child'; header: '%invisible';
tagAs: 'text'; tagAs: 'text';
body: 'Just testing'. body: '<i>Just testing</i>'.
node1 addNode: node3. node1 addNode: node3.
node4 := self class new node4 := self class new
header: 'Something'; header: 'Something';
tagAs: 'text'; tagAs: 'text';
body: 'else'. body: '<h1>else</h1>'.
node1 addNode: node4. node1 addNode: node4.
node1 addNode: node2.
self self
addNode: node1; addNode: node1.
addNode: node2.
] ]
{ #category : #initialization } { #category : #initialization }
@ -502,16 +502,29 @@ GrafoscopioNode >> headers [
^ headers := self children collect: [:currentNode | currentNode header ] ^ headers := self children collect: [:currentNode | currentNode header ]
] ]
{ #category : #'as yet unclassified' } { #category : #operation }
GrafoscopioNode >> htmlToMarkdown [ GrafoscopioNode >> htmlToMarkdown [
"I convert the node body from HTML format to Pandoc's Markdown." "I convert the node body from HTML format to Pandoc's Markdown."
| htmlFile | | htmlFile |
(self isTaggedAs: 'código' ) ifTrue: [ ^self ].
((self headerStartsWith: '%invisible') or:[self hasAncestorHeaderWith: '%invisible'])
ifTrue: [ ^self ].
htmlFile := FileLocator temp asFileReference / 'body.html'. htmlFile := FileLocator temp asFileReference / 'body.html'.
htmlFile ensureDelete. htmlFile ensureDelete.
htmlFile ensureCreateFile. htmlFile ensureCreateFile.
htmlFile writeStreamDo: [:stream | stream nextPutAll: self body]. htmlFile writeStreamDo: [:stream | stream nextPutAll: self body].
self body: (PipeableOSProcess command: 'pandoc -f html -t markdown --atx-headers ', htmlFile fullName) output. self body: (PipeableOSProcess command: 'pandoc -f html -t markdown --atx-headers ', htmlFile fullName) output.
"htmlFile ensureDelete." htmlFile ensureDelete.
]
{ #category : #operation }
GrafoscopioNode >> htmlToMarkdownSubtree [
"I convert self and childern nodes body from HTML format to Pandoc's Markdown."
self preorderTraversal do: [ :each | each htmlToMarkdown ]
] ]
{ #category : #accessing } { #category : #accessing }