From d82292661244f0a8774da46ae22ea652e3745412 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 13 Dec 2024 19:06:23 -0500 Subject: [PATCH] Moving functionality to improve modularity. --- src/MiniDocs/LeDatabase.extension.st | 2 +- src/MiniDocs/LePage.extension.st | 8 -------- src/MiniDocs/XMLDocument.extension.st | 9 +++++++++ 3 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 src/MiniDocs/XMLDocument.extension.st diff --git a/src/MiniDocs/LeDatabase.extension.st b/src/MiniDocs/LeDatabase.extension.st index b084682..64c6151 100644 --- a/src/MiniDocs/LeDatabase.extension.st +++ b/src/MiniDocs/LeDatabase.extension.st @@ -43,7 +43,7 @@ LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocati remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree. "Ensuring remote metadata has consistent data" remoteMetadata at: 'origin' put: externalDocLocation. - remoteMetadata at: 'title' ifAbsentPut: [ page detectMarkdeepTitleFrom: markdeepDocTree ]. + remoteMetadata at: 'title' ifAbsentPut: [ markdeepDocTree detectMarkdeepTitle ]. remoteMetadata at: 'id' ifAbsentPut: [UUID new asString36]. remoteMetadata at: 'created' ifAbsentPut: [ DateAndTime now] . remoteMetadata at: 'creator' ifAbsentPut: [ 'unknown' ]. diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index 109076f..d21769f 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -99,14 +99,6 @@ LePage >> defaultPandocTemplate [ ^ FileLocator home / '.pandoc' / 'templates' / 'clean-menu-mod.html' ] -{ #category : #'*MiniDocs' } -LePage >> detectMarkdeepTitleFrom: xmlSubtree [ - | titleLine | - titleLine := (xmlSubtree nodesCollect: [:node | node contentString ]) first lines - detect: [:line | line includesSubstring: ' **'] ifNone: ['Untitled']. - ^ titleLine trimmed trimBoth: [:char | char = $* ] -] - { #category : #'*MiniDocs' } LePage >> detectParentSnippetWithUid: uidString [ uidString = self uid asString36 ifTrue: [ ^ self ]. diff --git a/src/MiniDocs/XMLDocument.extension.st b/src/MiniDocs/XMLDocument.extension.st new file mode 100644 index 0000000..d4574b6 --- /dev/null +++ b/src/MiniDocs/XMLDocument.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #XMLDocument } + +{ #category : #'*MiniDocs' } +XMLDocument >> detectMarkdeepTitle [ + | titleLine | + titleLine := (self nodesCollect: [:node | node contentString ]) first lines + detect: [:line | line includesSubstring: ' **'] ifNone: ['Untitled']. + ^ titleLine trimmed trimBoth: [:char | char = $* ] +]