Improving Unix (Mac, Gnu/Linux) Pandoc integration with new librarie.
This commit is contained in:
parent
c53e8c2053
commit
21641e9399
@ -541,6 +541,12 @@ GrafoscopioNotebook >> notebookSubMenu [
|
|||||||
name: 'Import images';
|
name: 'Import images';
|
||||||
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
||||||
action: [ self importImages ] ].
|
action: [ self importImages ] ].
|
||||||
|
group
|
||||||
|
addItem: [ :item |
|
||||||
|
item
|
||||||
|
name: 'See images list';
|
||||||
|
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
||||||
|
action: [ self listImagesUI ] ].
|
||||||
group
|
group
|
||||||
addItem: [ :item |
|
addItem: [ :item |
|
||||||
item
|
item
|
||||||
@ -583,12 +589,6 @@ GrafoscopioNotebook >> notebookSubMenu [
|
|||||||
name: 'See pdf';
|
name: 'See pdf';
|
||||||
icon: (Smalltalk ui icons iconNamed: #smallInspectIt);
|
icon: (Smalltalk ui icons iconNamed: #smallInspectIt);
|
||||||
action: [ self inform: 'To be implemented...' ] ].
|
action: [ self inform: 'To be implemented...' ] ].
|
||||||
group
|
|
||||||
addItem: [ :item |
|
|
||||||
item
|
|
||||||
name: 'See images list';
|
|
||||||
icon: (Smalltalk ui icons iconNamed: #processBrowser);
|
|
||||||
action: [ self listImagesUI ] ].
|
|
||||||
group
|
group
|
||||||
addItem: [ :item |
|
addItem: [ :item |
|
||||||
item
|
item
|
||||||
|
@ -40,6 +40,27 @@ Pandoc class >> executableLocation [
|
|||||||
ifFalse: [ self definePandocExecutable ]
|
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' }
|
{ #category : #'as yet unclassified' }
|
||||||
Pandoc class >> listImagesFrom: aFileReference [
|
Pandoc class >> listImagesFrom: aFileReference [
|
||||||
"I provide a list of all images contained in aFile."
|
"I provide a list of all images contained in aFile."
|
||||||
@ -48,10 +69,9 @@ Pandoc class >> listImagesFrom: aFileReference [
|
|||||||
filter exists ifFalse: [ self downloadLuaFilters ].
|
filter exists ifFalse: [ self downloadLuaFilters ].
|
||||||
commandString := 'pandoc ', aFileReference fullName, ' --lua-filter=',filter fullName.
|
commandString := 'pandoc ', aFileReference fullName, ' --lua-filter=',filter fullName.
|
||||||
Smalltalk platformName = 'unix'
|
Smalltalk platformName = 'unix'
|
||||||
ifTrue: [ outputString := (PipeableOSProcess waitForCommand: commandString ) output ].
|
ifTrue: [ ^ self extractImagesInUnixFor: aFileReference withFilter: filter ].
|
||||||
Smalltalk platformName = 'Win32'
|
Smalltalk platformName = 'Win32'
|
||||||
ifTrue: [ WindowsProcess ].
|
ifTrue: [ self ].
|
||||||
^ ((Soup fromString: outputString) findAllTags: 'td') collect: [ :each | each next ]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #utility }
|
{ #category : #utility }
|
||||||
|
Loading…
Reference in New Issue
Block a user