Skip to content

Commit

Permalink
- implement alternative syntax for italic and bold
Browse files Browse the repository at this point in the history
- added more tests
  • Loading branch information
Finn Schöllkopf committed May 26, 2021
1 parent 423a656 commit 439918d
Show file tree
Hide file tree
Showing 41 changed files with 109 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
instance creation
newFor: aString at: startPosition

^ self new
content: aString;
startPosition: startPosition;
delimiter: (aString at: 1);
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
delimiter: anObject

delimiter := anObject.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
delimiter

^ delimiter
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
testing
matches: aMarkdownEmphasisDelimiter
matches: aMarkdownEmphasisDelimiter

^ aMarkdownEmphasisDelimiter type = self type
and: [((self isOpener and: [aMarkdownEmphasisDelimiter isCloser])
or: [self isCloser and: [aMarkdownEmphasisDelimiter isOpener]])
and: [(self isOpenerAndCloser or: [aMarkdownEmphasisDelimiter isOpenerAndCloser])
==> [((self length + aMarkdownEmphasisDelimiter length) isDivisibleBy: 3)
==> [(self length isDivisibleBy: 3)
and: [aMarkdownEmphasisDelimiter length isDivisibleBy: 3]]]]]
^ (self matchesType: aMarkdownEmphasisDelimiter)
and: [(self matchesDelimiter: aMarkdownEmphasisDelimiter)
and: [self matchesOpenClose: aMarkdownEmphasisDelimiter]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
matchesDelimiter: aMarkdownEmphasisDelimiter

^ aMarkdownEmphasisDelimiter delimiter = self delimiter
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
testing
matchesOpenClose: aMarkdownEmphasisDelimiter

^ (self matchesOpenerOrCloser: aMarkdownEmphasisDelimiter)
and: [self matchesOpenerAndCloser: aMarkdownEmphasisDelimiter]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
testing
matchesOpenerAndCloser: aMarkdownEmphasisDelimiter

^ (self isOpenerAndCloser
or: [aMarkdownEmphasisDelimiter isOpenerAndCloser])
==> [(self length + aMarkdownEmphasisDelimiter length isDivisibleBy: 3)
==> [(self length isDivisibleBy: 3)
and: [aMarkdownEmphasisDelimiter length isDivisibleBy: 3]]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
testing
matchesOpenerOrCloser: aMarkdownEmphasisDelimiter

^ (self isOpener
and: [aMarkdownEmphasisDelimiter isCloser])
or: [self isCloser
and: [aMarkdownEmphasisDelimiter isOpener]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
matchesType: aMarkdownEmphasisDelimiter

^ aMarkdownEmphasisDelimiter type = self type
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
punctuationCharacters

self subclassResponsibility
^ #($! $" $# $$ $% $& $' $( $) $* $+ $, $- $. $/ $: $; $< $= $> $? $@ $[ $] $\ $^ $_ $` ${ $} $| $~)
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"class" : {
"mayBeginWith:" : "F.S 5/6/2021 15:15" },
"mayBeginWith:" : "F.S 5/6/2021 15:15",
"newFor:at:" : "F.S 5/26/2021 15:53" },
"instance" : {
"decideLeftFlankingForPreceding:following:" : "azi 8/6/2020 08:06",
"decideRightFlankingForPreceding:following:" : "azi 8/6/2020 08:06",
"delimiter" : "F.S 5/26/2021 15:52",
"delimiter:" : "F.S 5/26/2021 15:52",
"delimiterLengthForEmphasisWith:" : "jh 5/7/2021 11:01",
"emphasisFrom:to:delimiterLength:" : "jh 5/7/2021 11:02",
"emphasisStartingAt:" : "F.S 5/6/2021 15:02",
Expand All @@ -16,7 +19,12 @@
"isOpenerAndCloser" : "jko 5/6/2019 16:20",
"isRightFlanking" : "jko 5/23/2019 12:06",
"isRightFlanking:" : "jko 5/23/2019 12:43",
"matches:" : "F.S 5/6/2021 15:17",
"punctuationCharacters" : "jh 5/7/2021 11:02",
"matches:" : "F.S 5/26/2021 16:00",
"matchesDelimiter:" : "F.S 5/26/2021 15:55",
"matchesOpenClose:" : "F.S 5/26/2021 15:58",
"matchesOpenerAndCloser:" : "F.S 5/26/2021 15:57",
"matchesOpenerOrCloser:" : "F.S 5/26/2021 15:57",
"matchesType:" : "F.S 5/26/2021 15:55",
"punctuationCharacters" : "F.S 5/26/2021 16:12",
"setPreceding:following:" : "jst 6/29/2019 16:11",
"whitespaceCharacters" : "MK 7/3/2020 21:07" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
],
"classvars" : [
],
"commentStamp" : "fgo 5/21/2019 15:45",
"commentStamp" : "<historical>",
"instvars" : [
"isLeftFlanking",
"isRightFlanking" ],
"isRightFlanking",
"delimiter" ],
"name" : "MarkdownEmphasisDelimiter",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"convertUnorderedList:" : "cg 6/29/2020 17:57",
"convertUnorderedListStyleSettings:" : "MK 7/9/2020 15:42",
"createNested" : "hsl 7/12/2020 13:53",
"createNestedHTML:" : "F.S 5/26/2021 14:26",
"createNestedHTML:" : "F.S 5/26/2021 16:49",
"labelAsCssDescriptor:" : "azi 8/6/2020 08:09" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
mayBeginWith: aCharacter

^ aCharacter = $*
^ (aCharacter = $*) or: [aCharacter = $_]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
isExtendableWith: aCharacter

^ aCharacter = $*
^ aCharacter = self delimiter

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"class" : {
"mayBeginWith:" : "F.S 5/6/2021 15:19" },
"mayBeginWith:" : "F.S 5/26/2021 15:42" },
"instance" : {
"boldLength" : "jh 5/7/2021 10:46",
"delimiterLengthForEmphasisWith:" : "jh 5/7/2021 10:46",
"emphasisFrom:to:delimiterLength:" : "F.S 5/6/2021 15:20",
"isExtendableWith:" : "F.S 5/6/2021 15:21",
"punctuationCharacters" : "F.S 5/6/2021 15:22",
"isExtendableWith:" : "F.S 5/26/2021 15:47",
"type" : "F.S 5/6/2021 15:36" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"commentStamp" : "",
"instvars" : [
],
"delimiter" ],
"name" : "MarkdownItalicBoldDelimiter",
"pools" : [
],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
"emphasisFrom:to:delimiterLength:" : "F.S 5/6/2021 15:27",
"isExtendableWith:" : "F.S 5/6/2021 15:30",
"neededLength" : "jh 5/7/2021 10:47",
"punctuationCharacters" : "F.S 5/6/2021 15:24",
"type" : "F.S 5/6/2021 15:36" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertBasicParagraph

| paragraph html |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertBlockList

| blocks html expectedHtml |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertBlockquote

| blockquote html |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertBoldParagraph

| paragraph html result |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertCodeBlock

| codeBlock html |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertCommentBlock

| comment html |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertHeadings

| heading html |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertItalicParagraph

| paragraph html result |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertLink

| link |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertMixedDelimiters

| paragraph html result |
Expand All @@ -10,6 +10,6 @@ testConvertMixedDelimiters

paragraph := self createBlockFrom: '**bold _bold & italic_ bold**'.
html := htmlConverter convertParagraph: paragraph.
self assert: result equals: html.
self assert: result equals: html


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests - inline
testConvertMixedDelimiters2

| paragraph html result |

result := '<p>_<em>italic</em><strong>bold</strong></p>', Character cr.
paragraph := self createBlockFrom: '_*italic*__bold__'.
html := htmlConverter convertParagraph: paragraph.
self assert: result equals: html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests - inline
testConvertMixedDelimiters3

| paragraph html result |

result := '<p><em><em>italic</em><strong>bold</strong></em></p>', Character cr.
paragraph := self createBlockFrom: '_*italic*__bold___'.
html := htmlConverter convertParagraph: paragraph.
self assert: result equals: html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertMixedDelimitersFailure

| paragraph html result |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertMixedItalic

| paragraph html result |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertOrderedList
"not implemented yet"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - inline
testConvertStrikeParagraph

| paragraph html |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - color
testConvertToRGBA

| color convertedColor |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests
tests - blocks
testConvertUnorderedList

| block html expectedHtml |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"testConvertHeadings" : "MK 6/21/2020 17:42",
"testConvertItalicParagraph" : "F.S 5/26/2021 15:21",
"testConvertLink" : "hsl 7/1/2020 03:35",
"testConvertMixedDelimiters" : "F.S 5/26/2021 15:34",
"testConvertMixedDelimiters" : "F.S 5/26/2021 16:22",
"testConvertMixedDelimiters2" : "F.S 5/26/2021 16:23",
"testConvertMixedDelimiters3" : "F.S 5/26/2021 16:24",
"testConvertMixedDelimitersFailure" : "F.S 5/26/2021 15:34",
"testConvertMixedItalic" : "F.S 5/26/2021 15:35",
"testConvertOrderedList" : "cg 6/30/2020 00:09",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests - recognition
testIsExtendableWithAnyCharacterExceptAsterisk

(Character allByteCharacters copyWithoutAll: {$* . $[ . $] . $( . $) . $~})
(Character allByteCharacters copyWithoutAll: {$*. $[. $]. $(. $). $~. $_})
do: [:character | | token |
token := MarkdownString newFor: 'a' at: 1.
self assert: (token isExtendableWith: character)]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"testEndPosition" : "jst 6/26/2019 14:29",
"testExtend" : "jst 6/29/2019 16:10",
"testIsCloser" : "hsl 7/1/2020 12:36",
"testIsExtendableWithAnyCharacterExceptAsterisk" : "F.S 5/6/2021 16:27",
"testIsExtendableWithAnyCharacterExceptAsterisk" : "F.S 5/26/2021 16:05",
"testIsNotExtendableWithAsterisk" : "jst 6/28/2019 15:13",
"testIsOpener" : "MK 7/5/2020 21:32",
"testStartPosition" : "jst 6/26/2019 14:28",
Expand Down

0 comments on commit 439918d

Please sign in to comment.