Using Lua scripts with Pandoc for a crossplatform support.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-10-08 17:36:52 -05:00
parent d739f3f357
commit b679e231ec
2 changed files with 29 additions and 8 deletions

View File

@ -68,14 +68,22 @@ Markdown >> detectYAMLMetadata [
{ #category : #operation } { #category : #operation }
Markdown >> exportMetadataAsJson [ Markdown >> exportMetadataAsJson [
| yaml2json | "TBD: Lua scripts should be checked and installed when missing. Maybe a shared location
self exportMetadataAsYaml. in '.local/share/Grafoscopio/Scripts' should be developed in the near future."
yaml2json := OSSUnixSubprocess new | output luaScript |
shellCommand: 'yaml2json /tmp/metadata.yaml > /tmp/metadata.json'; luaScript := FileLocator home / '.local/share/Brea/scripts/meta-to-json.lua'.
run. OSSUnixSubprocess new
yaml2json waitForExit. workingDirectory: self file parent fullName;
yaml2json closeAndCleanStreams. command: 'pandoc';
^ FileLocator temp / 'metadata.json' 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 } { #category : #operation }

View File

@ -14,6 +14,19 @@ String >> asDashedLowercase [
^ '-' join: (self substrings collect: [:each | each asLowercase ]) ^ '-' 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' } { #category : #'*Grafoscopio-Utils' }
String >> isOrgModeHeader [ String >> isOrgModeHeader [
^ self beginsWithAnyOf: #('* ' '** ' '*** ' '**** ' '***** ' '***** ') ^ self beginsWithAnyOf: #('* ' '** ' '*** ' '**** ' '***** ' '***** ')