Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
e26334425f | |||
58ec9eed76 | |||
bb7bab403e | |||
cea7ce5e6c | |||
cccf81e89b | |||
02403b5ae3 | |||
e4d0880fea | |||
ee80105f44 | |||
ecb4321551 | |||
56ef3869ca |
@ -23,6 +23,30 @@ FileLocator class >> atAlias: aString put: aFolderOrFile [
|
||||
^ updatedAliases
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
FileLocator >> extractMetadata [
|
||||
"I package the functionality from [[How to extract meta information using ExifTool]],
|
||||
from the GToolkit Book.
|
||||
I depend on the external tool ExifTool."
|
||||
|
||||
| process variablesList |
|
||||
process := GtSubprocessWithInMemoryOutput new
|
||||
command: 'exiftool';
|
||||
arguments: { self fullName}.
|
||||
process errorBlock: [ :proc | ^ self error: 'Failed to run exiftool' ].
|
||||
process runAndWait.
|
||||
variablesList := process stdout lines collect: [ :currentLine |
|
||||
| separatorIndex name value |
|
||||
separatorIndex := currentLine indexOf: $:.
|
||||
name := (currentLine copyFrom: 1 to: separatorIndex - 1) trimBoth.
|
||||
value := (currentLine
|
||||
copyFrom: separatorIndex + 1
|
||||
to: currentLine size) trimBoth.
|
||||
name -> value
|
||||
].
|
||||
^ variablesList asOrderedDictionary
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
FileLocator class >> fileAliases [
|
||||
^ MiniDocs appFolder / 'fileAliases.ston'
|
||||
|
@ -37,7 +37,9 @@ HedgeDoc >> asLePage [
|
||||
addSnippet: snippet;
|
||||
yourself.
|
||||
newPage incomingLinks.
|
||||
newPage metadata addAll: self metadata.
|
||||
newPage options
|
||||
at: 'originalMetadata' put: self metadata;
|
||||
at: 'url' put: self url.
|
||||
^ newPage
|
||||
]
|
||||
|
||||
@ -162,7 +164,6 @@ HedgeDoc >> url: anObject [
|
||||
(html xpath: '//head/meta[@name="application-name"][@content = "HedgeDoc - Ideas grow better together"]') isEmpty
|
||||
ifTrue: [ self inform: 'Not a hedgedoc url'.
|
||||
url := nil ].
|
||||
self metadata at: 'title' put: tempUrl firstPathSegment.
|
||||
server := tempUrl host.
|
||||
url := anObject
|
||||
]
|
||||
|
@ -50,7 +50,7 @@ Markdown >> body: aString [
|
||||
{ #category : #operation }
|
||||
Markdown >> commentYAMLMetadata [
|
||||
| newContents |
|
||||
self detectYAMLMetadata ifFalse: [ ^ self ].
|
||||
self contents detectYAMLMetadata ifFalse: [ ^ self ].
|
||||
newContents := '' writeStream.
|
||||
newContents nextPutAll: '<!--@yaml'; lf.
|
||||
newContents nextPutAll: self yamlMetadataString.
|
||||
@ -160,7 +160,10 @@ Markdown >> fromFile: aFileReference [
|
||||
{ #category : #'instance creation' }
|
||||
Markdown >> fromString: markdownString [
|
||||
markdownString yamlMetadata
|
||||
ifNotNil: [(self metadata) at: 'original' put: markdownString yamlMetadata].
|
||||
ifNotNil: [
|
||||
self metadata
|
||||
ifEmpty: [self metadata: markdownString yamlMetadata]
|
||||
ifNotEmpty: [self metadata at: 'original' put: markdownString yamlMetadata]].
|
||||
self body: markdownString contentsWithoutYAMLMetadata
|
||||
]
|
||||
|
||||
@ -191,6 +194,7 @@ Markdown >> metadata [
|
||||
|
||||
^ metadata ifNil: [ metadata := Dictionary new].
|
||||
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -230,3 +234,8 @@ Markdown >> printOn: aStream [
|
||||
Markdown >> title [
|
||||
^ title ifNil: [ title:= self headerAsTitle ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdown >> title: aString [
|
||||
title := aString
|
||||
]
|
||||
|
@ -147,17 +147,11 @@ Pandoc class >> markdownToHtmlOnUnix: inputFile [
|
||||
outputFile := inputFile parent / (inputFile basenameWithoutExtension , '.html').
|
||||
outputFile ensureDelete.
|
||||
outputFile ensureCreateFile.
|
||||
OSSUnixSubprocess new
|
||||
command: 'pandoc';
|
||||
arguments: {'-f'. 'markdown+startnum+task_lists'. '--standalone'. '-t'. 'html'. inputFile fullName.
|
||||
'--output'. outputFile fullName };
|
||||
redirectStdout;
|
||||
redirectStderr;
|
||||
runAndWaitOnExitDo: [ :process :outString :errString |
|
||||
process isSuccess
|
||||
ifTrue: [ ^ outputFile ]
|
||||
ifFalse: [ ^ inputFile ]
|
||||
]
|
||||
GtSubprocessWithInMemoryOutput new
|
||||
shellCommand: 'pandoc -f markdown+startnum+task_lists --standalone -t html ', inputFile fullName, ' --output ', outputFile fullName;
|
||||
runAndWait;
|
||||
stdout.
|
||||
^ outputFile.
|
||||
]
|
||||
|
||||
{ #category : #converters }
|
||||
|
Loading…
Reference in New Issue
Block a user