Implementing PubPub initial minimal grammar for dealing with alternate link notation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-21 18:47:37 -05:00
parent 9a3d17e200
commit 70a06b2c4d
3 changed files with 57 additions and 3 deletions

View File

@ -24,6 +24,14 @@ Markdeep class >> fromMarkdownFile: aFileReference [
^ self new fromMarkdownFile: aFileReference. ^ self new fromMarkdownFile: aFileReference.
] ]
{ #category : #accessing }
Markdeep class >> fromPubPubTOC: orderedDictionary folder: folder index: ordinalPossitive [
| contentSection testFile |
contentSection := orderedDictionary associations at: ordinalPossitive.
testFile := folder / (contentSection key,'--', contentSection value),'md'.
^ self new fromMarkdownFile: testFile.
]
{ #category : #'instance creation' } { #category : #'instance creation' }
Markdeep >> authors [ Markdeep >> authors [
self metadata at: 'authors' ifPresent: [:k | ^ '**', k, '**' ]. self metadata at: 'authors' ifPresent: [:k | ^ '**', k, '**' ].
@ -123,7 +131,7 @@ Markdeep >> contents [
Markdeep >> exportAsFile [ Markdeep >> exportAsFile [
| newFile | | newFile |
self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ]. self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ].
newFile := (self markdownFile fullName, '.html') asFileReference. newFile := (self markdownFile file fullName, '.html') asFileReference.
self exportAsFileOn: newFile. self exportAsFileOn: newFile.
] ]

View File

@ -28,7 +28,8 @@ MiniDocs class >> installYamlToJson [
{ #category : #accessing } { #category : #accessing }
MiniDocs class >> yamlToJson: yamlString [ MiniDocs class >> yamlToJson: yamlString [
"This method uses a external binary written in Nim, as the native Pharo parser for YAML, written in PetitParser,
was less robust and unable to parse correctly the same strings as the external one."
self yamlToJsonBinary exists ifFalse: [ self installYamlToJson ]. self yamlToJsonBinary exists ifFalse: [ self installYamlToJson ].
OSSUnixSubprocess new OSSUnixSubprocess new

View File

@ -0,0 +1,45 @@
Class {
#name : #PubPubGrammar,
#superclass : #PP2CompositeNode,
#instVars : [
'document',
'link',
'linkLabel',
'linkContent'
],
#category : #'MiniDocs-Model'
}
{ #category : #accessing }
PubPubGrammar >> document [
^ link islandInSea star
]
{ #category : #links }
PubPubGrammar >> link [
^ linkLabel, linkContent ==> #second
]
{ #category : #links }
PubPubGrammar >> linkContent [
| content |
content := ($} asPParser not) star flatten.
^ ${ asPParser, content, $} asPParser
]
{ #category : #links }
PubPubGrammar >> linkLabel [
| label |
label := ($] asPParser not) star flatten.
^ $[ asPParser, label, $] asPParser
]
{ #category : #accessing }
PubPubGrammar >> linkSea [
^ link sea ==> #second
]
{ #category : #accessing }
PubPubGrammar >> start [
^ document
]