HedgeDoc convert/import as LePage promotes Markdown headers.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-03-26 21:54:46 -05:00
parent 60939fe2b8
commit 536d2a9326
3 changed files with 21 additions and 1 deletions

View File

@ -31,11 +31,13 @@ HedgeDoc class >> newDefault [
HedgeDoc >> asLePage [ HedgeDoc >> asLePage [
| newPage snippet | | newPage snippet |
snippet := LeTextSnippet new snippet := LeTextSnippet new
string: self bodyWithoutTitleHeader. string: self bodyWithoutTitleHeader promoteMarkdownHeaders.
newPage := LePage new newPage := LePage new
initializeTitle: self title; initializeTitle: self title;
addSnippet: snippet; addSnippet: snippet;
yourself. yourself.
newPage incomingLinks.
newPage metadata addAll: self metadata.
^ newPage ^ newPage
] ]

View File

@ -0,0 +1,8 @@
Extension { #name : #LeHeaderNode }
{ #category : #'*MiniDocs' }
LeHeaderNode >> headerFullName [
^ self topParent completeSource
copyFrom: self startPosition
to: self stopPosition
]

View File

@ -50,6 +50,16 @@ String >> detectYAMLMetadata [
ifFound: [ ^ true ] ifNone: [ ^ false ] ] ifFound: [ ^ true ] ifNone: [ ^ false ] ]
] ]
{ #category : #'*MiniDocs' }
String >> promoteMarkdownHeaders [
| headers response |
response := self contents.
headers := (LeTextSnippet string: response) ast // #LeHeaderNode collect: [ :each | each headerFullName asString ].
headers do: [ :each |
response := response copyReplaceAll: each with: each allButFirst ].
^ response
]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
String >> romanizeAccents [ String >> romanizeAccents [
| modified corrections | | modified corrections |