Skip to content

Commit

Permalink
Rename more occurences of attribute to emphasis
Browse files Browse the repository at this point in the history
Note: While it may not be the most ideal convention, we try to use
ItalicEmphasis and StrongEmphasis in the tests to differentiate between
"normal" *emphasis* and **strong emphasis**


Co-authored-by: Kira Grammel <kira.grammel@student.hpi.de>
  • Loading branch information
pixunil and kiragrammel committed Jul 25, 2019
1 parent 6c9fba9 commit d3c2828
Show file tree
Hide file tree
Showing 47 changed files with 139 additions and 119 deletions.

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" : {
"attributeFrom:to:delimiterLength:" : "kgr 7/23/2019 13:24",
"attributeStartingAt:" : "kgr 7/23/2019 11:37",
"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
@@ -1,8 +1,8 @@
styling
add: aCollectionOfMarkdownAttributes to: aText
add: aCollectionOfMarkdownEmphases to: aText

aCollectionOfMarkdownAttributes do: [:attribute |
aText
addAttribute: attribute 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:" : "fgo 7/10/2019 15:25",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ testBoldEmphasisDelimiterLength
closer := MarkdownEmphasisDelimiter new content: '**'; yourself.
opener := MarkdownEmphasisDelimiter new content: '**'; yourself.

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testDifferentDelimitersCreateBoldEmphasis
opener := MarkdownEmphasisDelimiter newFor: '****' at: 1.
closer := MarkdownEmphasisDelimiter newFor: '***' at: 6.

emphasis := closer attributeStartingAt: opener.
emphasis := closer emphasisStartingAt: opener.
self assert: TextEmphasis bold equals: emphasis textAttribute.
self assert: 3 equals: emphasis startPosition.
self assert: 7 equals: emphasis endPosition

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ testItalicEmphasisDelimiterLength
closer := MarkdownEmphasisDelimiter new content: '*'; yourself.
opener := MarkdownEmphasisDelimiter new content: '*'; yourself.

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ testMaxDelimiterLengthIs2
closer := MarkdownEmphasisDelimiter new content: '***'; yourself.
opener := MarkdownEmphasisDelimiter new content: '****'; yourself.

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testSameDelimitersCreateBoldEmphasis
opener := MarkdownEmphasisDelimiter newFor: '**' at: 1.
closer := MarkdownEmphasisDelimiter newFor: '**' at: 5.

emphasis := closer attributeStartingAt: opener.
emphasis := closer emphasisStartingAt: opener.
self assert: TextEmphasis bold equals: emphasis textAttribute.
self assert: 1 equals: emphasis startPosition.
self assert: 6 equals: emphasis endPosition
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testSameDelimitersCreateItalicEmphasis
opener := MarkdownEmphasisDelimiter newFor: '*' at: 1.
closer := MarkdownEmphasisDelimiter newFor: '*' at: 5.

emphasis := closer attributeStartingAt: opener.
emphasis := closer emphasisStartingAt: opener.
self assert: TextEmphasis italic equals: emphasis textAttribute.
self assert: 1 equals: emphasis startPosition.
self assert: 5 equals: emphasis endPosition
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
"class" : {
},
"instance" : {
"testBoldEmphasisDelimiterLength" : "kgr 7/23/2019 11:50",
"testBoldEmphasisDelimiterLength" : "jst 7/25/2019 14:28",
"testClosingDelimiterIsCloser" : "jko 5/23/2019 12:43",
"testCut1FromEnd" : "kgr 5/27/2019 15:35",
"testCut1FromStart" : "kgr 5/27/2019 15:35",
"testCut2FromEnd" : "kgr 5/27/2019 15:35",
"testCut2FromStart" : "kgr 5/27/2019 15:35",
"testDifferentDelimitersCreateBoldEmphasis" : "fgo 7/24/2019 10:09",
"testEmphasisAttributeItalic" : "kgr 7/23/2019 13:12",
"testDifferentDelimitersCreateBoldEmphasis" : "jst 7/25/2019 14:12",
"testEmphasisDelimiterAsString" : "jst 6/26/2019 15:08",
"testEndPosition" : "jst 6/26/2019 14:25",
"testExtend" : "jst 6/29/2019 16:10",
"testIsExtendableWithAsterisk" : "jst 6/28/2019 15:14",
"testIsNotExtendableWithText" : "jst 6/28/2019 15:09",
"testIsNotOpenerAndCloser" : "jko 5/23/2019 12:43",
"testIsOpenerAndCloser" : "jko 5/23/2019 12:43",
"testItalicEmphasisDelimiterLength" : "kgr 7/23/2019 11:52",
"testItalicEmphasisDelimiterLength" : "jst 7/25/2019 14:28",
"testLeftFlanking" : "jst 6/28/2019 14:33",
"testLength" : "jst 6/26/2019 15:07",
"testMatchesOpenerNot" : "kgr 5/27/2019 15:42",
"testMaxDelimiterLengthIs2" : "kgr 5/27/2019 15:42",
"testMaxDelimiterLengthIs2" : "jst 7/25/2019 14:28",
"testMayBeginWithAsterisk" : "jst 6/26/2019 14:34",
"testMayNotBeginWithOtherCharacter" : "jst 6/26/2019 14:39",
"testNotClosingDelimiterIsNotCloser" : "jko 5/23/2019 12:43",
Expand All @@ -31,6 +30,6 @@
"testOpenerAndCloserMatchesOpener" : "kgr 5/27/2019 15:42",
"testOpeningDelimiterIsOpener" : "jko 5/23/2019 12:43",
"testRightFlanking" : "jst 6/28/2019 14:33",
"testSameDelimitersCreateBoldEmphasis" : "fgo 7/24/2019 10:10",
"testSameDelimitersCreateItalicEmphasis" : "fgo 7/24/2019 10:10",
"testSameDelimitersCreateBoldEmphasis" : "jst 7/25/2019 14:12",
"testSameDelimitersCreateItalicEmphasis" : "jst 7/25/2019 14:12",
"testStartPosition" : "jst 6/26/2019 14:26" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests
testDifferentEmphasisType

| emphasis1 emphasis2 |
emphasis1 := MarkdownEmphasis from: 1 to: 2.
emphasis2 := MarkdownEmphasis strongFrom: 1 to: 3.
self
deny: emphasis1 = emphasis2;
deny: emphasis1 hash = emphasis2 hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests
testEndPositionsAreUnequal

| emphasis1 emphasis2 |
emphasis1 := MarkdownEmphasis from: 1 to: 2.
emphasis2 := MarkdownEmphasis from: 1 to: 3.
self
deny: emphasis1 = emphasis2;
deny: emphasis1 hash = emphasis2 hash
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ testEqual
| emphasis1 emphasis2 |
emphasis1 := MarkdownEmphasis from: 1 to: 2.
emphasis2 := MarkdownEmphasis from: 1 to: 2.
self assert: emphasis1 equals: emphasis2
self
assert: emphasis1 equals: emphasis2;
assert: emphasis1 hash equals: emphasis2 hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests
testStartPositionsAreUnequal

| emphasis1 emphasis2 |
emphasis1 := MarkdownEmphasis from: 1 to: 2.
emphasis2 := MarkdownEmphasis from: 2 to: 2.
self
deny: emphasis1 = emphasis2;
deny: emphasis1 hash = emphasis2 hash
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"instance" : {
"testCreateBoldEmphasis" : "kgr 7/23/2019 12:07",
"testCreateItalicEmphasis" : "kgr 7/23/2019 12:08",
"testEqual" : "kgr 7/23/2019 12:04",
"testSetRange" : "kgr 7/23/2019 11:49" } }
"testDifferentEmphasisType" : "jst 7/25/2019 14:44",
"testEndPositionsAreUnequal" : "jst 7/25/2019 14:44",
"testEqual" : "jst 7/25/2019 14:41",
"testSetRange" : "kgr 7/23/2019 11:49",
"testStartPositionsAreUnequal" : "jst 7/25/2019 14:43" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
assert: aCollectionOfMarkdownEmphases areEmphasesIn: inlineTextStylerAttributes
assert: expectedEmphases areEmphasesIn: inlineTextStylerEmphases

self assert: aCollectionOfMarkdownEmphases asBag equals: inlineTextStylerAttributes asBag
self assert: expectedEmphases asBag equals: inlineTextStylerEmphases asBag

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests - cleaning
testCleanEmptiesEmphases

inlineTextStyler
emphases: {MarkdownEmphasis from: 1 to: 2} asOrderedCollection;
clean.

self assert: inlineTextStyler emphases isEmpty
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tests - interpretation
testDelimiterSpansCanNotOverlap

| attributes |
attributes := inlineTextStyler
inlineTextStyler
parse: '**f*o** o*'.

self assert: 1 equals: attributes size.
self assert: TextEmphasis bold equals: attributes first textAttribute

self
assert: {MarkdownEmphasis strongFrom: 1 to: 7}
areEmphasesIn: inlineTextStyler emphases
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ tests - interpretation
testInterpretEmptyTokens

inlineTextStyler interpretTokens.
self assert: inlineTextStyler attributes isEmpty
self assert: inlineTextStyler emphases isEmpty
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ testInterpretTokensAsItalics

self
assert: {MarkdownEmphasis from: 1 to: 5}
areEmphasesIn: inlineTextStyler attributes
areEmphasesIn: inlineTextStyler emphases

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ testInterpretTokensBold

self
assert: {MarkdownEmphasis strongFrom: 1 to: 7}
areEmphasesIn: inlineTextStyler attributes
areEmphasesIn: inlineTextStyler emphases
Loading

0 comments on commit d3c2828

Please sign in to comment.