Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version = 3.8.6

runner.dialect = scala212
runner.dialect = scala212source3

maxColumn = 100

Expand All @@ -26,3 +26,5 @@ spaces.inImportCurlyBraces=true
spaces.afterSymbolicDefs=true

binPack.parentConstructors = keep
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.newSyntax.control = false
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ReStructuredTextToHTMLSpec extends FunSuite {
fmt.element(
"a",
sl.withStyles("reference", "external"),
fmt.optAttributes("href" -> Some(url), "title" -> title) *
fmt.optAttributes("href" -> Some(url), "title" -> title)*
)
case it: InternalTarget =>
val relativePath = it.relativeTo(fmt.path).relativePath
Expand All @@ -122,7 +122,7 @@ class ReStructuredTextToHTMLSpec extends FunSuite {
fmt.optAttributes(
"href" -> Some("#" + relativePath.fragment.get),
"title" -> title
) *
)*
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package laika.api.builder

import laika.api.bundle.ExtensionBundle
import laika.ast.RewriteRules.{ RewritePhaseBuilder, RewriteRulesBuilder }
import laika.ast._
import laika.ast.*

/** API for specifying configuration options that apply to all
* kinds of operations that contain both, a parsing and a rendering step (only Transform API).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import laika.parse.text.PrefixedParser

/** Base trait for `SpanParserBuilder` and `BlockParserBuilder` APIs.
*/
sealed trait ParserBuilder[T <: ParserDefinition[_]] {
sealed trait ParserBuilder[T <: ParserDefinition[?]] {

/** Builds a block parser definition lazily by passing the recursive parsers
* of the host language.
Expand Down Expand Up @@ -105,7 +105,7 @@ class BlockParserBuilder private (
def createParser(recursiveParsers: RecursiveParsers): BlockParserDefinition = {
val p = parserFactory(recursiveParsers)
val startChars = p match {
case pp: PrefixedParser[_] => pp.startChars.toSortedSet
case pp: PrefixedParser[?] => pp.startChars.toSortedSet
case _ => Set.empty[Char]
}
new BlockParserDefinition(startChars, p, recursive, position, precedence, paragraphLineCheck)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class TagFormatter extends Formatter {
*/
def element(
tagName: String,
container: ElementContainer[_ <: Element],
container: ElementContainer[? <: Element],
attrs: (String, String)*
): String =
s"<$tagName${attributes(tagName, container, attrs)}>${children(container.content)}</$tagName>"
Expand All @@ -61,7 +61,7 @@ abstract class TagFormatter extends Formatter {
*/
def indentedElement(
tagName: String,
container: ElementContainer[_ <: Element],
container: ElementContainer[? <: Element],
attrs: (String, String)*
): String =
s"<$tagName${attributes(tagName, container, attrs)}>${
Expand Down
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/laika/ast/ElementTraversal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ trait ElementTraversal { this: Element =>
f(element)
}

def foreachInIterable(t: Iterable[_], f: Element => Unit): Unit = {
def foreachInIterable(t: Iterable[?], f: Element => Unit): Unit = {
t.foreach {
case e: Element => foreachInElement(e, f)
case t: Iterable[_] => foreachInIterable(t, f)
case t: Iterable[?] => foreachInIterable(t, f)
case _ => ()
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/laika/ast/OutputContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ object OutputContext {
override def productPrefix: String = "OutputContext"
}

def apply(format: RenderFormat[_]): OutputContext =
def apply(format: RenderFormat[?]): OutputContext =
Impl(format.fileSuffix, format.description.toLowerCase)

def apply(format: TwoPhaseRenderFormat[_, _]): OutputContext = apply(format.interimFormat)
def apply(format: TwoPhaseRenderFormat[?, ?]): OutputContext = apply(format.interimFormat)

}
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/laika/ast/RewriteRules.scala
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ case object RewritePhase {
case class Render(context: OutputContext) extends RewritePhase

object Render {
def apply(format: RenderFormat[_]): Render = apply(OutputContext(format))
def apply(format: TwoPhaseRenderFormat[_, _]): Render = apply(OutputContext(format))
def apply(format: RenderFormat[?]): Render = apply(OutputContext(format))
def apply(format: TwoPhaseRenderFormat[?, ?]): Render = apply(OutputContext(format))
}

}
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/laika/ast/documents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ case class StaticDocument(path: Path, formats: TargetFormats = TargetFormats.All
object StaticDocument {

def apply(path: Path, format: String, formats: String*): StaticDocument =
StaticDocument(path, TargetFormats.Selected(NonEmptySet.of(format, formats: _*)))
StaticDocument(path, TargetFormats.Selected(NonEmptySet.of(format, formats*)))

}

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/laika/config/Selections.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object Selections {
}

combinations.fold(NonEmptyChain.one(value))(_.map { combined =>
Selections((combined.toChain.toList ++ nonSeparated) *)
Selections((combined.toChain.toList ++ nonSeparated)*)
})
}

Expand Down
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/laika/config/TargetFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ object TargetFormats {
object Selected {

def apply(format: String, formats: String*): Selected = apply(
NonEmptySet.of(format, formats *)
NonEmptySet.of(format, formats*)
)

}

implicit val decoder: ConfigDecoder[TargetFormats] = ConfigDecoder.seq[String].map { formats =>
NonEmptySet.fromSet(TreeSet(formats *)).fold[TargetFormats](TargetFormats.None)(fs =>
NonEmptySet.fromSet(TreeSet(formats*)).fold[TargetFormats](TargetFormats.None)(fs =>
if (fs == NonEmptySet.one("*")) TargetFormats.All
else {
val pdfExtra = if (fs.contains("pdf")) Seq("fo", "xsl-fo") else Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private[laika] object NavigationTreeDirectives {
val noRoot = optExcludeRoot.getOrElse(excludeRoot)
val context = NavigationBuilderContext.defaults
.withRefPath(cursor.path)
.withItemStyles(itemStyles.toSeq *)
.withItemStyles(itemStyles.toSeq*)
.withMaxLevels(depth.getOrElse(defaultDepth))
.withExcludeSections(optExcludeSections.getOrElse(excludeSections))
.withExcludeSelf(excludeSelf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private[laika] object StandardDirectives extends DirectiveRegistry {

(positionalAttributes.as[String].widen, parsedBody.map(asBlock(_))).mapN { (formats, body) =>
NonEmptySet
.fromSet(TreeSet(formats: _*))
.fromSet(TreeSet(formats*))
.fold[Either[String, Block]](Left("no formats provided"))(set =>
Right(TargetFormat(set, body))
)
Expand All @@ -199,15 +199,15 @@ private[laika] object StandardDirectives extends DirectiveRegistry {
lazy val blockStyle: BlockDirectives.Directive = BlockDirectives.create("style") {
import laika.api.bundle.BlockDirectives.dsl.*

(parsedBody, positionalAttributes.as[String].map(Styles(_: _*))).mapN(asBlock)
(parsedBody, positionalAttributes.as[String].map(Styles(_*))).mapN(asBlock)
}

/** Implementation of the `style` directive for span elements in markup documents.
*/
lazy val spanStyle: SpanDirectives.Directive = SpanDirectives.create("style") {
import laika.api.bundle.SpanDirectives.dsl.*

(parsedBody, positionalAttributes.as[String].map(Styles(_: _*))).mapN(asSpan)
(parsedBody, positionalAttributes.as[String].map(Styles(_*))).mapN(asSpan)
}

/** Implementation of the `icon` directive for span elements in markup documents.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private[laika] object BlockParsers {
def paragraph(firstLine: LineSource, restLines: Seq[LineSource]): Paragraph =
Paragraph(
recParsers.recursiveSpans.parseAndRecover(
BlockSource(processLineBreaks(firstLine), restLines.map(processLineBreaks): _*)
BlockSource(processLineBreaks(firstLine), restLines.map(processLineBreaks)*)
)
)

Expand All @@ -127,7 +127,7 @@ private[laika] object BlockParsers {
}

val linkTarget: BlockParserBuilder = BlockParserBuilder.withEscapedText { escapedParsers =>
import escapedParsers._
import escapedParsers.*

val id = "[" ~> escapedUntil(']').map(_.toLowerCase) <~ ":" <~ ws.void
val url =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package laika.internal.markdown.github
import cats.data.NonEmptySet
import laika.internal.parse.uri.AutoLinkParsers
import laika.parse.Parser
import laika.parse.builders._
import laika.parse.builders.*

/** Parsers for inline auto-links, which are urls or email addresses that are recognized and
* inserted as links into the AST without any surrounding markup delimiters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package laika.internal.markdown.github
import cats.data.NonEmptyChain
import laika.api.bundle.BlockParserBuilder
import laika.ast.{ CodeBlock, LiteralBlock, Span, Text }
import laika.parse.builders._
import laika.parse.syntax._
import laika.parse.builders.*
import laika.parse.syntax.*
import laika.parse.{ BlockSource, Failure, Parser, Success }

/** Parser for fenced code blocks as defined by GitHub Flavored Markdown and CommonMark.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package laika.internal.markdown.github

import laika.api.bundle.BlockParserBuilder
import laika.ast._
import laika.internal.markdown.BlockParsers._
import laika.ast.*
import laika.internal.markdown.BlockParsers.*
import laika.parse.{ LineSource, Parser }
import laika.parse.text.PrefixedParser
import laika.parse.builders._
import laika.parse.syntax._
import laika.parse.builders.*
import laika.parse.syntax.*

/** Parser for the table extension of GitHub Flavored Markdown.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package laika.internal.nav

import laika.api.config.Config
import laika.config.LaikaKeys
import laika.ast._
import laika.ast.*
import laika.api.config.Config.ConfigResult

/** Responsible for applying the navigation order to the contents of a document tree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private[laika] object DirectiveParsers {
def declarationParser(
supportsCustomFence: Boolean = false
): Parser[(String, ObjectBuilderValue, String)] = {
import HoconParsers._
import HoconParsers.*

val defaultFence = success("@:@")
val fence =
Expand Down Expand Up @@ -161,7 +161,7 @@ private[laika] object DirectiveParsers {
*/
private[laika] object SpanDirectiveParsers {

import DirectiveParsers._
import DirectiveParsers.*
import laika.api.bundle.SpanDirectives

val contextRef: SpanParserBuilder =
Expand All @@ -174,7 +174,7 @@ private[laika] object SpanDirectiveParsers {
directives: Map[String, SpanDirectives.Directive]
)(recParsers: RecursiveSpanParsers): PrefixedParser[Span] = {

import recParsers._
import recParsers.*

val separators = directives.values.flatMap(_.separators).toSet
val body: BodyParserBuilder = spec =>
Expand All @@ -198,7 +198,7 @@ private[laika] object SpanDirectiveParsers {
*/
private[laika] object BlockDirectiveParsers {

import DirectiveParsers._
import DirectiveParsers.*
import laika.api.bundle.BlockDirectives

def blockDirective(directives: Map[String, BlockDirectives.Directive]): BlockParserBuilder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private[internal] trait DefaultEscapedTextParsers extends EscapedTextParsers {
* spans. The final character is not included in the result.
*/
def escapedUntil(char: Char, chars: Char*): Parser[String] = escapedText(
TextParsers.delimitedBy(char, chars: _*).nonEmpty
TextParsers.delimitedBy(char, chars*).nonEmpty
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private[laika] object DocumentParser {

}

private def create[D, R <: ElementContainer[_]](
private def create[D, R <: ElementContainer[?]](
rootParser: Parser[R],
configParser: Parser[ConfigParser]
)(docFactory: (Path, ConfigParser, R) => D): DocumentInput => Either[ParserError, D] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private[laika] class RootParser(markupParser: MarkupFormat, markupExtensions: Ma
case BlockPosition.NestedOnly => lazily(nestedInterruptions)
}

private def createAndSortParsers[T <: ParserDefinition[_]](
private def createAndSortParsers[T <: ParserDefinition[?]](
mainParsers: Seq[ParserBuilder[T]],
extParsers: Seq[ParserBuilder[T]]
): Seq[T] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import laika.api.bundle.SpanParserBuilder
import laika.ast.{ Reverse, Span, SpanLink, Text }
import laika.parse.text.PrefixedParser
import laika.parse.{ Failure, Parser, Success }
import laika.parse.builders._
import laika.parse.syntax._
import laika.parse.builders.*
import laika.parse.syntax.*
import URIParsers.{ fragment, path, query, regName }

/** Parser for inline auto-links, which are urls or email addresses that are recognized and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package laika.internal.parse.uri

import laika.parse.Parser
import laika.parse.builders._
import laika.parse.syntax._
import laika.parse.builders.*
import laika.parse.syntax.*
import laika.parse.text.{ CharGroup, Characters }

/** Parses URIs as defined in RFC 3986 and email addresses as defined in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private[laika] object ASTRenderer extends ((Formatter, Element) => String) {
case tsc: TemplateSpanContainer => elementContainerDesc(tsc, "TemplateSpans")
case tc: TextContainer => textContainerDesc(tc)
case Content(content, desc, _) => desc + fmt.indentedChildren(content)
case ec: ElementContainer[_] => elementContainerDesc(ec, "Elements")
case ec: ElementContainer[?] => elementContainerDesc(ec, "Elements")
case e => renderElement(e)
}

Expand Down
20 changes: 10 additions & 10 deletions core/shared/src/main/scala/laika/internal/render/FOFormatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private[laika] class FOFormatter private (
def localId(ref: String): String = FOFormatter.localId(path, ref, pathTranslator)
val idAttr = element.options.id.map(id => "id" -> localId(id)).toSeq

attributes(filterAttributes(tag, idAttr ++ combinedAttrs) *)
attributes(filterAttributes(tag, idAttr ++ combinedAttrs)*)
}

}
Expand Down Expand Up @@ -119,31 +119,31 @@ private[laika] object FOFormatter extends (Formatter.Context[TagFormatter] => Ta

/** Renders an FO `block` element and its children on the same line.
*/
def block(container: ElementContainer[_ <: Element], attr: (String, String)*): String =
fmt.element("fo:block", container, attr *)
def block(container: ElementContainer[? <: Element], attr: (String, String)*): String =
fmt.element("fo:block", container, attr*)

/** Renders an FO `block` element and the specified nested spans,
* preserving all whitespace within the text elements of those spans.
*/
def blockWithWS(container: ElementContainer[_ <: Element], attr: (String, String)*): String =
fmt.withoutIndentation(_.element("fo:block", container, attr *))
def blockWithWS(container: ElementContainer[? <: Element], attr: (String, String)*): String =
fmt.withoutIndentation(_.element("fo:block", container, attr*))

/** Renders an FO `inline` element and its children on the same line.
*/
def inline(container: ElementContainer[_ <: Element], attr: (String, String)*): String =
fmt.element("fo:inline", container, attr *)
def inline(container: ElementContainer[? <: Element], attr: (String, String)*): String =
fmt.element("fo:inline", container, attr*)

/** Renders an FO `block` element, containing nested blocks.
* The content will be rendered indented one level to the right.
*/
def blockContainer(styleHint: Element, content: Seq[Block], attr: (String, String)*): String =
fmt.indentedElement("fo:block", styleHint, content, attr *)
fmt.indentedElement("fo:block", styleHint, content, attr*)

/** Renders an FO `list-block` element, and the specified list items.
* The content will be rendered indented one level to the right.
*/
def listBlock(container: ListContainer, attr: (String, String)*): String =
fmt.indentedElement("fo:list-block", container, attr *)
fmt.indentedElement("fo:list-block", container, attr*)

/** Renders an FO `list-item` element with the specified label and body.
* The content will be rendered indented one level to the right.
Expand All @@ -155,7 +155,7 @@ private[laika] object FOFormatter extends (Formatter.Context[TagFormatter] => Ta
attr: (String, String)*
): String = {
val content = List(ListItemLabel(Paragraph(label)), ListItemBody(body))
fmt.indentedElement("fo:list-item", styleHint, content, attr: _*)
fmt.indentedElement("fo:list-item", styleHint, content, attr*)
}

}
Expand Down
Loading