Fixed encoding bug in htmlToMarkdown.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-08-27 13:34:45 +00:00
parent b2c8d2bfdf
commit bab4ab7fb9

View File

@ -505,20 +505,22 @@ GrafoscopioNode >> headers [
{ #category : #operation } { #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 markdownFile |
(self isTaggedAs: 'código' ) ifTrue: [ ^self ]. (self isTaggedAs: 'código' ) ifTrue: [ ^self ].
((self headerStartsWith: '%invisible') or:[self hasAncestorHeaderWith: '%invisible']) ((self headerStartsWith: '%invisible') "or:[self hasAncestorHeaderWith: '%invisible']")
ifTrue: [ ^self ]. ifTrue: [ ^self ].
htmlFile := FileLocator temp asFileReference / 'body.html'. htmlFile := FileLocator temp asFileReference / 'body.html'.
htmlFile ensureDelete. htmlFile ensureDelete.
htmlFile ensureCreateFile. markdownFile := FileLocator temp asFileReference / 'body.markdown'.
htmlFile writeStreamDo: [:stream | stream nextPutAll: self body]. markdownFile ensureDelete.
htmlFile writeStreamDo: [:out | out nextPutAll: self body ].
self body: (PipeableOSProcess command: 'pandoc -f html -t markdown --atx-headers ', htmlFile fullName) output. OSProcess
waitForCommand: 'pandoc -f html -t markdown --atx-headers ',
htmlFile fullName, ' -o ', markdownFile fullName.
self body: markdownFile contents.
htmlFile ensureDelete. htmlFile ensureDelete.
markdownFile ensureDelete.
] ]
{ #category : #operation } { #category : #operation }
@ -887,16 +889,6 @@ GrafoscopioNode >> publish [
self inform: publishedUrl , ' was published and the url was copied to clipboard' self inform: publishedUrl , ' was published and the url was copied to clipboard'
] ]
{ #category : #accessing }
GrafoscopioNode >> remoteRepository [
^ remoteRepository
]
{ #category : #accessing }
GrafoscopioNode >> remoteRepository: anObject [
remoteRepository := anObject
]
{ #category : #'add/remove nodes' } { #category : #'add/remove nodes' }
GrafoscopioNode >> removeLastNode [ GrafoscopioNode >> removeLastNode [
"Adds the given node to the receivers collection of children, and sets this object as the parent "Adds the given node to the receivers collection of children, and sets this object as the parent
@ -915,6 +907,11 @@ GrafoscopioNode >> removeNode: aNode [
] ]
{ #category : #utility }
GrafoscopioNode >> replaceAccentedHTMLChars [
self body: (self body copyReplaceAll: 'í' with: 'í' )
]
{ #category : #accessing } { #category : #accessing }
GrafoscopioNode >> root [ GrafoscopioNode >> root [
"I return the root node of the Grafoscopio tree, i.e the common ancestor of all other nodes" "I return the root node of the Grafoscopio tree, i.e the common ancestor of all other nodes"