Skip to content

Commit 0716c7a

Browse files
committed
Remove extra newlines
1 parent 9eb8645 commit 0716c7a

31 files changed

+0
-125
lines changed

aztec/src/main/java/org/wordpress/aztec/Html.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ public static StringBuilder stringifyAttributes(Attributes attributes) {
174174
}
175175
return sb;
176176
}
177-
178177
}
179178

180179
class HtmlToSpannedConverter implements ContentHandler, LexicalHandler {
@@ -642,32 +641,26 @@ public void skippedEntity(String name) throws SAXException {
642641

643642
@Override
644643
public void startDTD(String s, String s1, String s2) throws SAXException {
645-
646644
}
647645

648646
@Override
649647
public void endDTD() throws SAXException {
650-
651648
}
652649

653650
@Override
654651
public void startEntity(String s) throws SAXException {
655-
656652
}
657653

658654
@Override
659655
public void endEntity(String s) throws SAXException {
660-
661656
}
662657

663658
@Override
664659
public void startCDATA() throws SAXException {
665-
666660
}
667661

668662
@Override
669663
public void endCDATA() throws SAXException {
670-
671664
}
672665

673666
@Override

aztec/src/main/kotlin/org/wordpress/aztec/AztecParser.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ class AztecParser {
239239
// at last, all checks passed so, let's mark the newline as visual!
240240
markBlockElementLineBreak(spanned, spanStart - 1)
241241
}
242-
243242
}
244243

245244
private fun markBlockElementsAsParagraphs(text: Spannable) {
@@ -497,7 +496,6 @@ class AztecParser {
497496
hiddenIndex++
498497
}
499498
}
500-
501499
} while (last != hiddenIndex)
502500
}
503501

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
271271
FullWidthImageElementWatcher.install(this)
272272

273273
EndOfBufferMarkerAdder.install(this)
274-
275274
}
276275

277276
override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
@@ -328,7 +327,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
328327
setSelection(retainedSelectionStart, retainedSelectionEnd)
329328
}
330329

331-
332330
val isLinkDialogVisible = customState.getBoolean(LINK_DIALOG_VISIBLE_KEY, false)
333331
if (isLinkDialogVisible) {
334332
val retainedUrl = customState.getString(LINK_DIALOG_URL_KEY, "")
@@ -407,7 +405,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
407405
out.writeBundle(state)
408406
}
409407

410-
411408
companion object {
412409
@JvmField val CREATOR: Parcelable.Creator<SavedState> = object : Parcelable.Creator<SavedState> {
413410
override fun createFromParcel(source: Parcel): SavedState {
@@ -515,7 +512,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
515512
newSelStart--
516513
}
517514

518-
519515
TextFormat.values().forEach {
520516
if (contains(it, newSelStart, newSelEnd)) {
521517
styles.add(it)
@@ -792,7 +788,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
792788
inlineFormatter.removeInlineStyle(TextFormat.FORMAT_CODE, start, end)
793789
}
794790

795-
796791
fun removeBlockStylesFromRange(start: Int, end: Int, ignoreLineBounds: Boolean = false) {
797792
blockFormatter.removeBlockStyle(TextFormat.FORMAT_PARAGRAPH, start, end, Arrays.asList(AztecBlockSpan::class.java), ignoreLineBounds)
798793
}
@@ -886,7 +881,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
886881
}
887882
}
888883

889-
890884
fun removeLink() {
891885
val urlSpanBounds = linkFormatter.getUrlSpanBounds()
892886

@@ -918,7 +912,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
918912
val anchorText = anchorInput.text.toString().trim { it <= ' ' }
919913

920914
link(linkText, anchorText)
921-
922915
})
923916

924917
if (linkFormatter.isUrlSelected()) {
@@ -999,7 +992,6 @@ class AztecText : android.support.v7.widget.AppCompatEditText, TextWatcher, Unkn
999992
history.handleHistory(this@AztecText)
1000993
return false
1001994
}
1002-
1003995
}
1004996
return super.sendKeyEvent(event)
1005997
}

aztec/src/main/kotlin/org/wordpress/aztec/History.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class History(val historyEnabled: Boolean, val historySize: Int) {
9696
editText.isFocusable = false
9797
editText.isFocusableInTouchMode = false
9898

99-
10099
setTextFromHistory(editText)
101100

102101
historyWorking = false

aztec/src/main/kotlin/org/wordpress/aztec/formatting/AztecFormatter.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.wordpress.aztec.formatting
33
import android.text.Editable
44
import org.wordpress.aztec.AztecText
55

6-
76
abstract class AztecFormatter(editor: AztecText) {
87

98
val editor: AztecText
@@ -20,5 +19,4 @@ abstract class AztecFormatter(editor: AztecText) {
2019
init {
2120
this.editor = editor
2221
}
23-
2422
}

aztec/src/main/kotlin/org/wordpress/aztec/formatting/BlockFormatter.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
231231
}
232232
}
233233

234-
235234
//TODO: Come up with a better way to init spans and get their classes (all the "make" methods)
236235
fun makeBlock(textFormat: TextFormat, nestingLevel: Int, attrs: AztecAttributes = AztecAttributes()): List<AztecBlockSpan> {
237236
when (textFormat) {
@@ -287,7 +286,6 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
287286
}
288287
}
289288

290-
291289
fun getSelectedTextBounds(editable: Editable, selectionStart: Int, selectionEnd: Int): IntRange {
292290
val startOfLine: Int
293291
val endOfLine: Int
@@ -310,14 +308,12 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
310308
}
311309
}
312310

313-
314311
startOfLine = if (indexOfFirstLineBreak != -1) indexOfFirstLineBreak else 0
315312
endOfLine = if (indexOfLastLineBreak != -1) (indexOfLastLineBreak + 1) else editable.length
316313

317314
return IntRange(startOfLine, endOfLine)
318315
}
319316

320-
321317
fun applyBlockStyle(blockElementType: TextFormat, start: Int = selectionStart, end: Int = selectionEnd) {
322318
if (start != end) {
323319
val nestingLevel = AztecNestable.getNestingLevelAt(editableText, start)
@@ -352,7 +348,6 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
352348
applyBlock(makeBlockSpan(blockElementType, nestingLevel), startOfBlock + 1,
353349
(if (endOfBlock == editableText.length) endOfBlock else endOfBlock + 1))
354350
}
355-
356351
} else {
357352
val boundsOfSelectedText = getSelectedTextBounds(editableText, start, end)
358353

@@ -366,7 +361,6 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
366361
var startOfBlock: Int = startOfLine
367362
var endOfBlock: Int = endOfLine
368363

369-
370364
if (startOfLine != 0) {
371365
val spansOnPreviousLine = editableText.getSpans(startOfLine - 1, startOfLine - 1, spanToApply.javaClass)
372366
.firstOrNull()
@@ -474,7 +468,6 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
474468
val lines = TextUtils.split(editableText.toString(), "\n")
475469
val list = ArrayList<Int>()
476470

477-
478471
for (i in lines.indices) {
479472
val lineStart = (0..i - 1).sumBy { lines[it].length + 1 }
480473
val lineEnd = lineStart + lines[i].length
@@ -520,7 +513,6 @@ class BlockFormatter(editor: AztecText, val listStyle: ListStyle, val quoteStyle
520513
return spans.isNotEmpty()
521514
}
522515

523-
524516
fun containQuote(selStart: Int = selectionStart, selEnd: Int = selectionEnd): Boolean {
525517
val lines = TextUtils.split(editableText.toString(), "\n")
526518
val list = ArrayList<Int>()

aztec/src/main/kotlin/org/wordpress/aztec/formatting/InlineFormatter.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import org.wordpress.aztec.spans.*
1111
import org.wordpress.aztec.watchers.TextChangedEvent
1212
import java.util.*
1313

14-
1514
class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormatter(editor) {
1615

1716
data class CarryOverSpan(val span: AztecInlineSpan, val start: Int, val end: Int)
1817
data class CodeStyle(val codeBackground: Int, val codeBackgroundAlpha: Float, val codeColor: Int)
1918

2019
val carryOverSpans = ArrayList<CarryOverSpan>()
2120

22-
2321
fun toggleBold() {
2422
if (!containsInlineStyle(TextFormat.FORMAT_BOLD)) {
2523
applyInlineStyle(TextFormat.FORMAT_BOLD)
@@ -84,7 +82,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
8482
carryOverSpans.clear()
8583
}
8684

87-
8885
fun handleInlineStyling(textChangedEvent: TextChangedEvent) {
8986
//trailing styling
9087
if (!editor.formattingHasChanged() || textChangedEvent.isNewLineButNotAtTheBeginning()) return
@@ -113,7 +110,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
113110
editor.setFormattingChangesApplied()
114111
}
115112

116-
117113
private fun clearInlineStyles(start: Int, end: Int, ignoreSelectedStyles: Boolean) {
118114
val newStart = if (start > end) end else start
119115

@@ -134,7 +130,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
134130
}
135131
}
136132

137-
138133
fun applyInlineStyle(textFormat: TextFormat, start: Int = selectionStart, end: Int = selectionEnd) {
139134
val spanToApply = makeInlineSpan(textFormat)
140135

@@ -163,7 +158,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
163158
} else {
164159
editableText.setSpan(precedingSpan, spanStart, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE)
165160
}
166-
167161
}
168162
}
169163

@@ -200,7 +194,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
200194
} else {
201195
editableText.setSpan(spanToApply, start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE)
202196
}
203-
204197
}
205198

206199
joinStyleSpans(start, end)
@@ -234,7 +227,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
234227
joinStyleSpans(start, end)
235228
}
236229

237-
238230
fun isSameInlineSpanType(firstSpan: AztecInlineSpan, secondSpan: AztecInlineSpan): Boolean {
239231
if (firstSpan.javaClass == secondSpan.javaClass) {
240232
//special check for StyleSpan
@@ -245,7 +237,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
245237
} else {
246238
return true
247239
}
248-
249240
}
250241

251242
return false
@@ -268,7 +259,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
268259
editableText.removeSpan(outerSpan)
269260
editableText.setSpan(innerSpan, outerSpanStart, inSelectionSpanEnd, Spanned.SPAN_EXCLUSIVE_INCLUSIVE)
270261
}
271-
272262
}
273263
}
274264
}
@@ -291,7 +281,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
291281
}
292282
}
293283

294-
295284
//joins spans withing selected text
296285
val spansInSelection = editableText.getSpans(start, end, AztecInlineSpan::class.java)
297286
val spansToUse = editableText.getSpans(start, end, AztecInlineSpan::class.java)
@@ -311,7 +300,6 @@ class InlineFormatter(editor: AztecText, val codeStyle: CodeStyle) : AztecFormat
311300
neighbourSpan = it
312301
return@inner
313302
}
314-
315303
}
316304
}
317305

aztec/src/main/kotlin/org/wordpress/aztec/formatting/LineBlockFormatter.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import org.wordpress.aztec.watchers.EndOfBufferMarkerAdder
1212
import org.xml.sax.Attributes
1313
import java.util.*
1414

15-
1615
class LineBlockFormatter(editor: AztecText) : AztecFormatter(editor) {
1716

1817
fun applyMoreComment() {

aztec/src/main/kotlin/org/wordpress/aztec/formatting/LinkFormatter.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import org.wordpress.aztec.AztecAttributes
1010
import org.wordpress.aztec.AztecText
1111
import org.wordpress.aztec.spans.AztecURLSpan
1212

13-
1413
class LinkFormatter(editor: AztecText, val linkStyle: LinkStyle):AztecFormatter(editor) {
1514

1615
data class LinkStyle(val linkColor: Int, val linkUnderline: Boolean)
@@ -29,7 +28,6 @@ class LinkFormatter(editor: AztecText, val linkStyle: LinkStyle):AztecFormatter(
2928

3029
url = if (TextUtils.isEmpty(clipboardUrl)) "" else clipboardUrl
3130
anchor = if (selectionStart == selectionEnd) "" else editor.getSelectedText()
32-
3331
} else {
3432
val urlSpan = editableText.getSpans(selectionStart, selectionEnd, AztecURLSpan::class.java).first()
3533

@@ -51,7 +49,6 @@ class LinkFormatter(editor: AztecText, val linkStyle: LinkStyle):AztecFormatter(
5149
}
5250

5351
return Pair(url, anchor)
54-
5552
}
5653

5754
/**
@@ -81,7 +78,6 @@ class LinkFormatter(editor: AztecText, val linkStyle: LinkStyle):AztecFormatter(
8178
return Pair(spanStart, spanEnd)
8279
}
8380

84-
8581
fun addLink(link: String, anchor: String, start: Int, end: Int) {
8682
val cleanLink = link.trim()
8783

aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ object Format {
8080
if (content.contains("<pre") || content.contains("<script")) {
8181
preserve_linebreaks = true
8282

83-
8483
content = content.replace(Regex("<(pre|script)[^>]*>[\\s\\S]+?</\\1>"), { matchResult: MatchResult ->
8584
var value = replaceAll(matchResult.groupValues[0], "<br ?/?>(\\r\\n|\\n)?", "<wp-line-break>")
8685
value = replaceAll(value, "</?p( [^>]*)?>(\\r\\n|\\n)?", "<wp-line-break>")
@@ -115,7 +114,6 @@ object Format {
115114

116115
content = replaceAll(content, "\\s*<(!--.*?--|hr)>\\s*", "\n\n<$1>\n\n")
117116

118-
119117
// Mark </p> if it has any attributes.
120118
content = replaceAll(content, "(<p [^>]+>.*?)</p>", "$1</p#>")
121119

@@ -200,7 +198,6 @@ object Format {
200198
"|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section" +
201199
"|article|aside|hgroup|header|footer|nav|figure|details|menu|summary"
202200

203-
204201
if (html.contains("<object")) {
205202
p = Pattern.compile("<object[\\s\\S]+?</object>")
206203
m = p.matcher(html)
@@ -261,7 +258,6 @@ object Format {
261258

262259
html += "\n\n"
263260

264-
265261
html = replaceAll(html, "(?i)<br ?/?>\\s*<br ?/?>", "\n\n")
266262
html = replaceAll(html, "(?i)(<(?:$blocklist)(?: [^>]*)?>)", "\n$1")
267263
html = replaceAll(html, "(?i)(</(?:$blocklist)>)", "$1\n\n")
@@ -296,7 +292,6 @@ object Format {
296292
html = replaceAll(html, "(?i)<br ?/?>(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)", "$1")
297293
html = replaceAll(html, "(?i)(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*", "[caption$1[/caption]")
298294

299-
300295
// html = html.replace(Regex("(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)</p>"), { matchResult: MatchResult ->
301296
// if (matchResult.groupValues[2].matches(Regex("<p( [^>]*)?>"))) {
302297
// matchResult.groupValues[0]
@@ -317,7 +312,6 @@ object Format {
317312
return html.replace("\n", "").trim()
318313
}
319314

320-
321315
fun preProcessSpannedText(text: SpannableStringBuilder, isCalypsoFormat: Boolean) {
322316
if (isCalypsoFormat) {
323317
text.getSpans(0, text.length, AztecVisualLinebreak::class.java).forEach {
@@ -336,7 +330,6 @@ object Format {
336330
}
337331
}
338332

339-
340333
fun postProcessSpanedText(text: SpannableStringBuilder, isCalypsoFormat: Boolean) {
341334
if (isCalypsoFormat) {
342335
val spans = text.getSpans(0, text.length, EndOfParagraphMarker::class.java)

0 commit comments

Comments
 (0)