Skip to content

Commit 4594d3b

Browse files
authored
Merge pull request #35 from kbiakov/bugfix/html_tags
Fixed escaping html tags before highlighting
2 parents abc089b + 3b0d640 commit 4594d3b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

codeview/src/main/java/io/github/kbiakov/codeview/adapters/AbstractCodeAdapter.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import java.util.*
2929
abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter.ViewHolder> {
3030

3131
protected val context: Context
32-
protected var lines: List<String> = ArrayList() // items
32+
protected var lines: List<String> = ArrayList()
3333
protected var droppedLines: List<String>? = null
3434

3535
internal var options: Options
@@ -157,6 +157,7 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
157157
*/
158158
private fun updateContent(code: String, onUpdated: () -> Unit) {
159159
options.code = code
160+
options.isHighlighted = true
160161
prepareCodeLines()
161162
ui(onUpdated)
162163
}
@@ -227,7 +228,7 @@ abstract class AbstractCodeAdapter<T> : RecyclerView.Adapter<AbstractCodeAdapter
227228
}
228229
}
229230
tvLineContent.apply {
230-
text = html(lines[pos])
231+
text = lines[pos].let { if (options.isHighlighted) html(it) else it }
231232
textSize = fontSize
232233
setTextColor(options.theme.noteColor.color())
233234
}
@@ -333,6 +334,8 @@ data class Options(
333334
var maxLines: Int = 0,
334335
var lineClickListener: OnCodeLineClickListener? = null) {
335336

337+
internal var isHighlighted: Boolean = false
338+
336339
fun withCode(code: String): Options {
337340
this.code = code
338341
return this

0 commit comments

Comments
 (0)