-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to laika 1.0.0 #140
Conversation
|
||
val formatterFactory: RenderContext[TextFormatter] => TextFormatter = PlaintextFormatter | ||
val formatterFactory: Formatter.Context[Formatter] => Formatter = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor thing: to reduce a bit if boilerplate you could also simply inline this like here:
https://github.com/typelevel/Laika/blob/main/core/shared/src/main/scala/laika/format/AST.scala#L41
Just quickly want to confirm that the post processor skeleton looks okay in my eyes. |
To test this I published the Some preamble in the build.sbt: import cats.effect.unsafe.implicits.global
import pink.cozydev.protosearch.analysis.DocsDirectory
import laika.io.model.FilePath
lazy val indexTask = taskKey[String]("Generates the index output") And then the task: indexTask := {
val userConfig = laikaConfig.value
val targetDir = (laikaAST / target).value
val parser = laika.sbt.Settings.parser.value
val tree = parser.use(_.fromInput(laikaInputs.value.delegate).parse).unsafeRunSync()
DocsDirectory.plaintextRenderer.use(
_.from(tree)
.toDirectory(FilePath.fromJavaFile(targetDir))(userConfig.encoding)
.render
).unsafeRunSync()
println(s"rendered to ${targetDir}")
root.toString()
} This rendered the So I am happy to say that I think we are on a good path here. And then I can get back to actually making the plaintext formatting reasonable, and the IndexFormat actually building an index. |
Here's the commit of the hacked build testing this out: |
It turns out I didn't need to publish Thank you @armanbilge suggesting this :) |
laikaIO/src/main/scala/pink/cozydev/protosearch/analysis/IndexFormat.scala
Outdated
Show resolved
Hide resolved
Co-authored-by: Sam Pillsworth <sam@blerf.ca>
Merging this and continuing the work in #148 |
This PR upgrades to laika 1.0.0
The two important pieces are:
Plaintext
which implementsRenderFormat[Formatter]
IndexFormat
which implements theTwoPhaseRenderFormat[Formatter, BinaryPostProcessor.Builder]
Plaintext
runs on every document.IndexFormat
renders a tree of documents that have been formatted withPlaintext
This follows the approach outlined in #102 (comment)
The
DocsDirectory
file is upgraded, but this really is not the intended way to use things going forward.