Skip to content

Commit

Permalink
Merge pull request #35 from hpi-swa-teaching/refactor/attributes
Browse files Browse the repository at this point in the history
Simplifies TextAttributes
  • Loading branch information
felix-gohla committed Jul 25, 2019
2 parents 31c38c5 + d3c2828 commit dd20ec7
Show file tree
Hide file tree
Showing 94 changed files with 321 additions and 326 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I represent a Markdown emphasis over a range of characters. The applied styling is expressed through my textAttribute.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
instance creation
from: startPosition to: endPosition

^ self new
textAttribute: TextEmphasis italic;
setFrom: startPosition to: endPosition;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
instance creation
strongFrom: startPosition to: endPosition

^ self new
textAttribute: TextEmphasis bold;
setFrom: startPosition to: endPosition;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
setFrom: anInteger to: anotherInteger

startPosition := anInteger.
endPosition := anotherInteger
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
textAttribute: aTextAttribute

textAttribute := aTextAttribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
textAttribute

^ textAttribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"class" : {
"from:to:" : "kgr 7/23/2019 11:27",
"strongFrom:to:" : "kgr 7/23/2019 11:19" },
"instance" : {
"endPosition" : "fgo 5/21/2019 15:36",
"setFrom:to:" : "fgo 7/10/2019 15:16",
"startPosition" : "fgo 5/21/2019 15:36",
"textAttribute" : "fgo 7/10/2019 14:39",
"textAttribute:" : "fgo 7/10/2019 14:39" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
],
"classvars" : [
],
"commentStamp" : "fgo 5/21/2019 15:40",
"commentStamp" : "fgo 7/11/2019 15:37",
"instvars" : [
"startPosition",
"endPosition" ],
"name" : "MarkdownAttribute",
"endPosition",
"textAttribute" ],
"name" : "MarkdownEmphasis",
"pools" : [
],
"super" : "Object",
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
attributes
delimiterLengthForAttributeWith: aMarkdownEmphasisDelimiter
delimiterLengthForEmphasisWith: aMarkdownEmphasisDelimiter

^ {self length. aMarkdownEmphasisDelimiter length. self boldLength} min
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
attributes
emphasisFrom: start to: end delimiterLength: aLength

aLength = 1
ifTrue: [^ MarkdownEmphasis from: start to: end]
ifFalse: [^ MarkdownEmphasis strongFrom: start to: end]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
attributes
emphasisStartingAt: openingEmphasisDelimiter

| delimiterLength start end |
delimiterLength := self delimiterLengthForEmphasisWith: openingEmphasisDelimiter.
start := openingEmphasisDelimiter endPosition - delimiterLength + 1.
end := self startPosition + delimiterLength - 1.
^ self emphasisFrom: start to: end delimiterLength: delimiterLength

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"class" : {
"mayBeginWith:" : "jst 6/26/2019 14:35" },
"instance" : {
"attributeStartingAt:" : "jko 5/23/2019 12:44",
"attributeTypeFor:" : "jko 5/21/2019 23:34",
"boldLength" : "fgo 5/10/2019 15:54",
"cutFromEnd:" : "fgo 5/21/2019 15:22",
"cutFromStart:" : "fgo 5/21/2019 15:20",
"decideLeftFlankingForPreceding:following:" : "jst 6/28/2019 14:30",
"decideRightFlankingForPreceding:following:" : "jst 6/28/2019 14:35",
"delimiterLengthForAttributeWith:" : "jko 5/23/2019 12:44",
"delimiterLengthForEmphasisWith:" : "jst 7/25/2019 14:28",
"emphasisFrom:to:delimiterLength:" : "jst 7/25/2019 14:12",
"emphasisStartingAt:" : "jst 7/25/2019 14:28",
"isCloser" : "jko 5/6/2019 16:20",
"isDelimiter" : "fgo 5/4/2019 21:08",
"isExtendableWith:" : "jst 6/28/2019 15:15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"asText" : "jko 6/25/2019 20:40",
"font" : "kgr 6/10/2019 13:39",
"fontSize" : "kgr 6/10/2019 13:40",
"fontSizes" : "kgr 6/10/2019 13:41",
"fontSizes" : "fgo 7/23/2019 13:53",
"isExtendableWith:" : "jko 7/4/2019 17:03",
"level" : "jst 5/13/2019 15:24",
"prefix" : "jst 5/13/2019 15:29",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
styling
add: aCollectionOfMarkdownAttributes to: aText
add: aCollectionOfMarkdownEmphases to: aText

aCollectionOfMarkdownAttributes do: [:attribute |
attribute textAttributes do: [:textAttribute |
aText
addAttribute: textAttribute
from: attribute startPosition
to: attribute endPosition]]
aCollectionOfMarkdownEmphases do: [:emphasis |
aText
addAttribute: emphasis textAttribute
from: emphasis startPosition
to: emphasis endPosition]

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ initialize-release
clean

self
attributes: OrderedCollection new;
emphases: OrderedCollection new;
tokens: OrderedCollection new
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing-private
emphases: aCollectionOfMarkdownEmphases

emphases := aCollectionOfMarkdownEmphases
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing-private
emphases

^ emphases
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ parse: aString
clean;
tokenize: aString;
interpretTokens.
^ self attributes
^ self emphases

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ parsing
process: opener and: closer

| length |
self attributes add: (closer attributeStartingAt: opener).
self emphases add: (closer emphasisStartingAt: opener).
self removeDelimitersBetween: opener and: closer.
length := closer delimiterLengthForAttributeWith: opener.
length := closer delimiterLengthForEmphasisWith: opener.
self cutOpener: opener to: length.
^ self cutCloser: closer to: length
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"class" : {
},
"instance" : {
"add:to:" : "jko 6/21/2019 14:36",
"attributes" : "jko 5/16/2019 17:07",
"attributes:" : "jko 5/16/2019 17:08",
"clean" : "jko 5/23/2019 14:44",
"add:to:" : "jst 7/25/2019 14:32",
"clean" : "jst 7/25/2019 14:07",
"createTokensFrom:" : "jst 6/29/2019 16:10",
"cutCloser:to:" : "lpf 5/23/2019 10:27",
"cutOpener:to:" : "lpf 5/23/2019 10:28",
"emphases" : "jst 7/25/2019 14:08",
"emphases:" : "jst 7/25/2019 14:07",
"findOpenerFor:ifFound:" : "jko 5/16/2019 17:34",
"followingCharacterOf:" : "jst 6/26/2019 23:26",
"initialize" : "jst 6/29/2019 16:09",
"interpretTokens" : "jko 6/21/2019 14:00",
"parse:" : "jko 6/21/2019 14:45",
"parse:" : "jst 7/25/2019 14:08",
"precedingCharacterOf:" : "jst 6/26/2019 23:26",
"privateFormat:" : "jst 6/28/2019 14:02",
"privateStyle:" : "jko 6/25/2019 22:04",
"process:and:" : "jko 5/23/2019 14:38",
"process:and:" : "jst 7/25/2019 14:28",
"processAdjacentTokens" : "jst 6/29/2019 16:11",
"removeDelimitersBetween:and:" : "lpf 5/23/2019 10:28",
"reset" : "jst 6/28/2019 14:03",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"commentStamp" : "fgo 5/21/2019 15:43",
"instvars" : [
"tokens",
"attributes" ],
"emphases" ],
"name" : "MarkdownInlineTextStyler",
"pools" : [
],
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*MarkdownEditor-Tests
= aMarkdownEmphasis

^ self endPosition = aMarkdownEmphasis endPosition
and: [self startPosition = aMarkdownEmphasis startPosition]
and: [self textAttribute = aMarkdownEmphasis textAttribute]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*MarkdownEditor-Tests
hash

^ (self startPosition hash bitXor: self endPosition hash)
bitXor: self textAttribute hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
},
"instance" : {
"=" : "kgr 7/23/2019 12:07",
"hash" : "kgr 7/23/2019 12:26" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "MarkdownEmphasis" }
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests - matching
testBoldAttributeDelimiterLength
testBoldEmphasisDelimiterLength

| opener closer |
closer := MarkdownEmphasisDelimiter new content: '**'; yourself.
opener := MarkdownEmphasisDelimiter new content: '**'; yourself.

self assert: 2 equals: (closer delimiterLengthForAttributeWith: opener)
self assert: 2 equals: (closer delimiterLengthForEmphasisWith: opener)

Loading

0 comments on commit dd20ec7

Please sign in to comment.