Improving HedgeDoc objects reading from web links.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-03-25 16:23:14 -05:00
parent 80afb07c77
commit 27a20e83b0
2 changed files with 12 additions and 6 deletions

View File

@ -42,7 +42,7 @@ HedgeDoc >> asMarkdownTiddler [
{ #category : #accessing } { #category : #accessing }
HedgeDoc >> contents [ HedgeDoc >> contents [
^ body ^ super contents
] ]
{ #category : #accessing } { #category : #accessing }
@ -55,6 +55,12 @@ HedgeDoc >> defaultServer [
self server: 'https://docutopia.tupale.co'. self server: 'https://docutopia.tupale.co'.
] ]
{ #category : #accessing }
HedgeDoc >> fromLink: aString [
self url: aString.
self retrieveContents
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
HedgeDoc >> htmlUrl [ HedgeDoc >> htmlUrl [
| link | | link |
@ -81,7 +87,7 @@ HedgeDoc >> pad: anObject [
{ #category : #accessing } { #category : #accessing }
HedgeDoc >> retrieveContents [ HedgeDoc >> retrieveContents [
self url ifNil: [ ^ self ]. self url ifNil: [ ^ self ].
self contents: (self url addPathSegment: 'download') retrieveContents. self fromString: (self url addPathSegment: 'download') retrieveContents.
^ self. ^ self.
] ]

View File

@ -62,7 +62,7 @@ Markdown >> contents [
response response
nextPutAll: '---'; cr; nextPutAll: '---'; cr;
nextPutAll: self metadataAsYAML; cr; nextPutAll: self metadataAsYAML; cr;
nextPutAll: '---'; cr; cr; nextPutAll: '---'; cr;
nextPutAll: self body. nextPutAll: self body.
^ response contents ^ response contents
] ]
@ -76,7 +76,7 @@ Markdown >> contents: aString [
Markdown >> documentTree [ Markdown >> documentTree [
| parser| | parser|
self contents ifNil: [^ nil]. self contents ifNil: [^ nil].
parser := PPCommonMarkBlockParser new parse: self contents. parser := PPCommonMarkBlockParser new parse: self body.
^ parser accept: CMBlockVisitor new ^ parser accept: CMBlockVisitor new
] ]
@ -191,7 +191,7 @@ Markdown >> metadata: rawMeta [
{ #category : #accessing } { #category : #accessing }
Markdown >> metadataAsYAML [ Markdown >> metadataAsYAML [
self metadata isEmptyOrNil ifTrue: [ ^ '' ]. self metadata isEmptyOrNil ifTrue: [ ^ '' ].
^ YQ jsonToYaml: self metadata ^ (YQ jsonToYaml: self metadata) accentedCharactersCorrection
] ]
{ #category : #persistence } { #category : #persistence }
@ -215,5 +215,5 @@ Markdown >> printOn: aStream [
{ #category : #accessing } { #category : #accessing }
Markdown >> title [ Markdown >> title [
^ self metadata at: 'title' ifAbsentPut: [ self headerAsTitle] ^ self metadata at: 'title' ifAbsentPut: [ self headerAsTitle ]
] ]