Improving Markdeep and Markdown document tree readings with more renders and linefeed bugfix.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-07 19:21:47 -05:00
parent 093f989e28
commit 2dd4377c4d
7 changed files with 115 additions and 15 deletions

View File

@ -55,13 +55,6 @@ HedgeDoc >> defaultServer [
self server: 'https://docutopia.tupale.co'. self server: 'https://docutopia.tupale.co'.
] ]
{ #category : #accessing }
HedgeDoc >> documentTree [
| parser|
parser := PPCommonMarkBlockParser new parse: self contents.
^ parser accept: CMBlockVisitor new
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
HedgeDoc >> htmlUrl [ HedgeDoc >> htmlUrl [
| link | | link |

View File

@ -213,7 +213,9 @@ Markdeep >> markdeepScriptTag [
{ #category : #accessing } { #category : #accessing }
Markdeep >> markdownFile [ Markdeep >> markdownFile [
^ self file ifNil: [ self file: FileLocator temp / ('untitled--', NanoID generate, '.md')]. self file ifNil: [
self file: FileLocator temp / ('untitled--', NanoID generate, '.md.html') ].
^ (self file fullName withoutSuffix: '.html') asFileReference.
] ]
{ #category : #accessing } { #category : #accessing }
@ -276,10 +278,10 @@ Markdeep >> printOn: aStream [
Markdeep >> processMarkdownFor: aFileReference [ Markdeep >> processMarkdownFor: aFileReference [
"comment stating purpose of message" "comment stating purpose of message"
| markdownContent | | markdownContent |
self markdownFile: aFileReference. self file: aFileReference, 'html'.
markdownContent := Markdown fromFile: aFileReference. markdownContent := Markdown fromFile: aFileReference.
self metadata: markdownContent yamlMetadata.
self body: (markdownContent commentYAMLMetadata contents). self body: (markdownContent commentYAMLMetadata contents).
self metadata: markdownContent yamlMetadata
] ]
{ #category : #accessing } { #category : #accessing }

View File

@ -30,12 +30,12 @@ Markdown >> commentYAMLMetadata [
| newContents | | newContents |
self detectYAMLMetadata ifFalse: [ ^ self ]. self detectYAMLMetadata ifFalse: [ ^ self ].
newContents := '' writeStream. newContents := '' writeStream.
newContents nextPutAll: '<!--@yaml:'; crlf. newContents nextPutAll: '<!--@yaml'; lf.
newContents nextPutAll: self yamlMetadataString. newContents nextPutAll: self yamlMetadataString.
newContents nextPutAll: String cr. newContents nextPutAll: String lf.
newContents nextPutAll: '-->'; crlf. newContents nextPutAll: '-->'; lf; lf.
(self lines copyFrom: self yamlMetadataClosingLineNumber + 2 to: self lines size) do: [ :line | (self lines copyFrom: self yamlMetadataClosingLineNumber + 2 to: self lines size) do: [ :line |
newContents nextPutAll: line; crlf ]. newContents nextPutAll: line; lf;lf ].
^ newContents contents. ^ newContents contents.
] ]
@ -64,6 +64,16 @@ Markdown >> contentsWithoutYAMLMetadata [
^ newContents contents. ^ newContents contents.
] ]
{ #category : #operation }
Markdown >> deleteYAMLMetadata [
| newContents |
self detectYAMLMetadata ifFalse: [ ^ self ].
newContents := '' writeStream.
(self lines copyFrom: self yamlMetadataClosingLineNumber + 1 to: self lines size) do: [ :line |
newContents nextPutAll: line; lf;lf ].
^ newContents contents.
]
{ #category : #utilities } { #category : #utilities }
Markdown >> detectYAMLMetadata [ Markdown >> detectYAMLMetadata [
| lines | | lines |
@ -74,6 +84,13 @@ Markdown >> detectYAMLMetadata [
ifFound: [ ^ true ] ifNone: [ ^ false ] ] ifFound: [ ^ true ] ifNone: [ ^ false ] ]
] ]
{ #category : #accessing }
Markdown >> documentTree [
| parser|
parser := PPCommonMarkBlockParser new parse: self contents.
^ parser accept: CMBlockVisitor new
]
{ #category : #persistence } { #category : #persistence }
Markdown >> exportAsFile [ Markdown >> exportAsFile [
| newFile | | newFile |
@ -222,7 +239,7 @@ Markdown >> yamlMetadataString [
yamlLines do: [ :line | yamlLines do: [ :line |
output output
nextPutAll: line; nextPutAll: line;
nextPut: Character cr. ]. nextPut: Character lf. ].
^ output contents ^ output contents
] ]

View File

@ -8,3 +8,25 @@ Class {
PPCMEmphasize >> accept: visitor [ PPCMEmphasize >> accept: visitor [
^ visitor visitEmphasize: self ^ visitor visitEmphasize: self
] ]
{ #category : #accessing }
PPCMEmphasize >> viewBody [
| aText |
aText := (self className ,' ', self text) asRopedText.
self children do: [ :child |
aText append: ' ' asRopedText.
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: ('= "' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append:
('"' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor)
].
^ aText
]

View File

@ -8,3 +8,25 @@ Class {
PPCMHardBreak >> accept: visitor [ PPCMHardBreak >> accept: visitor [
^ visitor visitHardBreak: self ^ visitor visitHardBreak: self
] ]
{ #category : #accessing }
PPCMHardBreak >> viewBody [
| aText |
aText := (self className ,' ', self text) asRopedText.
self children do: [ :child |
aText append: ' ' asRopedText.
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: ('= "' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append:
('"' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor)
].
^ aText
]

View File

@ -13,3 +13,25 @@ PPCMHtmlBlock >> accept: visitor [
PPCMHtmlBlock >> isBlockLevel [ PPCMHtmlBlock >> isBlockLevel [
^ true ^ true
] ]
{ #category : #accessing }
PPCMHtmlBlock >> viewBody [
| aText |
aText := (self className ,' ', self text) asRopedText.
self children do: [ :child |
aText append: ' ' asRopedText.
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: ('= "' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append:
('"' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor)
].
^ aText
]

View File

@ -18,3 +18,25 @@ PPCMIndentedCode >> code [
PPCMIndentedCode >> isBlockLevel [ PPCMIndentedCode >> isBlockLevel [
^ true ^ true
] ]
{ #category : #accessing }
PPCMIndentedCode >> viewBody [
| aText |
aText := (self className ,' ', self text) asRopedText.
self children do: [ :child |
aText append: ' ' asRopedText.
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: ('= "' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append: (child text asRopedText foreground:
BrGlamorousColors disabledButtonTextColor).
aText append:
('"' asRopedText foreground:
BrGlamorousColors disabledButtonTextColor)
].
^ aText
]