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 [
| newPage snippet |
snippet := LeTextSnippet new
string: self bodyWithoutTitleHeader.
string: self bodyWithoutTitleHeader promoteMarkdownHeaders.
newPage := LePage new
initializeTitle: self title;
addSnippet: snippet;
yourself.
newPage incomingLinks.
newPage metadata addAll: self metadata.
^ 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 ] ]
]
{ #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' }
String >> romanizeAccents [
| modified corrections |