Skip to content

Commit

Permalink
Merge pull request #763 from Gabriel-Darbord/762-RichTextComposer-add…
Browse files Browse the repository at this point in the history
…s-blank-lines-to-nested-lists

Fix #762: avoid empty lines in nested lists
  • Loading branch information
jecisc authored Jun 2, 2024
2 parents 2833225 + 7c62f57 commit 577ace6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,20 +486,18 @@ MicRichTextComposerTest >> testNestedMixedList [
]

{ #category : 'skipped tests' }
MicRichTextComposerTest >> testNestedMixedListNoEmptyLinesEfterSubLists [
MicRichTextComposerTest >> testNestedMixedListNoEmptyLinesAfterSubLists [

| source output |
source :=
'- item 1
1. sub item 1.1
- item 2
2. sub item 2.1
2. sub item 2.2
- sub item 2.1.1
- item 3'.
output := (self richTextForString: source) asString trim.
self assert: output lines size equals: 6


]

{ #category : 'skipped tests' }
Expand Down Expand Up @@ -543,7 +541,7 @@ And this is just an other paragraph'.
]

{ #category : 'tests - list' }
MicRichTextComposerTest >> testNosuperfluousNewLines [
MicRichTextComposerTest >> testNoSuperfluousNewLines [

| source richText expected |
source := 'This is **bold**'.
Expand Down Expand Up @@ -584,6 +582,18 @@ MicRichTextComposerTest >> testOrderedNestedList [

]

{ #category : 'tests' }
MicRichTextComposerTest >> testOrderedNestedListNoEmptyLinesAfterSubLists [
| source output |
source := '
1. First item
2. Second item
3. Third item
4. Fourth item'.
output := (self richTextForString: source) asString trim.
self assert: output lines size equals: 4.
]

{ #category : 'tests - paragraph' }
MicRichTextComposerTest >> testParagraphNotFormat [

Expand Down Expand Up @@ -686,6 +696,18 @@ MicRichTextComposerTest >> testUnorderedList [
self assert: (runs at: 29) first amount equals: 2.
]

{ #category : 'tests' }
MicRichTextComposerTest >> testUnorderedNestedListNoEmptyLinesAfterSubLists [
| source output |
source := '
- First item
- Second item
- Third item
- Fourth item'.
output := (self richTextForString: source) asString trim.
self assert: output lines size equals: 4.
]

{ #category : 'tests - format' }
MicRichTextComposerTest >> underlineFormat [
^ TextEmphasis underlined
Expand Down
6 changes: 3 additions & 3 deletions src/Microdown-RichTextComposer/MicRichTextComposer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ MicRichTextComposer >> visitOrderedList: aList [
put: (self textStyler counterFor: counter atLevel: self level).
counter := counter + 1 ].
super visitOrderedList: aList ].
canvas newLine.
canvas newLineIfNotAlready.
aList nestedLevel = 1 ifTrue: [ canvas << textStyler interBlockSpacing]
]

Expand Down Expand Up @@ -771,6 +771,6 @@ MicRichTextComposer >> visitUnorderedList: aList [
propertyAt: #bullet
put: (self textStyler bulletForLevel: self level) ].
super visitUnorderedList: aList ].
canvas newLine.
aList nestedLevel = 1 ifTrue: [ canvas << textStyler interBlockSpacing]
canvas newLineIfNotAlready.
aList nestedLevel = 1 ifTrue: [ canvas << textStyler interBlockSpacing ]
]

0 comments on commit 577ace6

Please sign in to comment.