Skip to content

Commit

Permalink
refactor lookForNewBlockStarts, fix HTM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marie Fischer committed Jul 27, 2021
1 parent 1a0e31c commit 63e156d
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parsing
canContainFurtherBlocks

^ true
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"beClosed" : "jh 7/25/2021 21:04",
"beOpen" : "jh 7/25/2021 21:04",
"canContain:" : "mf 7/4/2021 13:55",
"canContainFurtherBlocks" : "mf 7/27/2021 11:50",
"container" : "mf 7/4/2021 13:57",
"container:" : "LL 7/12/2021 21:54",
"continue:" : "LL 7/12/2021 21:55",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parsing
canContainFurtherBlocks

^ false
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"acceptsLines" : "mf 7/4/2021 14:36",
"adaptToDocumentWith:" : "jh 7/21/2021 13:52",
"applyStylingWith:" : "jh 7/13/2021 15:26",
"canContainFurtherBlocks" : "mf 7/27/2021 11:51",
"continue:" : "mf 7/26/2021 23:40",
"finalize:" : "jh 7/22/2021 13:57",
"firstLineSize" : "jh 7/14/2021 14:54",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"inlineElements:" : "jh 7/26/2021 12:47",
"lastChild" : "mf 7/4/2021 14:29",
"leafBlocks" : "LL 6/16/2021 14:57",
"needsInlineParsing" : "jh 7/15/2021 17:41",
"needsInlineParsing" : "mf 7/27/2021 11:50",
"treeRepresentation" : "jh 7/26/2021 13:00" } }
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ createNew: aParsingState

| listData |
(self checkBlankAfterParagraph: aParsingState)
ifTrue: [^0].
ifTrue: [^ 0].
(listData := self parseWithState: aParsingState)
ifNil: [^0].
ifNil: [^ 0].
"a list item that follows a Paragraph may only begin with a 1"
aParsingState container class = MarkdownParagraph
& (listData at: #isOrdered) ==> ((listData at: #start) = 1)
ifFalse: [^0].
aParsingState container class = MarkdownParagraph & (listData at: #isOrdered)
==> ((listData at: #start) = 1)
ifFalse: [^ 0].
aParsingState newBlock:
((self newFrom: listData)
startPosition: aParsingState charPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"class" : {
"checkBlankAfterParagraph:" : "jh 7/14/2021 21:58",
"createNew:" : "jh 7/14/2021 22:13",
"createNew:" : "mf 7/27/2021 12:48",
"defaultFontColors" : "mf 7/1/2021 13:42",
"defaultFontSizes" : "mf 7/1/2021 13:42",
"maxPaddingWith:" : "mf 7/4/2021 14:22",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
phase 2
lookForNewBlockStarts

self state oldTip class = MarkdownFencedCodeBlock
ifTrue: [^ self processRemainderOfLine].
self state oldTip canContainFurtherBlocks
ifFalse: [^ self processRemainderOfLine].
self blockChecklist do: [:class || result |
result := class createNew: self state.

result = 1 "matched container block - try again for the rest of the line"
ifTrue: [self incorporateNewBlock.
^ self lookForNewBlockStarts].

result = 2 "matched leaf block - we are done"
ifTrue: [self incorporateNewBlock.
^ self processRemainderOfLine]].

^ self processRemainderOfLine
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"incorporateNewBlock" : "mf 7/4/2021 14:54",
"initialize" : "mf 7/4/2021 14:50",
"lazyContinuation" : "mf 7/6/2021 12:10",
"lookForNewBlockStarts" : "mf 7/27/2021 00:22",
"lookForNewBlockStarts" : "mf 7/27/2021 11:51",
"parse:" : "LL 7/13/2021 18:23",
"parseInline:" : "jh 7/24/2021 14:38",
"parseInline:with:" : "jh 7/26/2021 21:04",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ testConvertOrderdList
parser parse: '1. ListItem 1', Character cr, '2. ListItem 2', Character cr,'3. ListItem 3'.
output := (htmlConverter convertToHtml: parsingState document).
listHtml := '<ol>
<li><p>ListItem 1</p></li>
<li><p>ListItem 2</p></li>
<li><p>ListItem 3</p></li>
<li><p>ListItem 1</p>
</li>
<li><p>ListItem 2</p>
</li>
<li><p>ListItem 3</p>
</li>
</ol>'.
expectedOutput := self fullHtmlDocumentFrom: listHtml.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ testConvertOrderdListsNested
parser
parse: '1. Level 1
2. Level 1
1. Level 2
2. Level 2
1. Level 3
3. Level 2
4. Level 2
1. Level 2
2. Level 2
1. Level 3
3. Level 2
4. Level 2
3. Level 1'.
output := (htmlConverter convertToHtml: parsingState document).
listHtml := '<ol>
<li><p>Level 1</p></li>
<li><p>Level 1</p>
</li>
<li><p>Level 1</p>
<ol>
<li><p>Level 2</li>
<li><p>Level 2</p>
</li>
<li><p>Level 2</p>
<ol>
<li><p>Level 3</p></li>
<li><p>Level 3</p>
</li>
</ol>
</li>
<li><p>Level 2</p></li>
<li><p>Level 2</p></li>
<li><p>Level 2</p>
</li>
<li><p>Level 2</p>
</li>
</ol>
</li>
<li><p>Level 1</p></li>
<li><p>Level 1</p>
</li>
</ol>'.
expectedOutput := self fullHtmlDocumentFrom: listHtml.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ testConvertUnorderdList
parser parse: '* ListItem 1', Character cr, '* ListItem 2', Character cr,'* ListItem 3'.
output := (htmlConverter convertToHtml: parsingState document).
listHtml := '<ul>
<li>ListItem 1</li>
<li>ListItem 2</li>
<li>ListItem 3</li>
<li><p>ListItem 1</p>
</li>
<li><p>ListItem 2</p>
</li>
<li><p>ListItem 3</p>
</li>
</ul>'.
expectedOutput := self fullHtmlDocumentFrom: listHtml.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ testConvertUnorderdListsNested
parser
parse: '* Level 1
* Level 1
- Level 2
- Level 2
- Level 3
- Level 2
- Level 2
- Level 2
- Level 2
- Level 3
- Level 2
- Level 2
* Level 1'.
output := (htmlConverter convertToHtml: parsingState document).
listHtml := '<ul>
<li>Level 1</li>
<li>Level 1
<li><p>Level 1</p>
</li>
<li><p>Level 1</p>
<ul>
<li>Level 2</li>
<li>Level 2
<li><p>Level 2</p>
</li>
<li><p>Level 2</p>
<ul>
<li>Level 3</li>
<li><p>Level 3</p>
</li>
</ul>
</li>
<li>Level 2</li>
<li>Level 2</li>
<li><p>Level 2</p>
</li>
<li><p>Level 2</p>
</li>
</ul>
</li>
<li>Level 1</li>
<li><p>Level 1</p>
</li>
</ul>'.
expectedOutput := self fullHtmlDocumentFrom: listHtml.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"testConvertLink" : "jh 7/8/2021 14:14",
"testConvertLinkWithAutoLink" : "jh 7/8/2021 14:14",
"testConvertNestedHtml" : "jh 7/8/2021 14:14",
"testConvertOrderdList" : "mf 7/22/2021 23:37",
"testConvertOrderdListsNested" : "mf 7/22/2021 23:40",
"testConvertOrderdList" : "mf 7/27/2021 11:54",
"testConvertOrderdListsNested" : "mf 7/27/2021 12:55",
"testConvertParagraph" : "jh 7/8/2021 14:15",
"testConvertParagraphComplex" : "mf 7/22/2021 23:36",
"testConvertStrikeText" : "jh 7/8/2021 14:15",
"testConvertStyleSettings" : "jh 7/1/2021 12:30",
"testConvertThematicBreak" : "jh 7/8/2021 14:15",
"testConvertToRGBA" : "hsl 6/27/2020 16:38",
"testConvertUnorderdList" : "jh 7/8/2021 14:15",
"testConvertUnorderdListsNested" : "jh 7/8/2021 14:15" } }
"testConvertUnorderdList" : "mf 7/27/2021 12:55",
"testConvertUnorderdListsNested" : "mf 7/27/2021 12:57" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"class" : {
},
"instance" : {
"closeBoxOfSettings" : "7/21/2021 13:44:50",
"colorOfFirstCharInText" : "7/21/2021 13:44:50",
"currentShownStylerMorphs" : "7/21/2021 13:44:50",
"closeBoxOfSettings" : " 7/21/2021 13:44:50",
"colorOfFirstCharInText" : " 7/21/2021 13:44:50",
"currentShownStylerMorphs" : " 7/21/2021 13:44:50",
"setUp" : "jh 6/1/2021 21:34",
"tearDown" : "JE 7/16/2021 19:53",
"testApplyChanges" : "jh 6/1/2021 21:33",
"testCancelChanges" : "JE 6/1/2021 10:43",
"testCancelChangesOnClosing" : "jh 5/29/2021 12:44",
"testCloseMarkdownOptions" : "jh 5/29/2021 12:48",
"testCreateMarkdownOptions" : "jh 5/29/2021 12:48",
"testLabel" : "7/21/2021 13:44:50",
"testLabelForCategories" : "7/21/2021 13:44:50",
"testLabel" : " 7/21/2021 13:44:50",
"testLabelForCategories" : " 7/21/2021 13:44:50",
"testNoWindowIsDefaultMorph" : "jh 5/29/2021 12:55",
"testOpenWindowIfNotPresent" : "jh 5/29/2021 12:49",
"testShowStylerMorphsGeneral" : "7/21/2021 13:44:50",
"testShowStylerMorphsHeadings" : "7/21/2021 13:44:50",
"testShowStylerMorphsLists" : "7/21/2021 13:44:50",
"testShowStylerMorphsGeneral" : " 7/21/2021 13:44:50",
"testShowStylerMorphsHeadings" : " 7/21/2021 13:44:50",
"testShowStylerMorphsLists" : " 7/21/2021 13:44:50",
"testUnregisterEditor" : "jh 5/29/2021 13:11",
"testVersionUpdate" : "JE 7/16/2021 19:54" } }

0 comments on commit 63e156d

Please sign in to comment.