Improving Unix (Mac, Gnu/Linux) Pandoc integration with new librarie.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2018-10-03 11:11:10 +00:00
parent c53e8c2053
commit 21641e9399
2 changed files with 29 additions and 9 deletions

View File

@ -541,6 +541,12 @@ GrafoscopioNotebook >> notebookSubMenu [
name: 'Import images';
icon: (Smalltalk ui icons iconNamed: #processBrowser);
action: [ self importImages ] ].
group
addItem: [ :item |
item
name: 'See images list';
icon: (Smalltalk ui icons iconNamed: #processBrowser);
action: [ self listImagesUI ] ].
group
addItem: [ :item |
item
@ -583,12 +589,6 @@ GrafoscopioNotebook >> notebookSubMenu [
name: 'See pdf';
icon: (Smalltalk ui icons iconNamed: #smallInspectIt);
action: [ self inform: 'To be implemented...' ] ].
group
addItem: [ :item |
item
name: 'See images list';
icon: (Smalltalk ui icons iconNamed: #processBrowser);
action: [ self listImagesUI ] ].
group
addItem: [ :item |
item

View File

@ -40,6 +40,27 @@ Pandoc class >> executableLocation [
ifFalse: [ self definePandocExecutable ]
]
{ #category : #utility }
Pandoc class >> extractImagesInUnixFor: aFileReference withFilter: aLuaFilter [
"I use Pandoc Lua scripting capabilities to extract al images links in aFileReference"
OSSUnixSubprocess new
command: 'pandoc';
arguments: {aFileReference fullName . '--lua-filter=',aLuaFilter fullName };
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString :errString |
process isSuccess
ifTrue: [
^ ((Soup fromString: outString) findAllTags: 'td') collect: [ :each | each next ] ]
ifFalse: [
"OSSUnixProcessExitStatus has a nice #printOn: "
Transcript show: 'Command exit with error status: ', process exitStatusInterpreter printString; cr.
Transcript show: 'Stderr contents: ', errString.
]
]
]
{ #category : #'as yet unclassified' }
Pandoc class >> listImagesFrom: aFileReference [
"I provide a list of all images contained in aFile."
@ -48,10 +69,9 @@ Pandoc class >> listImagesFrom: aFileReference [
filter exists ifFalse: [ self downloadLuaFilters ].
commandString := 'pandoc ', aFileReference fullName, ' --lua-filter=',filter fullName.
Smalltalk platformName = 'unix'
ifTrue: [ outputString := (PipeableOSProcess waitForCommand: commandString ) output ].
ifTrue: [ ^ self extractImagesInUnixFor: aFileReference withFilter: filter ].
Smalltalk platformName = 'Win32'
ifTrue: [ WindowsProcess ].
^ ((Soup fromString: outputString) findAllTags: 'td') collect: [ :each | each next ]
ifTrue: [ self ].
]
{ #category : #utility }