Using Lua scripts with Pandoc for a crossplatform support.
This commit is contained in:
parent
d739f3f357
commit
b679e231ec
@ -68,14 +68,22 @@ Markdown >> detectYAMLMetadata [
|
||||
|
||||
{ #category : #operation }
|
||||
Markdown >> exportMetadataAsJson [
|
||||
| yaml2json |
|
||||
self exportMetadataAsYaml.
|
||||
yaml2json := OSSUnixSubprocess new
|
||||
shellCommand: 'yaml2json /tmp/metadata.yaml > /tmp/metadata.json';
|
||||
run.
|
||||
yaml2json waitForExit.
|
||||
yaml2json closeAndCleanStreams.
|
||||
^ FileLocator temp / 'metadata.json'
|
||||
"TBD: Lua scripts should be checked and installed when missing. Maybe a shared location
|
||||
in '.local/share/Grafoscopio/Scripts' should be developed in the near future."
|
||||
| output luaScript |
|
||||
luaScript := FileLocator home / '.local/share/Brea/scripts/meta-to-json.lua'.
|
||||
OSSUnixSubprocess new
|
||||
workingDirectory: self file parent fullName;
|
||||
command: 'pandoc';
|
||||
arguments: { '--lua-filter=', luaScript fullName . self file basename };
|
||||
redirectStdout;
|
||||
redirectStdin;
|
||||
runAndWaitOnExitDo: [ :process :outString :errString |
|
||||
output := process isSuccess
|
||||
ifTrue: [ outString ]
|
||||
ifFalse: [ errString ]
|
||||
].
|
||||
^ output correctAccentedCharacters
|
||||
]
|
||||
|
||||
{ #category : #operation }
|
||||
|
@ -14,6 +14,19 @@ String >> asDashedLowercase [
|
||||
^ '-' join: (self substrings collect: [:each | each asLowercase ])
|
||||
]
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils' }
|
||||
String >> correctAccentedCharacters [
|
||||
|
||||
| output |
|
||||
output := self
|
||||
copyReplaceAll: 'ó' with: 'ó'.
|
||||
output := output copyReplaceAll: 'á' with: 'á'.
|
||||
output := output copyReplaceAll: 'é' with: 'é'.
|
||||
output := output copyReplaceAll: 'Ã' with: 'í'.
|
||||
output := output copyReplaceAll: 'ú' with: 'ú'.
|
||||
^ output
|
||||
]
|
||||
|
||||
{ #category : #'*Grafoscopio-Utils' }
|
||||
String >> isOrgModeHeader [
|
||||
^ self beginsWithAnyOf: #('* ' '** ' '*** ' '**** ' '***** ' '***** ')
|
||||
|
Loading…
Reference in New Issue
Block a user