Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

883 raw annotated annotation paragraph a block looks bogus #888

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@ MicTextualMicrodownExporter >> visitAnchorReference: anAnchorReference [
{ #category : 'visit - block' }
MicTextualMicrodownExporter >> visitAnnotated: anAnnotated [

builder
annotated: anAnnotated label
paragraph: [ super visitAnnotated: anAnnotated ]
| textualExporter |
textualExporter := MicTextualMicrodownExporter new.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi est ce que tu recrees une instance de la meme classe ? car tu pourrais utiliser self.
Est ce que c'est parce que tu veux jeter le contenu?
La variable string me semble pas etre utilisee.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour le builder textWithBracket: j'ai besoin d'un String comme paramétre
Comme je n'avait que les enfants de anAnnotated, j'ai utilisé un nouveaux MicTextualMicrodownExporter et je l'ai fait visité tout les enfants afin de produire le String.
Le probléme d'utiliser self comme visiteur des enfants de anAnnotated, et qu'il va ajouter automatiquement dans son stream le contenu de ce qu'il va visiter, sans ajouter le charater '>' au début
Pour la variable String, j'ai oublié de la supprimer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok je comprends maintenant je me demandais si cela marchait avec plusieurs lignes.
J'imagine que tu as des tests.

anAnnotated children do: [ :each | each accept: textualExporter ].

builder
annotated: anAnnotated label
paragraph: [ builder textWithBracket: textualExporter contents ]
]

{ #category : 'visit - format' }
Expand Down
17 changes: 15 additions & 2 deletions src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,21 @@ MicMicrodownTextualBuilderTest >> testAnchorReference [
{ #category : 'tests - anchor' }
MicMicrodownTextualBuilderTest >> testAnnotated [

self assert: (builder annotated: 'anAnnotation' paragraph: [ builder text: 'anAnnotatedParagraph' ]) contents equals: '>[!anAnnotation]
> anAnnotatedParagraph', String cr, String cr
self
assert: (builder
annotated: 'anAnnotation'
paragraph: [ builder textWithBracket: 'anAnnotatedParagraph' ]) contents
equals: '>[!anAnnotation]
> anAnnotatedParagraph' , String cr , String cr
]

{ #category : 'tests - anchor' }
MicMicrodownTextualBuilderTest >> testAnnotatedWithMultipleLine [

self assert: (builder annotated: 'anAnnotation' paragraph: [ builder textWithBracket: 'anAnnotatedParagraph
an Another Line']) contents equals: '>[!anAnnotation]
> anAnnotatedParagraph
> an Another Line', String cr, String cr
]

{ #category : 'tests - anchor' }
Expand Down
18 changes: 14 additions & 4 deletions src/Microdown/MicMicrodownTextualBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,7 @@ MicMicrodownTextualBuilder >> rawAnnotated: annotation paragraph: aBlock [
raw: annotation;
raw: AnnotatedParagraphClosingMarkup ;
raw: Character cr;
raw: $>;
raw: String space;
rawParagraph: aBlock;
raw: Character cr
rawParagraph: aBlock


]
Expand Down Expand Up @@ -628,6 +625,19 @@ MicMicrodownTextualBuilder >> strike: aBlock [
self raw: StrikeMarkup.
]

{ #category : 'writing during' }
MicMicrodownTextualBuilder >> textWithBracket: aString [

| lines |
lines := aString substrings: String crlf.
lines do: [ :each |
self
raw: $>;
raw: String space;
raw: each;
raw: Character cr ]
]

{ #category : 'element - list' }
MicMicrodownTextualBuilder >> unorderedListDuring: aBlockClosure [
"For list we do not emit empty line at the end because we do not want to force the creation of a paragraph
Expand Down
Loading