From fe0d65cf5a634ad1b3933bb745145a316e31e5c7 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 9 May 2023 14:45:23 -0500 Subject: [PATCH] Data cleaning methods. --- src/MiniDocs/Markdeep.class.st | 37 ++++++++++++++++++++++++++++++++++ src/MiniDocs/Markdown.class.st | 18 +++++++++++++++++ src/MiniDocs/PubPub.class.st | 30 --------------------------- 3 files changed, 55 insertions(+), 30 deletions(-) delete mode 100644 src/MiniDocs/PubPub.class.st diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index c650a88..26e4c4b 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -393,6 +393,43 @@ Markdeep >> pubPubRawLinks [ ^ (parser parse: self body) ] +{ #category : #accessing } +Markdeep >> removeAlternativeImagesArray [ + | parser replacements | + self body ifNil: [^ self]. + parser := PubPubGrammar2 new. + replacements := parser parse: body. + replacements ifEmpty: [^self]. + replacements do: [:replacement | + self body: + (self body copyReplaceAll: replacement third with: '' ) + ]. + self body: (self body copyReplaceAll: '{srcset=}' with: ''). +] + +{ #category : #accessing } +Markdeep >> removeAutoGeneratedFileNotice [ + | autoGeneratedNotice | + autoGeneratedNotice := '**Notice:** This file is an auto-generated download and, as such, might +include minor display or rendering errors. For the version of record, +please visit the HTML version or download the PDF. + +------------------------------------------------------------------------'. + self body: (self body copyReplaceAll: autoGeneratedNotice with: '') +] + +{ #category : #accessing } +Markdeep >> removeCCByLicenseDiv [ + | licenseDiv| + licenseDiv := '
+ +**License:** [Creative Commons Attribution 4.0 International License +(CC-BY 4.0)](https://creativecommons.org/licenses/by/4.0/) + +
'. + self body: (self body copyReplaceAll: licenseDiv with: '') +] + { #category : #accessing } Markdeep >> replaceBackslashBreaklines [ self bodyReplaceAll: '\ diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index 1117488..bcbe8c3 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -25,6 +25,24 @@ Markdown class >> yamlMetadataDelimiter [ ] +{ #category : #accessing } +Markdown >> asMarkdeep [ + ^ Markdeep new + body: self body; + markdownFile: self file; + commentYAMLMetadata +] + +{ #category : #accessing } +Markdown >> body [ + ^ body +] + +{ #category : #accessing } +Markdown >> body: aString [ + body := aString +] + { #category : #operation } Markdown >> commentYAMLMetadata [ | newContents | diff --git a/src/MiniDocs/PubPub.class.st b/src/MiniDocs/PubPub.class.st deleted file mode 100644 index e50b328..0000000 --- a/src/MiniDocs/PubPub.class.st +++ /dev/null @@ -1,30 +0,0 @@ -Class { - #name : #PubPub, - #superclass : #Markdown, - #instVars : [ - 'url' - ], - #category : #'MiniDocs-Core' -} - -{ #category : #accessing } -PubPub >> detectImageLinkPositions [ - | docNodes response | - docNodes := self documentTree allChildren. - response := OrderedCollection new. - docNodes doWithIndex: [:each :i| - ((each className = 'PPCMLink') and: [ (docNodes at: i - 1) text = '!' ]) ifTrue: - [ response add: {i -> each } ] - ]. - ^ response -] - -{ #category : #accessing } -PubPub >> linksWithTreePosition [ - | response | - response := OrderedCollection new. - self documentTree allChildren doWithIndex: [:each :i | - each className = 'PPCMLink' ifTrue: [ response add: { i -> each }] - ]. - ^ response -]