Skip to content

Commit

Permalink
Introduce write forwarders on Writer to enable selective overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
sirthias committed Oct 24, 2016
1 parent c0b64f3 commit 349a62f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/src/main/scala/com/lightbend/paradox/ParadoxProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ class ParadoxProcessor(reader: Reader = new Reader, writer: Writer = new Writer)
private val page = loc.tree.label

val getTitle = page.title
val getContent = writer.write(page.markdown, context)
val getContent = writer.writeContent(page.markdown, context)

lazy val getBase = page.base
lazy val getHome = link(Some(loc.root))
lazy val getPrev = link(loc.prev)
lazy val getNext = link(loc.next)
lazy val getBreadcrumbs = writer.writeFragment(Breadcrumbs.markdown(leadingBreadcrumbs, loc.path), context)
lazy val getNavigation = writer.writeFragment(pageToc.root(loc), context)
lazy val getBreadcrumbs = writer.writeBreadcrumbs(Breadcrumbs.markdown(leadingBreadcrumbs, loc.path), context)
lazy val getNavigation = writer.writeNavigation(pageToc.root(loc), context)
lazy val hasSubheaders = page.headers.nonEmpty
lazy val getToc = writer.writeFragment(headerToc.headers(loc), context)
lazy val getToc = writer.writeToc(headerToc.headers(loc), context)

lazy val getProperties = context.properties.asJava

Expand All @@ -99,7 +99,7 @@ class ParadoxProcessor(reader: Reader = new Reader, writer: Writer = new Writer)
lazy val getHref: String = location.map(href).orNull
lazy val getHtml: String = location.map(link).orNull
lazy val getTitle: String = location.map(title).orNull
lazy val isActive: Boolean = location.map(active).getOrElse(false)
lazy val isActive: Boolean = location.exists(active)

private def link(location: Location[Page]): String = {
val node = if (active(location))
Expand Down
24 changes: 24 additions & 0 deletions core/src/main/scala/com/lightbend/paradox/markdown/Writer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ class Writer(serializer: Writer.Context => ToHtmlSerializer) {
verbatimSerializers.asJava,
serializerPlugins(context).asJava))

/**
* Write main content.
*/
def writeContent(node: Node, context: Writer.Context): String =
writeFragment(node, context)

/**
* Write breadcrumbs fragment.
*/
def writeBreadcrumbs(node: Node, context: Writer.Context): String =
writeFragment(node, context)

/**
* Write navigation fragment.
*/
def writeNavigation(node: Node, context: Writer.Context): String =
writeFragment(node, context)

/**
* Write navigation fragment.
*/
def writeToc(node: Node, context: Writer.Context): String =
writeFragment(node, context)

/**
* Write markdown to HTML, in the context of a page.
*/
Expand Down

0 comments on commit 349a62f

Please sign in to comment.