Skip to content

Commit

Permalink
Merge pull request #117 from hpi-swa-teaching/feature/strikeout
Browse files Browse the repository at this point in the history
Enable strikeout of text
  • Loading branch information
JulianEgbert committed May 12, 2021
2 parents a3bab9e + d65b4ce commit 3a0b404
Show file tree
Hide file tree
Showing 97 changed files with 438 additions and 131 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
mayBeginWith: aCharacter

^ aCharacter = $*
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
attribute
delimiterLengthForEmphasisWith: aMarkdownEmphasisDelimiter

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

aLength = 1
ifTrue: [^ MarkdownItalic from: start to: end]
ifFalse: [^ MarkdownBold from: start to: end]
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
isExtendableWith: aCharacter

^ aCharacter = $*
self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
testing
matches: aMarkdownEmphasisDelimiter

^ aMarkdownEmphasisDelimiter type = 'EmphasisDelimiter'
^ aMarkdownEmphasisDelimiter type = self type
and: [((self isOpener and: [aMarkdownEmphasisDelimiter isCloser])
or: [self isCloser and: [aMarkdownEmphasisDelimiter isOpener]])
and: [(self isOpenerAndCloser or: [aMarkdownEmphasisDelimiter isOpenerAndCloser])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
punctuationCharacters

^ #($! $" $# $$ $% $& $' $( $) $* $+ $, $- $. $/ $: $; $< $= $> $? $@ $[ $] $\ $^ $_ $` ${ $} $| $~)
self subclassResponsibility

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
{
"class" : {
"mayBeginWith:" : "jst 6/26/2019 14:35" },
"mayBeginWith:" : "F.S 5/6/2021 15:15" },
"instance" : {
"boldLength" : "fgo 5/10/2019 15:54",
"decideLeftFlankingForPreceding:following:" : "azi 8/6/2020 08:06",
"decideRightFlankingForPreceding:following:" : "azi 8/6/2020 08:06",
"delimiterLengthForEmphasisWith:" : "jst 7/25/2019 14:28",
"emphasisFrom:to:delimiterLength:" : "cg 6/29/2020 21:52",
"emphasisStartingAt:" : "jst 7/25/2019 14:28",
"delimiterLengthForEmphasisWith:" : "jh 5/7/2021 11:01",
"emphasisFrom:to:delimiterLength:" : "jh 5/7/2021 11:02",
"emphasisStartingAt:" : "F.S 5/6/2021 15:02",
"isCloser" : "jko 5/6/2019 16:20",
"isDelimiter" : "fgo 5/4/2019 21:08",
"isExtendableWith:" : "jst 6/28/2019 15:15",
"isExtendableWith:" : "jh 5/7/2021 11:09",
"isLeftFlanking" : "jko 5/23/2019 12:06",
"isLeftFlanking:" : "jko 5/23/2019 12:42",
"isOpener" : "jko 5/6/2019 16:20",
"isOpenerAndCloser" : "jko 5/6/2019 16:20",
"isRightFlanking" : "jko 5/23/2019 12:06",
"isRightFlanking:" : "jko 5/23/2019 12:43",
"matches:" : "azi 8/6/2020 08:07",
"punctuationCharacters" : "MK 7/3/2020 21:06",
"matches:" : "F.S 5/6/2021 15:17",
"punctuationCharacters" : "jh 5/7/2021 11:02",
"setPreceding:following:" : "jst 6/29/2019 16:11",
"type" : "MK 7/5/2020 20:50",
"whitespaceCharacters" : "MK 7/3/2020 21:07" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
converting
convertStrike: aMarkdownStrike

^ '<del>', aMarkdownStrike content, '</del>'
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"convertHeading:" : "MK 7/5/2020 20:10",
"convertHeadingStyleSettings:" : "MK 7/9/2020 14:43",
"convertInlines:" : "azi 8/6/2020 08:08",
"convertItalic:" : "cg 6/29/2020 22:01",
"convertItalic:" : "F.S 5/6/2021 15:01",
"convertLink:" : "cg 6/29/2020 21:42",
"convertList:withTag:" : "cg 6/29/2020 22:20",
"convertOrderedList:" : "cg 6/29/2020 17:58",
"convertOrderedListStyleSettings:" : "MK 7/9/2020 15:43",
"convertParagraph:" : "mas 8/6/2020 09:59",
"convertParagraphStyleSettings:" : "MK 7/9/2020 14:43",
"convertStrike:" : "F.S 5/6/2021 13:12",
"convertStyleSettings:" : "mas 8/6/2020 09:57",
"convertUnorderedList:" : "cg 6/29/2020 17:57",
"convertUnorderedListStyleSettings:" : "MK 7/9/2020 15:42",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ createEmphasisFrom: opener and: closer

| emphasis |
emphasis := closer emphasisStartingAt: opener.
emphasis ifNil: [^ nil].
emphasis content: (self content copyFrom: opener endPosition + 1
to: closer startPosition - 1).
^ emphasis
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ interpretTokens
[(currentToken isDelimiter and: [currentToken isCloser])
ifTrue: [self
findOpenerFor: currentToken
ifFound: [:opener | currentToken := self process: opener and: currentToken]].
ifFound: [:opener| | token |
token := self process: opener and: currentToken.
token ifNotNil: [currentToken := token]]].
currentToken = self tokens last
ifFalse: [currentToken := self tokens after: currentToken]
ifTrue: [^ self]] repeat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ process: opener and: closer

(opener type = 'LinkDelimiter' and: [closer type = 'LinkDelimiter'])
ifTrue: [ ^ self processLink: opener and: closer].
(opener type = 'EmphasisDelimiter' and: [closer type = 'EmphasisDelimiter'])
(opener type = 'ItalicBoldDelimiter' and: [closer type = 'ItalicBoldDelimiter'])
ifTrue: [^ self processEmphasis: opener and: closer].
(opener type = 'StrikeDelimiter' and: [closer type = 'StrikeDelimiter'])
ifTrue: [^ self processEmphasis: opener and: closer].

^ closer
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
parsing
processEmphasis: opener and: closer

| length |

self inlineElements add: (self createEmphasisFrom: opener and: closer).
| length token|
token := (self createEmphasisFrom: opener and: closer).
token ifNotNil:
[self inlineElements add: (self createEmphasisFrom: opener and: closer)] ifNil: [^nil].
self removeDelimitersBetween: opener and: closer.
length := closer delimiterLengthForEmphasisWith: opener.
self cutOpener: opener to: length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parsing - tokenization
tokenFor: aCharacter at: position

| matchingTokenClass |
matchingTokenClass := {MarkdownEmphasisDelimiter. MarkdownOpeningLinkDelimiter.
matchingTokenClass := {MarkdownStrikeDelimiter. MarkdownItalicBoldDelimiter. MarkdownOpeningLinkDelimiter.
MarkdownClosingLinkDelimiter. MarkdownOpeningURLDelimiter.
MarkdownClosingURLDelimiter}
detect: [:tokenClass | tokenClass mayBeginWith: aCharacter]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean" : "hsl 5/19/2020 22:42",
"content" : "hsl 5/19/2020 15:11",
"content:" : "hsl 5/19/2020 15:11",
"createEmphasisFrom:and:" : "azi 8/6/2020 07:46",
"createEmphasisFrom:and:" : "F.S 5/6/2021 14:46",
"createLinkFrom:and:" : "cg 6/29/2020 22:52",
"createTokensFrom:" : "MK 7/5/2020 20:41",
"cutCloser:to:" : "hsl 5/17/2020 18:18",
Expand All @@ -19,20 +19,20 @@
"initialize" : "jst 6/29/2019 16:09",
"inlineElements" : "hsl 5/19/2020 22:41",
"inlineElements:" : "hsl 5/19/2020 22:41",
"interpretTokens" : "hsl 5/17/2020 15:54",
"parse:" : "hsl 8/5/2020 21:26",
"interpretTokens" : "F.S 5/6/2021 16:44",
"parse:" : "F.S 5/6/2021 14:38",
"precedingCharacterOf:" : "jst 6/26/2019 23:26",
"precedingTokenOf:" : "hsl 5/19/2020 13:26",
"privateFormat:" : "jst 6/28/2019 14:02",
"privateStyle:" : "jko 6/25/2019 22:04",
"process:and:" : "hsl 7/28/2020 13:38",
"process:and:" : "F.S 5/6/2021 15:38",
"processAdjacentTokens" : "jst 6/29/2019 16:11",
"processEmphasis:and:" : "mas 8/6/2020 10:37",
"processEmphasis:and:" : "F.S 5/6/2021 16:44",
"processLink:and:" : "mas 8/6/2020 10:37",
"processOpeningURLDelimiter:" : "azi 8/6/2020 08:04",
"removeDelimitersBetween:and:" : "MK 7/27/2020 11:10",
"reset" : "jst 6/28/2019 14:03",
"tokenFor:at:" : "azi 8/6/2020 08:03",
"tokenFor:at:" : "F.S 5/6/2021 15:28",
"tokenize:" : "hsl 8/5/2020 22:53",
"tokens" : "jko 5/6/2019 15:10",
"tokens:" : "jko 5/6/2019 15:11" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
instance creation
as yet unclassified
from: startPosition to: endPosition

^ self new
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"from:to:" : "cg 6/29/2020 21:50" },
"from:to:" : "F.S 5/6/2021 13:47" },
"instance" : {
"convertWith:" : "cg 6/29/2020 22:35",
"indicator" : "hsl 6/30/2020 16:58" } }
"convertWith:" : "F.S 5/6/2021 13:47",
"indicator" : "F.S 5/6/2021 13:47" } }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
mayBeginWith: aCharacter

^ aCharacter = $*
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
attribute
delimiterLengthForEmphasisWith: aMarkdownEmphasisDelimiter

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

aLength = 1
ifTrue: [^ MarkdownItalic from: start to: end]
ifFalse: [^ MarkdownBold from: start to: end]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isExtendableWith: aCharacter

^ aCharacter = $*
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
punctuationCharacters

^ #($! $" $# $$ $% $& $' $( $) $* $+ $, $- $. $/ $: $; $< $= $> $? $@ $[ $] $\ $^ $_ $` ${ $} $| $~)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
type

^ 'ItalicBoldDelimiter'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"class" : {
"mayBeginWith:" : "F.S 5/6/2021 15:19" },
"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",
"type" : "F.S 5/6/2021 15:36" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "MarkdownEditor-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "MarkdownItalicBoldDelimiter",
"pools" : [
],
"super" : "MarkdownEmphasisDelimiter",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
instance creation
from: startPosition to: endPosition

^ self new
textAttribute: TextEmphasis struckOut;
setFrom: startPosition to: endPosition;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export
convertWith: aConverter

^ aConverter convertStrike: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
indicator

^ '~~'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
"from:to:" : "F.S 5/6/2021 13:15" },
"instance" : {
"convertWith:" : "F.S 5/6/2021 13:14",
"indicator" : "F.S 5/6/2021 13:14" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "MarkdownEditor-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "MarkdownStrike",
"pools" : [
],
"super" : "MarkdownEmphasis",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
mayBeginWith: aCharacter

^ aCharacter = $~
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
attribute
delimiterLengthForEmphasisWith: aMarkdownEmphasisDelimiter

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

aLength = 2
ifTrue: [^ MarkdownStrike from: start to: end]
ifFalse: [^ nil]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isExtendableWith: aCharacter

^ aCharacter = $~
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
neededLength

^ 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
punctuationCharacters

^ #($! $" $# $$ $% $& $' $( $) $* $+ $, $- $. $/ $: $; $< $= $> $? $@ $[ $] $\ $^ $_ $` ${ $} $|)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
type

^ 'StrikeDelimiter'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"class" : {
"mayBeginWith:" : "F.S 5/6/2021 15:25" },
"instance" : {
"delimiterLengthForEmphasisWith:" : "jh 5/7/2021 10:46",
"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
@@ -0,0 +1,14 @@
{
"category" : "MarkdownEditor-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "MarkdownStrikeDelimiter",
"pools" : [
],
"super" : "MarkdownEmphasisDelimiter",
"type" : "normal" }
Loading

0 comments on commit 3a0b404

Please sign in to comment.