Skip to content
Snippets Groups Projects
Verified Commit be729ff2 authored by Sebastian's avatar Sebastian
Browse files

Add more HTML testing files; allow arbitrarily deep unordered list nesting

parent 598e9110
No related branches found
No related tags found
1 merge request!366Add support for HTML blog posts
...@@ -317,7 +317,8 @@ fun HtmlText( ...@@ -317,7 +317,8 @@ fun HtmlText(
val listType = listNesting.top() val listType = listNesting.top()
listNumbering.incrementCurrent() listNumbering.incrementCurrent()
if (listType == UNORDERED) { if (listType == UNORDERED) {
appendAndUpdateCursor(listBullets[listNesting.size]) val bulletType = listNesting.size - 1
appendAndUpdateCursor(listBullets[bulletType % listBullets.size])
appendAndUpdateCursor(" ") appendAndUpdateCursor(" ")
pushStringAnnotation("bullet", listNesting.size.toString()) pushStringAnnotation("bullet", listNesting.size.toString())
} else if (listType == ORDERED) { } else if (listType == ORDERED) {
......
/*
* Briar Desktop
* Copyright (C) 2023 The Briar Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.briarproject.briar.desktop.blog
import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.foundation.verticalScroll
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.briarproject.briar.desktop.utils.PreviewUtils.preview
fun testHtml(testHtml: String) = preview {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize(),
) {
val scrollState = rememberScrollState()
VerticalScrollbar(
adapter = rememberScrollbarAdapter(scrollState),
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
)
SelectionContainer(
modifier = Modifier.fillMaxWidth().verticalScroll(scrollState).padding(16.dp),
) {
HtmlText(testHtml) {
println(it)
}
}
}
}
/*
* Briar Desktop
* Copyright (C) 2023 The Briar Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.briarproject.briar.desktop.blog
import org.intellij.lang.annotations.Language
import org.jetbrains.annotations.NonNls
fun main() = testHtml(testHtml)
@NonNls
@Language("HTML")
private val testHtml = """
<h1>Ordered lists</h1>
<ol>
<li>foo
<li>direct children
<ol>
<li>child1
<li>child2
</ol>
</li>
<ol>
<li>bar1</li>
<li>bar2</li>
</ol>
<li> more direct children
<ol>
<li>foo
<li>bar
<ol>
<li>child1
<li>child2
</ol>
</li>
<li>cat
</ol>
</li>
<li>baz
</ol>
""".trimIndent()
/*
* Briar Desktop
* Copyright (C) 2023 The Briar Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.briarproject.briar.desktop.blog
import org.intellij.lang.annotations.Language
import org.jetbrains.annotations.NonNls
fun main() = testHtml(testHtml)
@NonNls
@Language("HTML")
private val testHtml = """
<h1>Unordered lists</h1>
<ul>
<li>foo
<li>direct children
<ul>
<li>child1
<li>child2
</ul>
</li>
<ul>
<li>bar1</li>
<li>bar2</li>
</ul>
<li> more direct children
<ul>
<li>foo
<li>bar
<ul>
<li>child1
<li>child2
<ul>
<li>4th level</li>
<li>same bullet as first level</li>
</ul>
</ul>
</li>
</ul>
</li>
<li>first level again
</ul>
""".trimIndent()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment