Skip to content

Commit

Permalink
Fixing links
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Mar 21, 2024
1 parent 04b9927 commit a3c5cd6
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 142 deletions.
27 changes: 14 additions & 13 deletions src/Microdown-LaTeXExporter/MicDocumentWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,42 @@ I'm the superclass of writers in various formats.
I managed end of line conventions, canvas responsible for the encodings of specific commands to output a given format and I support raw ouputting.
"
Class {
#name : #MicDocumentWriter,
#superclass : #MicrodownVisitor,
#name : 'MicDocumentWriter',
#superclass : 'MicrodownVisitor',
#instVars : [
'canvas',
'nbListTab',
'writingRaw'
],
#category : #'Microdown-LaTeXExporter'
#category : 'Microdown-LaTeXExporter',
#package : 'Microdown-LaTeXExporter'
}

{ #category : #accessing }
{ #category : 'accessing' }
MicDocumentWriter >> canvasClass [

^ self subclassResponsibility
]

{ #category : #writing }
{ #category : 'writing' }
MicDocumentWriter >> contents [

^ canvas contents
]

{ #category : #initialization }
{ #category : 'initialization' }
MicDocumentWriter >> crAsNewLine [

canvas crAsNewLine
]

{ #category : #initialization }
{ #category : 'initialization' }
MicDocumentWriter >> crlfAsNewLine [

canvas crlfAsNewLine
]

{ #category : #initialization }
{ #category : 'initialization' }
MicDocumentWriter >> initialize [
| stream |
super initialize.
Expand All @@ -47,34 +48,34 @@ MicDocumentWriter >> initialize [
nbListTab := -1
]

{ #category : #initialization }
{ #category : 'initialization' }
MicDocumentWriter >> lfAsNewLine [

canvas lfAsNewLine
]

{ #category : #initialization }
{ #category : 'initialization' }
MicDocumentWriter >> usedNewLine [
"Return the encoded new line. Useful for tests."

^ canvas stream usedNewLine
]

{ #category : #writing }
{ #category : 'writing' }
MicDocumentWriter >> visit: aMicElement [

aMicElement accept: self.
^ self contents
]

{ #category : #writing }
{ #category : 'writing' }
MicDocumentWriter >> write: aMicElement [
"for now for integration with Pillar."
self visit: aMicElement.
^ self contents
]

{ #category : #writing }
{ #category : 'writing' }
MicDocumentWriter >> writeRawDuring: aBlock [

[
Expand Down
9 changes: 5 additions & 4 deletions src/Microdown-LaTeXExporter/MicExportBrush.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ I'm the superclass of all brushes. A brush is something you can add on a canvas.
Copied from Pillar
"
Class {
#name : #MicExportBrush,
#superclass : #Object,
#name : 'MicExportBrush',
#superclass : 'Object',
#instVars : [
'stream'
],
#category : #'Microdown-LaTeXExporter'
#category : 'Microdown-LaTeXExporter',
#package : 'Microdown-LaTeXExporter'
}

{ #category : #initialization }
{ #category : 'initialization' }
MicExportBrush >> setStream: aStream [
stream := aStream
]
49 changes: 25 additions & 24 deletions src/Microdown-LaTeXExporter/MicExportCanvas.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,75 @@ I am the place where the visitors will write stuff. I output everything to a str
Copied from Pillar
"
Class {
#name : #MicExportCanvas,
#superclass : #Object,
#name : 'MicExportCanvas',
#superclass : 'Object',
#instVars : [
'stream',
'currentBrush',
'writingRaw'
],
#category : #'Microdown-LaTeXExporter'
#category : 'Microdown-LaTeXExporter',
#package : 'Microdown-LaTeXExporter'
}

{ #category : #'instance creation' }
{ #category : 'instance creation' }
MicExportCanvas class >> on: aStream [
^ self new
setStream: aStream;
yourself
]

{ #category : #private }
{ #category : 'private' }
MicExportCanvas >> brush: aBrush [
self flush.
currentBrush := aBrush.
aBrush setStream: stream.
^ aBrush
]

{ #category : #accessing }
{ #category : 'accessing' }
MicExportCanvas >> contents [
^ stream contents
]

{ #category : #accessing }
{ #category : 'accessing' }
MicExportCanvas >> crAsNewLine [

stream crAsNewLine
]

{ #category : #accessing }
{ #category : 'accessing' }
MicExportCanvas >> crlfAsNewLine [

stream crlfAsNewLine
]

{ #category : #accessing }
{ #category : 'accessing' }
MicExportCanvas >> flush [
stream flush
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> initialize [

super initialize.
writingRaw := false
]

{ #category : #accessing }
{ #category : 'accessing' }
MicExportCanvas >> lfAsNewLine [

stream lfAsNewLine
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> line: aString [
self
nextPutAll: aString;
newLine
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> lines: aString [
"Output aString and take care of line ending within aString."
| str |
Expand All @@ -84,55 +85,55 @@ MicExportCanvas >> lines: aString [
]
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> newLine [
stream newLine
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> nextPut: aCharacter [
stream nextPut: aCharacter
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> nextPutAll: aString [
aString do: [ :char | self nextPut: char ]
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> nextPutAllLines: aString [
self withLinesIn: aString do: [ :line | self nextPutAll: line ] separatedBy: [ self newLine ]
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> raw: aString [
stream << aString
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> rawLines: aString [
"Output aString and take care of line ending within aString."
self withLinesIn: aString do: [ :line | self raw: line ] separatedBy: [ self newLine ]
]

{ #category : #initialization }
{ #category : 'initialization' }
MicExportCanvas >> setStream: aStream [
stream := aStream
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> space [
stream space
]

{ #category : #accessing }
{ #category : 'accessing' }
MicExportCanvas >> stream [
"Pay attention to what you do with this stream. You may break the canvas logic"

^ stream
]

{ #category : #private }
{ #category : 'private' }
MicExportCanvas >> withLinesIn: aString do: aBlock separatedBy: anotherBlock [
"this method shows that the body of code block is weak because it should encapsulate the way it internally represents lines. Now this is exposed in clients."
| str |
Expand All @@ -146,7 +147,7 @@ MicExportCanvas >> withLinesIn: aString do: aBlock separatedBy: anotherBlock [
ifFalse: anotherBlock ]
]

{ #category : #'writing text' }
{ #category : 'writing text' }
MicExportCanvas >> writingRaw: aBoolean [

writingRaw := aBoolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #MicInlineBlockWithUrl }
Extension { #name : 'MicInlineBlockWithUrl' }

{ #category : #'*Microdown-LaTeXExporter' }
{ #category : '*Microdown-LaTeXExporter' }
MicInlineBlockWithUrl >> fileStringWithoutHostFile [
| urlString localFileIndicator |
urlString := url asString.
Expand All @@ -10,13 +10,13 @@ MicInlineBlockWithUrl >> fileStringWithoutHostFile [
ifFalse: [ urlString ]
]

{ #category : #'*Microdown-LaTeXExporter' }
{ #category : '*Microdown-LaTeXExporter' }
MicInlineBlockWithUrl >> fullName [

^ reference fullName
]

{ #category : #'*Microdown-LaTeXExporter' }
{ #category : '*Microdown-LaTeXExporter' }
MicInlineBlockWithUrl >> hasCaption [

^ children notEmpty
Expand Down
11 changes: 6 additions & 5 deletions src/Microdown-LaTeXExporter/MicLaTeXBrush.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
Command and environment LaTeX brushes common superclass.
"
Class {
#name : #MicLaTeXBrush,
#superclass : #MicExportBrush,
#category : #'Microdown-LaTeXExporter'
#name : 'MicLaTeXBrush',
#superclass : 'MicExportBrush',
#category : 'Microdown-LaTeXExporter',
#package : 'Microdown-LaTeXExporter'
}

{ #category : #accessing }
{ #category : 'accessing' }
MicLaTeXBrush >> optParameter: aStringOrBlock [
stream
<< $[
<< aStringOrBlock
<< $]
]

{ #category : #accessing }
{ #category : 'accessing' }
MicLaTeXBrush >> parameter: aStringOrBlock [
stream
<< ${
Expand Down
17 changes: 9 additions & 8 deletions src/Microdown-LaTeXExporter/MicLaTeXCanvas.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
I'm a specialized canvas to emit commands and latex environments.
"
Class {
#name : #MicLaTeXCanvas,
#superclass : #MicExportCanvas,
#name : 'MicLaTeXCanvas',
#superclass : 'MicExportCanvas',
#classVars : [
'LatexCharacters'
],
#category : #'Microdown-LaTeXExporter'
#category : 'Microdown-LaTeXExporter',
#package : 'Microdown-LaTeXExporter'
}

{ #category : #'class initialization' }
{ #category : 'class initialization' }
MicLaTeXCanvas class >> initialize [
" self initialize "
LatexCharacters := Dictionary new.
Expand Down Expand Up @@ -86,25 +87,25 @@ MicLaTeXCanvas class >> initialize [
at: $Ñ put: '\~{N}'
]
{ #category : #tags }
{ #category : 'tags' }
MicLaTeXCanvas >> command [
^ self brush: MicLaTeXCommand new
]
{ #category : #tags }
{ #category : 'tags' }
MicLaTeXCanvas >> environment [
^ self brush: MicLaTeXEnvironment new
]
{ #category : #'writing text' }
{ #category : 'writing text' }
MicLaTeXCanvas >> interpretedNextPut: aCharacter [
(LatexCharacters at: aCharacter ifAbsent: nil)
ifNil: [ self raw: aCharacter ]
ifNotNil: [ :string | self raw: string ]
]
{ #category : #'writing text' }
{ #category : 'writing text' }
MicLaTeXCanvas >> nextPut: aCharacter [
writingRaw
Expand Down
9 changes: 5 additions & 4 deletions src/Microdown-LaTeXExporter/MicLaTeXCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ To emit `\mycommand` potentially with arguments and optionals.
```
"
Class {
#name : #MicLaTeXCommand,
#superclass : #MicLaTeXBrush,
#category : #'Microdown-LaTeXExporter'
#name : 'MicLaTeXCommand',
#superclass : 'MicLaTeXBrush',
#category : 'Microdown-LaTeXExporter',
#package : 'Microdown-LaTeXExporter'
}

{ #category : #accessing }
{ #category : 'accessing' }
MicLaTeXCommand >> name: aString [

stream
Expand Down
Loading

0 comments on commit a3c5cd6

Please sign in to comment.