diff --git a/README.md b/README.md index 1aba528..bece5b0 100644 --- a/README.md +++ b/README.md @@ -378,6 +378,9 @@ If you need to set HTML attributes for a specific type, for example a row in the Release Notes ============= +V1.0.3 -> V1.0.4 +* Added the ability to add header row and header column for tables (NOTE: not finalized yet, but functional). + V1.0.2 -> V1.0.3 * Added no implicit warnings * Created mechanism for rendering the result of parsing in a hierarchical structure. diff --git a/build.sbt b/build.sbt index fdcae8e..614f9aa 100755 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ organization := "com.phasmidsoftware" name := "TableParser" -version := "1.0.4-SNAPSHOT" +version := "1.0.4" scalaVersion := "2.12.6" diff --git a/src/main/scala/com/phasmidsoftware/render/Renderer.scala b/src/main/scala/com/phasmidsoftware/render/Renderer.scala index 38770c6..9b71afc 100644 --- a/src/main/scala/com/phasmidsoftware/render/Renderer.scala +++ b/src/main/scala/com/phasmidsoftware/render/Renderer.scala @@ -80,7 +80,7 @@ abstract class ProductRenderer[T <: Product : ClassTag](val style: String, overr protected def us[U: TreeWriter](t: T): Seq[U] } -abstract class IndexedRenderer[T: Renderer](val style: String, override val baseAttrs: Map[String, String] = Map()) extends Renderer[Indexed[T]] { +abstract class IndexedRenderer[T: Renderer](val style: String, indexStyle: String, override val baseAttrs: Map[String, String] = Map()) extends Renderer[Indexed[T]] { /** * Render an instance of Indexed[T] as a U. * @@ -90,8 +90,7 @@ abstract class IndexedRenderer[T: Renderer](val style: String, override val base * @return a new instance of U. */ override def render[U: TreeWriter](ti: Indexed[T], attrs: Map[String, String]): U = { - // TODO specify style as header, but not with HTML-specific "th". - val indexRenderer: Renderer[Int] = new TaggedRenderer[Int]("th") {} + val indexRenderer: Renderer[Int] = new TaggedRenderer[Int](indexStyle) {} implicitly[TreeWriter[U]].node(style, Seq(indexRenderer.render(ti.i), implicitly[Renderer[T]].render(ti.t))) } } diff --git a/src/main/scala/com/phasmidsoftware/render/Renderers.scala b/src/main/scala/com/phasmidsoftware/render/Renderers.scala index 626e0a9..eb26417 100644 --- a/src/main/scala/com/phasmidsoftware/render/Renderers.scala +++ b/src/main/scala/com/phasmidsoftware/render/Renderers.scala @@ -47,7 +47,7 @@ trait Renderers { * @tparam P the type of the result. * @return a new instance of U. */ - def indexedRenderer[P: Renderer](style: String, attrs: Map[String, String] = Map()): Renderer[Indexed[P]] = new IndexedRenderer[P](style, attrs) {} + def indexedRenderer[P: Renderer](style: String, indexStyle: String, attrs: Map[String, String] = Map()): Renderer[Indexed[P]] = new IndexedRenderer[P](style, indexStyle, attrs) {} /** * Render an option of P as a U. diff --git a/src/test/scala/com/phasmidsoftware/render/RendererSpec.scala b/src/test/scala/com/phasmidsoftware/render/RendererSpec.scala index 45daf53..b1a2b98 100644 --- a/src/test/scala/com/phasmidsoftware/render/RendererSpec.scala +++ b/src/test/scala/com/phasmidsoftware/render/RendererSpec.scala @@ -40,7 +40,7 @@ class RendererSpec extends FlatSpec with Matchers { object Complex2 extends Renderers { implicit val valueRenderer: Renderer[Double] = renderer("td") implicit val complexRenderer: Renderer[Complex] = renderer2("span")(Complex) - implicit val indexedRenderer: Renderer[Indexed[Complex]] = indexedRenderer[Complex]("tr", Map()) + implicit val indexedRenderer: Renderer[Indexed[Complex]] = indexedRenderer[Complex]("tr", "th", Map()) // val rowsRenderer: Renderer[Seq[Indexed[Complex]]] = sequenceRenderer[Indexed[Complex]]("span") diff --git a/src/test/scala/com/phasmidsoftware/table/TableSpec.scala b/src/test/scala/com/phasmidsoftware/table/TableSpec.scala index d683f41..bc8a848 100644 --- a/src/test/scala/com/phasmidsoftware/table/TableSpec.scala +++ b/src/test/scala/com/phasmidsoftware/table/TableSpec.scala @@ -144,7 +144,7 @@ class TableSpec extends FlatSpec with Matchers { implicit object HTMLTreeWriter extends HTMLTreeWriter implicit val intPairRenderer: Renderer[IntPair] = renderer2("IntPair")(IntPair.apply) - implicit val r: Renderer[Indexed[IntPair]] = indexedRenderer("", Map()) + implicit val r: Renderer[Indexed[IntPair]] = indexedRenderer("", "th", Map()) }