htmlToMarkdownSubtree functionality added.

This commit is contained in:
GloriaMeneses 2017-08-26 20:43:40 +00:00 committed by SantiagoBragagnolo
parent 97a6c18c51
commit fbd389bb58
1 changed files with 21 additions and 8 deletions

View File

@ -190,7 +190,7 @@ GrafoscopioNode >> becomeDefaultTestTree [
header: 'Arbol principal'.
node1 := self class new
header: 'Markup';
body: 'I am just a node with markup';
body: 'I am <b>just a node with markup</b>';
tagAs: 'text';
links: 'temp.md';
level: 1.
@ -199,18 +199,18 @@ GrafoscopioNode >> becomeDefaultTestTree [
tagAs: 'código';
body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'.
node3 := self class new
header: 'Child';
header: '%invisible';
tagAs: 'text';
body: 'Just testing'.
body: '<i>Just testing</i>'.
node1 addNode: node3.
node4 := self class new
header: 'Something';
tagAs: 'text';
body: 'else'.
body: '<h1>else</h1>'.
node1 addNode: node4.
node1 addNode: node2.
self
addNode: node1;
addNode: node2.
addNode: node1.
]
{ #category : #initialization }
@ -502,16 +502,29 @@ GrafoscopioNode >> headers [
^ headers := self children collect: [:currentNode | currentNode header ]
]
{ #category : #'as yet unclassified' }
{ #category : #operation }
GrafoscopioNode >> htmlToMarkdown [
"I convert the node body from HTML format to Pandoc's Markdown."
| htmlFile |
(self isTaggedAs: 'código' ) ifTrue: [ ^self ].
((self headerStartsWith: '%invisible') or:[self hasAncestorHeaderWith: '%invisible'])
ifTrue: [ ^self ].
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."
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 }