~jan0sch/smederee

Showing details for patch 65b4d0a145f1c240199912a952ef5033cf6ebeaf.
2024-02-08 (Thu), 10:47 AM - Jens Grassel - 65b4d0a145f1c240199912a952ef5033cf6ebeaf

html-utils: Add strikethrough rendering to `MarkdownRenderer`.

- add also image attributes extension for possible use
- format dependencies vertically aligned in build.sbt
Summary of changes
2 files modified with 51 lines added and 42 lines removed
  • build.sbt with 44 added and 41 removed lines
  • modules/html-utils/src/main/scala/de/smederee/html/MarkdownRenderer.scala with 7 added and 1 removed lines
diff -rN -u old-smederee/build.sbt new-smederee/build.sbt
--- old-smederee/build.sbt	2025-01-12 22:08:29.894403047 +0000
+++ new-smederee/build.sbt	2025-01-12 22:08:29.894403047 +0000
@@ -119,6 +119,8 @@
                 library.catsCore,
                 library.commonMark,
                 library.commonMarkExtHeadingAnchor,
+                library.commonMarkExtImageAttrs,
+                library.commonMarkExtStrikethrough,
                 library.commonMarkExtTables,
                 library.commonMarkExtTaskListItems,
                 library.http4sCore,
@@ -418,47 +420,48 @@
             val simpleJavaMail  = "8.6.2"
             val springSecurity  = "6.2.1"
         }
-        val apacheSshdCore             = "org.apache.sshd"  % "sshd-core"                      % Version.apacheSshd
-        val apacheSshdSftp             = "org.apache.sshd"  % "sshd-sftp"                      % Version.apacheSshd
-        val apacheSshdScp              = "org.apache.sshd"  % "sshd-scp"                       % Version.apacheSshd
-        val bouncyCastleProvider       = "org.bouncycastle" % "bcprov-jdk15to18"               % Version.bouncyCastle
-        val catsCore                   = "org.typelevel"   %% "cats-core"                      % Version.cats
-        val catsEffect                 = "org.typelevel"   %% "cats-effect"                    % Version.catsEffect
-        val circeCore                  = "io.circe"        %% "circe-core"                     % Version.circe
-        val circeGeneric               = "io.circe"        %% "circe-generic"                  % Version.circe
-        val circeParser                = "io.circe"        %% "circe-parser"                   % Version.circe
-        val commonMark                 = "org.commonmark"   % "commonmark"                     % Version.commonMark
-        val commonMarkExtHeadingAnchor = "org.commonmark"   % "commonmark-ext-heading-anchor"  % Version.commonMark
-        val commonMarkExtTables        = "org.commonmark"   % "commonmark-ext-gfm-tables"      % Version.commonMark
-        val commonMarkExtTaskListItems = "org.commonmark"   % "commonmark-ext-task-list-items" % Version.commonMark
-        val doobieCore                 = "org.tpolecat"    %% "doobie-core"                    % Version.doobie
-        val doobieHikari               = "org.tpolecat"    %% "doobie-hikari"                  % Version.doobie
-        val doobiePostgres             = "org.tpolecat"    %% "doobie-postgres"                % Version.doobie
-        val doobieScalaTest            = "org.tpolecat"    %% "doobie-scalatest"               % Version.doobie
-        val ed25519Java                = "net.i2p.crypto"   % "eddsa"                          % "0.3.0"
-        val flywayCore                 = "org.flywaydb"     % "flyway-core"                    % Version.flyway
-        val fs2Core                    = "co.fs2"          %% "fs2-core"                       % Version.fs2
-        val fs2IO                      = "co.fs2"          %% "fs2-io"                         % Version.fs2
-        val http4sCirce                = "org.http4s"      %% "http4s-circe"                   % Version.http4s
-        val http4sCore                 = "org.http4s"      %% "http4s-core"                    % Version.http4s
-        val http4sDsl                  = "org.http4s"      %% "http4s-dsl"                     % Version.http4s
-        val http4sEmberServer          = "org.http4s"      %% "http4s-ember-server"            % Version.http4s
-        val http4sEmberClient          = "org.http4s"      %% "http4s-ember-client"            % Version.http4s
-        // val http4sTwirl                = "org.http4s"                   %% "http4s-twirl"                   % Version.http4s
-        val ip4sCore             = "com.comcast"                 %% "ip4s-core"              % Version.ip4s
-        val jansi                = "com.github.Osiris-Team"       % "jansi"                  % Version.jansi
-        val jclOverSlf4j         = "org.slf4j"                    % "jcl-over-slf4j"         % Version.jclOverSlf4j
-        val log4catsSlf4j        = "org.typelevel"               %% "log4cats-slf4j"         % Version.log4cats
-        val logback              = "ch.qos.logback"               % "logback-classic"        % Version.logback
-        val munit                = "org.scalameta"               %% "munit"                  % Version.munit
-        val munitCatsEffect      = "org.typelevel"               %% "munit-cats-effect"      % Version.munitCatsEffect
-        val munitScalaCheck      = "org.scalameta"               %% "munit-scalacheck"       % Version.munit
-        val osLib                = "com.lihaoyi"                 %% "os-lib"                 % Version.osLib
-        val postgresql           = "org.postgresql"               % "postgresql"             % Version.postgresql
-        val pureConfig           = "com.github.pureconfig"       %% "pureconfig-core"        % Version.pureConfig
-        val scalaCheck           = "org.scalacheck"              %% "scalacheck"             % Version.scalaCheck
-        val simpleJavaMail       = "org.simplejavamail"           % "simple-java-mail"       % Version.simpleJavaMail
-        val springSecurityCrypto = "org.springframework.security" % "spring-security-crypto" % Version.springSecurity
+        val apacheSshdCore             = "org.apache.sshd"              %  "sshd-core"                        % Version.apacheSshd
+        val apacheSshdSftp             = "org.apache.sshd"              %  "sshd-sftp"                        % Version.apacheSshd
+        val apacheSshdScp              = "org.apache.sshd"              %  "sshd-scp"                         % Version.apacheSshd
+        val bouncyCastleProvider       = "org.bouncycastle"             %  "bcprov-jdk15to18"                 % Version.bouncyCastle
+        val catsCore                   = "org.typelevel"                %% "cats-core"                        % Version.cats
+        val catsEffect                 = "org.typelevel"                %% "cats-effect"                      % Version.catsEffect
+        val circeCore                  = "io.circe"                     %% "circe-core"                       % Version.circe
+        val circeGeneric               = "io.circe"                     %% "circe-generic"                    % Version.circe
+        val circeParser                = "io.circe"                     %% "circe-parser"                     % Version.circe
+        val commonMark                 = "org.commonmark"               %  "commonmark"                       % Version.commonMark
+        val commonMarkExtHeadingAnchor = "org.commonmark"               %  "commonmark-ext-heading-anchor"    % Version.commonMark
+        val commonMarkExtImageAttrs    = "org.commonmark"               %  "commonmark-ext-image-attributes"  % Version.commonMark
+        val commonMarkExtStrikethrough = "org.commonmark"               %  "commonmark-ext-gfm-strikethrough" % Version.commonMark
+        val commonMarkExtTables        = "org.commonmark"               %  "commonmark-ext-gfm-tables"        % Version.commonMark
+        val commonMarkExtTaskListItems = "org.commonmark"               %  "commonmark-ext-task-list-items"   % Version.commonMark
+        val doobieCore                 = "org.tpolecat"                 %% "doobie-core"                      % Version.doobie
+        val doobieHikari               = "org.tpolecat"                 %% "doobie-hikari"                    % Version.doobie
+        val doobiePostgres             = "org.tpolecat"                 %% "doobie-postgres"                  % Version.doobie
+        val doobieScalaTest            = "org.tpolecat"                 %% "doobie-scalatest"                 % Version.doobie
+        val ed25519Java                = "net.i2p.crypto"               %  "eddsa"                            % "0.3.0"
+        val flywayCore                 = "org.flywaydb"                 %  "flyway-core"                      % Version.flyway
+        val fs2Core                    = "co.fs2"                       %% "fs2-core"                         % Version.fs2
+        val fs2IO                      = "co.fs2"                       %% "fs2-io"                           % Version.fs2
+        val http4sCirce                = "org.http4s"                   %% "http4s-circe"                     % Version.http4s
+        val http4sCore                 = "org.http4s"                   %% "http4s-core"                      % Version.http4s
+        val http4sDsl                  = "org.http4s"                   %% "http4s-dsl"                       % Version.http4s
+        val http4sEmberServer          = "org.http4s"                   %% "http4s-ember-server"              % Version.http4s
+        val http4sEmberClient          = "org.http4s"                   %% "http4s-ember-client"              % Version.http4s
+        val ip4sCore                   = "com.comcast"                  %% "ip4s-core"                        % Version.ip4s
+        val jansi                      = "com.github.Osiris-Team"       %  "jansi"                            % Version.jansi
+        val jclOverSlf4j               = "org.slf4j"                    %  "jcl-over-slf4j"                   % Version.jclOverSlf4j
+        val log4catsSlf4j              = "org.typelevel"                %% "log4cats-slf4j"                   % Version.log4cats
+        val logback                    = "ch.qos.logback"               %  "logback-classic"                  % Version.logback
+        val munit                      = "org.scalameta"                %% "munit"                            % Version.munit
+        val munitCatsEffect            = "org.typelevel"                %% "munit-cats-effect"                % Version.munitCatsEffect
+        val munitScalaCheck            = "org.scalameta"                %% "munit-scalacheck"                 % Version.munit
+        val osLib                      = "com.lihaoyi"                  %% "os-lib"                           % Version.osLib
+        val postgresql                 = "org.postgresql"               %  "postgresql"                       % Version.postgresql
+        val pureConfig                 = "com.github.pureconfig"        %% "pureconfig-core"                  % Version.pureConfig
+        val scalaCheck                 = "org.scalacheck"               %% "scalacheck"                       % Version.scalaCheck
+        val simpleJavaMail             = "org.simplejavamail"           %  "simple-java-mail"                 % Version.simpleJavaMail
+        val springSecurityCrypto       = "org.springframework.security" %  "spring-security-crypto"           % Version.springSecurity
     }
 
 // *****************************************************************************
diff -rN -u old-smederee/modules/html-utils/src/main/scala/de/smederee/html/MarkdownRenderer.scala new-smederee/modules/html-utils/src/main/scala/de/smederee/html/MarkdownRenderer.scala
--- old-smederee/modules/html-utils/src/main/scala/de/smederee/html/MarkdownRenderer.scala	2025-01-12 22:08:29.894403047 +0000
+++ new-smederee/modules/html-utils/src/main/scala/de/smederee/html/MarkdownRenderer.scala	2025-01-12 22:08:29.894403047 +0000
@@ -20,6 +20,7 @@
 import java.util.Locale
 
 import cats.syntax.all.*
+import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension
 import org.commonmark.ext.gfm.tables.TablesExtension
 import org.commonmark.ext.heading.anchor.HeadingAnchorExtension
 import org.commonmark.ext.task.list.items.TaskListItemsExtension
@@ -39,7 +40,12 @@
     private val log = LoggerFactory.getLogger(getClass())
 
     private val MarkdownExtensions =
-        List(TablesExtension.create(), HeadingAnchorExtension.create(), TaskListItemsExtension.create())
+        List(
+            HeadingAnchorExtension.create(),
+            StrikethroughExtension.create(),
+            TablesExtension.create(),
+            TaskListItemsExtension.create()
+        )
 
     /** Render the given markdown content into HTML.
       *