Reconvering Pandoc Markdown tranformation for node body.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2019-01-04 19:21:24 +00:00 committed by SantiagoBragagnolo
parent 37245db024
commit 89410871a8
4 changed files with 118 additions and 1 deletions

View File

@ -0,0 +1,51 @@
"
I model the links of a GrafoscopioNode.
I'm responsable for showing the links and selecting them.
"
Class {
#name : #GrafoscopioLinksList,
#superclass : #ComposableModel,
#instVars : [
'links'
],
#category : #'Grafoscopio-UI'
}
{ #category : #specs }
GrafoscopioLinksList class >> defaultSpec [
^ SpecLayout composed
add: #links;
yourself
]
{ #category : #accessing }
GrafoscopioLinksList >> content: aGrafoscopioNode [
links items: aGrafoscopioNode links
]
{ #category : #initialization }
GrafoscopioLinksList >> initializeWidgets [
links := self newList.
self focusOrder add: links
]
{ #category : #accessing }
GrafoscopioLinksList >> links [
^ links
]
{ #category : #accessing }
GrafoscopioLinksList >> links: anObject [
links := anObject
]
{ #category : #api }
GrafoscopioLinksList >> title [
^ 'Node links list'
]
{ #category : #'api-events' }
GrafoscopioLinksList >> whenSelectedItemChanged: aBlock [
links whenSelectedItemChanged: aBlock
]

View File

@ -0,0 +1,8 @@
Class {
#name : #GrafoscopioLinkstModel,
#superclass : #ComposableModel,
#instVars : [
'links'
],
#category : #'Grafoscopio-UI'
}

View File

@ -1073,3 +1073,38 @@ GrafoscopioNode >> visitedGoTo: aCollection [
]
{ #category : #'as yet unclassified' }
GrafoscopioNode >> wrapBodyLines [
"I convert the node body from HTML format to Pandoc's Markdown."
| bodyFile |
(self isTaggedAs: 'código' ) ifTrue: [ ^self ].
bodyFile := FileLocator temp asFileReference / 'body.txt'.
bodyFile ensureCreateFile.
bodyFile writeStreamDo: [:out | out nextPutAll: self body ].
Smalltalk platformName = 'unix'
ifTrue: [ self body: (self wrapBodyLinesFor: bodyFile) ].
Smalltalk platformName = 'Win32'
ifTrue: [ self shouldBeImplemented ].
bodyFile ensureDelete.
]
{ #category : #'as yet unclassified' }
GrafoscopioNode >> wrapBodyLinesFor: inputFile [
| outputFile |
outputFile := FileLocator temp / 'body.tmp.txt'.
outputFile ensureDelete.
outputFile ensureCreateFile.
OSSUnixSubprocess new
command: 'fold';
arguments: {'-sw'. '80'. inputFile fullName. outputFile fullName};
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString :errString |
process isSuccess
ifTrue: [ ^ outString ]
ifFalse: [
self inform: errString.
^inputFile contents ]
]
]

View File

@ -427,11 +427,21 @@ GrafoscopioNotebook >> links: anObject [
]
{ #category : #'as yet unclassified' }
GrafoscopioNotebook >> linksList [
| currentNode |
currentNode := tree highlightedItem content.
GrafoscopioLinksList new
content: currentNode;
openWithSpec
]
{ #category : #utilities }
GrafoscopioNotebook >> listImagesUI [
ListModel new
title: 'Images files list';
items: self imagesList ;
openWithSpec
openWithSpec
]
{ #category : #persistence }
@ -951,6 +961,13 @@ GrafoscopioNotebook >> topBar [
description: 'Toggle: code <--> text';
icon: MendaIcons new smalltalkCodeIcon;
action: [ self toggleCodeNode ] ].
group
addItem: [ :item |
item
name: nil;
description: 'List node links';
icon: #tinyMenu asIcon;
action: [ self linksList ] ].
group
addItem: [ :item |
item
@ -1060,3 +1077,9 @@ GrafoscopioNotebook >> workingFile [
GrafoscopioNotebook >> workingFile: aFileReference [
workingFile := aFileReference.
]
{ #category : #'as yet unclassified' }
GrafoscopioNotebook >> wrapBodyLines [
self currentNodeContent wrapBodyLines.
self updateBodyFor: self currentNode
]