Rework [code_block] tag
authorLanius Trolling <lanius@laniustrolling.dev>
Tue, 23 Jul 2024 18:15:03 +0000 (14:15 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Tue, 23 Jul 2024 18:15:03 +0000 (14:15 -0400)
src/jvmMain/kotlin/info/mechyrdia/data/Data.kt
src/jvmMain/kotlin/info/mechyrdia/data/ViewsComment.kt
src/jvmMain/kotlin/info/mechyrdia/lore/Fonts.kt
src/jvmMain/kotlin/info/mechyrdia/lore/ParserBuilder.kt
src/jvmMain/kotlin/info/mechyrdia/lore/ParserHtml.kt
src/jvmMain/kotlin/info/mechyrdia/lore/ViewsPrefs.kt
src/jvmMain/kotlin/info/mechyrdia/lore/ViewsRobots.kt

index bfc810ea1e2a65bc84eab920f5a24a773ff5a013..b1f1b405b8b7d0ed3ca8c56aa11784947db5de74 100644 (file)
@@ -111,7 +111,8 @@ const val MONGODB_ID_KEY = "_id"
 
 enum class IndexSort {
        ASCENDING,
-       DESCENDING;
+       DESCENDING,
+       ;
 }
 
 typealias IndexSortProperty<T> = Pair<KProperty1<T, *>, IndexSort>
index 788075c603ed70f777fec8048a7719e0d2bde40f..bb2abc64c0f12aedf89d615c8f9c406c7164afb9 100644 (file)
@@ -275,6 +275,15 @@ suspend fun ApplicationCall.commentHelpPage(): HTML.() -> Unit = page("Commentin
                                                +" text"
                                        }
                                }
+                               tr {
+                                       td { +"[code_block]Text goes here[/code_block]" }
+                                       td {
+                                               span {
+                                                       style = "font-family:JetBrains Mono"
+                                                       +"Marks a block of text as pre-formatted and puts it into monospaced font"
+                                               }
+                                       }
+                               }
                                tr {
                                        td { +"[align=(left, center, right, or justify)]Text goes here[/align]" }
                                        td {
@@ -470,6 +479,19 @@ suspend fun ApplicationCall.commentHelpPage(): HTML.() -> Unit = page("Commentin
                                                }
                                        }
                                }
+                               tr {
+                                       td { +"[epoch]893078880000[/epoch]" }
+                                       td {
+                                               +"Takes an offset of "
+                                               strong { +"milliseconds" }
+                                               +" counted from "
+                                               a(href = "https://en.wikipedia.org/wiki/Unix_time") {
+                                                       rel = "nofollow"
+                                                       +"Unix time"
+                                               }
+                                               +", and converts it to a client-localized date-time."
+                                       }
+                               }
                                tr {
                                        td { +"[lang=tylan]Rheagda Tulasra[/lang]" }
                                        td {
index 8baa193b39ab3b284ac1183a0db94788149985ca..72dc3bfe916cef447e80c7976fa4a6408f43310a 100644 (file)
@@ -39,7 +39,8 @@ enum class TextAlignment {
                override fun processWidth(widthDiff: Int): Int {
                        return widthDiff
                }
-       };
+       },
+       ;
        
        abstract fun processWidth(widthDiff: Int): Int
 }
index 17ecfb4d1eee6fd161cd20a3316af83ae9579801..70d8be525408b9fdd6ca50b94e69eca318b21764 100644 (file)
@@ -147,7 +147,8 @@ enum class RepliesBuilderTag(val type: BuilderTag<CommentRepliesBuilder>) {
                                env.context.addReplyTag(Id(id))
                        }
                }
-       );
+       ),
+       ;
        
        companion object {
                val asTags = LexerTags(entries.associate { it.name to it.type })
index 81e86a4615c7bee520c47c392354e5136fec8d8e..7eefe4cfd7f165b5344374d8c0137e9b3aa4a6fb 100644 (file)
@@ -250,7 +250,8 @@ enum class HtmlTagMode {
        INLINE,
        BLOCK,
        ITEM,
-       LAYOUT;
+       LAYOUT,
+       ;
        
        fun combine(env: LexerTagEnvironment<HtmlBuilderContext, HtmlBuilderSubject>, subNodes: ParserTree) = when (this) {
                INLINE -> HtmlLexerProcessor.combineInline(env, subNodes)
@@ -405,14 +406,17 @@ enum class FactbookFormattingTag(val type: HtmlLexerTag) {
        COLOR(HtmlTagLexerTag(attributes = ::processColor, tagMode = HtmlTagMode.INLINE, tagCreator = TagConsumer<*>::span.toTagCreator())),
        IPA(HtmlTagLexerTag(attributes = mapOf("style" to "font-family:DejaVu Sans"), tagMode = HtmlTagMode.INLINE, tagCreator = TagConsumer<*>::span.toTagCreator())),
        CODE(HtmlTagLexerTag(attributes = mapOf("style" to "font-family:JetBrains Mono"), tagMode = HtmlTagMode.INLINE, tagCreator = TagConsumer<*>::span.toTagCreator())),
-       CODE_BLOCK(HtmlTagLexerTag(tagCreator = { block ->
-               div {
-                       style = "font-family:JetBrains Mono"
-                       pre {
-                               block()
+       CODE_BLOCK(HtmlLexerTag { _, _, subNodes ->
+               val blockText = subNodes.unparse()
+               ({
+                       div {
+                               style = "font-family:JetBrains Mono"
+                               pre {
+                                       +blockText
+                               }
                        }
-               }
-       })),
+               })
+       }),
        BLOCKQUOTE(HtmlTagLexerTag(tagCreator = TagConsumer<*>::blockQuote.toTagCreator())),
        
        ERROR(HtmlTagLexerTag(attributes = mapOf("style" to "color: #f00"), tagCreator = TagConsumer<*>::div.toTagCreator())),
@@ -685,8 +689,6 @@ enum class CommentFormattingTag(val type: HtmlLexerTag) {
        CODE(FactbookFormattingTag.CODE.type),
        CODE_BLOCK(FactbookFormattingTag.CODE_BLOCK.type),
        
-       ERROR(HtmlTagLexerTag(attributes = mapOf("style" to "color: #f00"), tagCreator = TagConsumer<*>::div.toTagCreator())),
-       
        ALIGN(FactbookFormattingTag.ALIGN.type),
        ASIDE(FactbookFormattingTag.ASIDE.type),
        
index faf41dbfabb519e8050a5082487d4b75f3a32221..c098c316b49fa9fbb3aa1cc85d5f9c241c4a0956 100644 (file)
@@ -11,7 +11,8 @@ import kotlinx.serialization.serializer
 enum class PageTheme(val attributeValue: String?) {
        SYSTEM(null),
        LIGHT("light"),
-       DARK("dark");
+       DARK("dark"),
+       ;
 }
 
 object PageThemeSerializer : KeyedEnumSerializer<PageTheme>(PageTheme.entries, PageTheme::attributeValue)
@@ -36,7 +37,8 @@ enum class April1stMode {
        NEVER {
                override val isEnabled: Boolean
                        get() = false
-       };
+       },
+       ;
        
        abstract val isEnabled: Boolean
 }
index efd41e78b5c1e8dffa8f959f943f81f8fc85c76c..ad3b879a9881de38c9959537ee5a4f755b28cc23 100644 (file)
@@ -18,7 +18,8 @@ enum class SitemapChangeFrequency {
        WEEKLY,
        DAILY,
        HOURLY,
-       ALWAYS;
+       ALWAYS,
+       ;
 }
 
 val SitemapChangeFrequency.xmlValue: String