Improving Markdown exportation from Markdeep files.
This commit is contained in:
parent
05269ac364
commit
4c661e0b6d
@ -8,16 +8,16 @@ Class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
HedgeDocGrammar >> start [
|
HedgeDocGrammar >> metadataAsYAML [
|
||||||
| any |
|
"I parse the header of the hedgedoc document for YAML metadata."
|
||||||
any := #any asPParser.
|
^ '---' asPParser token, #any asPParser starLazy token, '---' asPParser token
|
||||||
^ (self yamlMetadata / any starLazy), youtubeEmbeddedLink
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
HedgeDocGrammar >> yamlMetadata [
|
HedgeDocGrammar >> start [
|
||||||
"I parse the header of the hedgedoc document for YAML metadata."
|
| any |
|
||||||
^ '---' asPParser token, #any asPParser starLazy token, '---' asPParser token
|
any := #any asPParser.
|
||||||
|
^ (self metadataAsYAML / any starLazy), youtubeEmbeddedLink
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
|
@ -30,6 +30,14 @@ Markdeep class >> fromPubPubTOC: orderedDictionary folder: folder index: ordina
|
|||||||
^ self new fromMarkdownFile: testFile.
|
^ self new fromMarkdownFile: testFile.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Markdeep >> asMarkdown [
|
||||||
|
^ Markdown new
|
||||||
|
metadata: self metadata;
|
||||||
|
body: self body;
|
||||||
|
file: self markdownFile
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'instance creation' }
|
{ #category : #'instance creation' }
|
||||||
Markdeep >> authors [
|
Markdeep >> authors [
|
||||||
self metadata at: 'authors' ifPresent: [:k | ^ '**', k, '**' ].
|
self metadata at: 'authors' ifPresent: [:k | ^ '**', k, '**' ].
|
||||||
@ -380,7 +388,7 @@ Markdeep >> processMarkdownFor: aFileReference [
|
|||||||
| markdownContent |
|
| markdownContent |
|
||||||
self file: aFileReference, 'html'.
|
self file: aFileReference, 'html'.
|
||||||
markdownContent := Markdown fromFile: aFileReference.
|
markdownContent := Markdown fromFile: aFileReference.
|
||||||
self metadata: markdownContent yamlMetadata.
|
self metadata: markdownContent metadataAsYAML.
|
||||||
self body: (markdownContent commentYAMLMetadata contents).
|
self body: (markdownContent commentYAMLMetadata contents).
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -62,7 +62,14 @@ Markdown >> containsYAMLMetadataClosing [
|
|||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Markdown >> contents [
|
Markdown >> contents [
|
||||||
^ body
|
| response |
|
||||||
|
response := WriteStream on: ''.
|
||||||
|
response
|
||||||
|
nextPutAll: self class yamlMetadataDelimiter; cr;
|
||||||
|
nextPutAll: self metadataAsYAML; cr;
|
||||||
|
nextPutAll: self class yamlMetadataDelimiter; cr;
|
||||||
|
nextPutAll: self body.
|
||||||
|
^ response contents
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
@ -121,7 +128,7 @@ Markdown >> exportAsFileOn: aFileReference [
|
|||||||
aFileReference ensureDelete.
|
aFileReference ensureDelete.
|
||||||
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
|
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
|
||||||
aFileReference writeStreamDo: [ :stream |
|
aFileReference writeStreamDo: [ :stream |
|
||||||
stream nextPutAll: self contents ].
|
stream nextPutAll: self contents withInternetLineEndings ].
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #operation }
|
{ #category : #operation }
|
||||||
@ -203,6 +210,12 @@ Markdown >> metadata: rawMeta [
|
|||||||
metadata := rawMeta
|
metadata := rawMeta
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Markdown >> metadataAsYAML [
|
||||||
|
self metadata isEmptyOrNil ifTrue: [ ^ self ].
|
||||||
|
^ YQ jsonToYaml: self metadata
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #persistence }
|
{ #category : #persistence }
|
||||||
Markdown >> notifyExportAsFileOn: aFileReference [
|
Markdown >> notifyExportAsFileOn: aFileReference [
|
||||||
self exportAsFileOn: aFileReference.
|
self exportAsFileOn: aFileReference.
|
||||||
@ -234,11 +247,6 @@ Markdown >> startsWithYAMLMetadataDelimiter [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
|
||||||
Markdown >> yamlMetadata [
|
|
||||||
^ MiniDocs yamlToJson: self yamlMetadataString
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #utilities }
|
{ #category : #utilities }
|
||||||
Markdown >> yamlMetadataClosingLineNumber [
|
Markdown >> yamlMetadataClosingLineNumber [
|
||||||
"I return the line where the closing of the YAML metadata occurs or 0 if no closing is found."
|
"I return the line where the closing of the YAML metadata occurs or 0 if no closing is found."
|
||||||
|
@ -17,11 +17,30 @@ YQ class >> binaryDownloadLinkFor: operativeSystem on: processor [
|
|||||||
^ binaryDownloadData at: 'browser_download_url'
|
^ binaryDownloadData at: 'browser_download_url'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
YQ class >> binaryFile [
|
||||||
|
"Starting with location on Arch Linux and its derivates. Multidistro and multiOS support should be added."
|
||||||
|
^ FileLocator root / 'usr/bin/yq'
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
YQ class >> install [
|
YQ class >> install [
|
||||||
^ self lastReleaseData
|
^ self lastReleaseData
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
YQ class >> jsonToYaml: aDictionary [
|
||||||
|
| jsonFile |
|
||||||
|
self binaryFile exists ifFalse: [ YQ install].
|
||||||
|
jsonFile := MarkupFile exportAsFileOn: FileLocator temp / 'data.json' containing: aDictionary.
|
||||||
|
OSSUnixSubprocess new
|
||||||
|
shellCommand: 'cat ', jsonFile fullName,' | yq -y';
|
||||||
|
redirectStdout;
|
||||||
|
runAndWaitOnExitDo: [ :command :outString |
|
||||||
|
^ outString
|
||||||
|
].
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
YQ class >> lastReleaseData [
|
YQ class >> lastReleaseData [
|
||||||
^ (STONJSON
|
^ (STONJSON
|
||||||
|
Loading…
Reference in New Issue
Block a user