diff --git a/core/shared/src/main/scala/laika/format/Markdown.scala b/core/shared/src/main/scala/laika/format/Markdown.scala index fe06b964e..d8ce192ea 100644 --- a/core/shared/src/main/scala/laika/format/Markdown.scala +++ b/core/shared/src/main/scala/laika/format/Markdown.scala @@ -16,10 +16,17 @@ package laika.format -import laika.api.bundle.{ BlockParserBuilder, ExtensionBundle, SpanParserBuilder } +import laika.api.bundle.{ + BlockParserBuilder, + BundleOrigin, + ExtensionBundle, + ParserBundle, + SpanParserBuilder +} import laika.api.format.MarkupFormat import laika.ast.Block import laika.markdown.bundle.VerbatimHTML +import laika.markdown.github.* import laika.markdown.{ BlockParsers, InlineParsers, ListParsers } import laika.parse.Parser import laika.parse.text.{ CharGroup, TextParsers } @@ -170,6 +177,48 @@ case object Markdown extends MarkupFormat { val extensions: Seq[ExtensionBundle] = Seq(VerbatimHTML) + /** Extension bundle that enables GitHub-Flavored Markdown on top of standard Markdown. + * + * The extension can be added to a transformer like any other extension: + * + * {{{ + * val transformer = Transformer + * .from(Markdown) + * .to(HTML) + * .using(GitHubFlavor) + * .build + * }}} + * + * These are the parsers this extension adds to standard Markdown: + * + * - strikethrough + * - auto-links (urls and email addresses) + * - fenced code blocks + * - tables + * + * @author Jens Halm + */ + object GitHubFlavor extends ExtensionBundle { + + val description: String = "Github-flavored Markdown" + + override val origin: BundleOrigin = BundleOrigin.Parser + + override def parsers: ParserBundle = new ParserBundle( + blockParsers = Seq( + Tables.parser + ) ++ FencedCodeBlocks.parsers, + spanParsers = Seq( + Strikethrough.parser, + AutoLinks.parsers.www, + AutoLinks.parsers.http, + AutoLinks.parsers.email + ) + ) + + override def forStrictMode: Option[ExtensionBundle] = None + } + override def createBlockListParser(parser: Parser[Block]): Parser[Seq[Block]] = super.createBlockListParser(BlockParsers.insignificantSpaces ~> parser) diff --git a/core/shared/src/main/scala/laika/markdown/github/AutoLinks.scala b/core/shared/src/main/scala/laika/markdown/github/AutoLinks.scala index 2f95f2453..40327ef5e 100644 --- a/core/shared/src/main/scala/laika/markdown/github/AutoLinks.scala +++ b/core/shared/src/main/scala/laika/markdown/github/AutoLinks.scala @@ -29,7 +29,7 @@ import laika.parse.uri.AutoLinkParsers * * @author Jens Halm */ -private[github] object AutoLinks { +private[laika] object AutoLinks { private val startChars = NonEmptySet.of('*', '_', '~', '(', ' ', '\n') private val endChars = NonEmptySet.of('*', '_', '~', ')', '?', '!', '.', ',', ':', ' ', '\n') diff --git a/core/shared/src/main/scala/laika/markdown/github/FencedCodeBlocks.scala b/core/shared/src/main/scala/laika/markdown/github/FencedCodeBlocks.scala index 3e07864b5..4e4db530e 100644 --- a/core/shared/src/main/scala/laika/markdown/github/FencedCodeBlocks.scala +++ b/core/shared/src/main/scala/laika/markdown/github/FencedCodeBlocks.scala @@ -29,7 +29,7 @@ import laika.parse.{ BlockSource, Failure, Parser, Success } * * @author Jens Halm */ -private[github] object FencedCodeBlocks { +private[laika] object FencedCodeBlocks { private def reverse(offset: Int, p: => Parser[String]): Parser[String] = Parser { in => p.parse(in.reverse.consume(offset)) match { diff --git a/core/shared/src/main/scala/laika/markdown/github/GitHubFlavor.scala b/core/shared/src/main/scala/laika/markdown/github/GitHubFlavor.scala deleted file mode 100644 index 6705552bd..000000000 --- a/core/shared/src/main/scala/laika/markdown/github/GitHubFlavor.scala +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package laika.markdown.github - -import laika.api.bundle.{ BundleOrigin, ExtensionBundle, ParserBundle } - -/** Extension bundle that enables GitHub-Flavored Markdown on top of standard Markdown. - * - * The extension can be added to a transformer like any other extension: - * - * {{{ - * val transformer = Transformer - * .from(Markdown) - * .to(HTML) - * .using(GitHubFlavor) - * .build - * }}} - * - * These are the parsers this extension adds to standard Markdown: - * - * - strikethrough - * - auto-links (urls and email addresses) - * - fenced code blocks - * - tables - * - * @author Jens Halm - */ -object GitHubFlavor extends ExtensionBundle { - - val description: String = "Github-flavored Markdown" - - override val origin: BundleOrigin = BundleOrigin.Parser - - override def parsers: ParserBundle = new ParserBundle( - blockParsers = Seq( - Tables.parser - ) ++ FencedCodeBlocks.parsers, - spanParsers = Seq( - Strikethrough.parser, - AutoLinks.parsers.www, - AutoLinks.parsers.http, - AutoLinks.parsers.email - ) - ) - - override def forStrictMode: Option[ExtensionBundle] = None -} diff --git a/core/shared/src/main/scala/laika/markdown/github/Strikethrough.scala b/core/shared/src/main/scala/laika/markdown/github/Strikethrough.scala index bf88c4767..c1aade082 100644 --- a/core/shared/src/main/scala/laika/markdown/github/Strikethrough.scala +++ b/core/shared/src/main/scala/laika/markdown/github/Strikethrough.scala @@ -26,7 +26,7 @@ import laika.markdown.InlineParsers.enclosedByDoubleChar * * @author Jens Halm */ -private[github] object Strikethrough { +private[laika] object Strikethrough { val parser: SpanParserBuilder = SpanParserBuilder.recursive { implicit recParsers => enclosedByDoubleChar('~').map { Deleted(_) } diff --git a/core/shared/src/main/scala/laika/markdown/github/Tables.scala b/core/shared/src/main/scala/laika/markdown/github/Tables.scala index 97233be2d..2b238f08c 100644 --- a/core/shared/src/main/scala/laika/markdown/github/Tables.scala +++ b/core/shared/src/main/scala/laika/markdown/github/Tables.scala @@ -30,7 +30,7 @@ import laika.parse.implicits._ * * @author Jens Halm */ -private[github] object Tables { +private[laika] object Tables { val parser: BlockParserBuilder = BlockParserBuilder.withSpans { spanParsers => def cell(textParser: Parser[LineSource], cellType: CellType): Parser[Cell] = diff --git a/core/shared/src/test/scala/laika/config/OperationConfigSpec.scala b/core/shared/src/test/scala/laika/config/OperationConfigSpec.scala index c8a171bf1..c060468a0 100644 --- a/core/shared/src/test/scala/laika/config/OperationConfigSpec.scala +++ b/core/shared/src/test/scala/laika/config/OperationConfigSpec.scala @@ -27,7 +27,7 @@ import laika.bundle.BundleProvider import MarkupFormat.MarkupParsers import laika.api.bundle.{ BlockParserBuilder, BundleOrigin, ExtensionBundle, SpanParserBuilder } import laika.markdown.bundle.VerbatimHTML -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown.GitHubFlavor import munit.FunSuite /** @author Jens Halm diff --git a/core/shared/src/test/scala/laika/markdown/GitHubFlavorSpec.scala b/core/shared/src/test/scala/laika/markdown/GitHubFlavorSpec.scala index 402654ee0..d4c3ef3e4 100644 --- a/core/shared/src/test/scala/laika/markdown/GitHubFlavorSpec.scala +++ b/core/shared/src/test/scala/laika/markdown/GitHubFlavorSpec.scala @@ -17,10 +17,9 @@ package laika.markdown import laika.api.builder.OperationConfig -import laika.ast._ +import laika.ast.* import laika.ast.sample.ParagraphCompanionShortcuts import laika.format.Markdown -import laika.markdown.github.GitHubFlavor import laika.parse.Parser import laika.parse.markup.RootParser import munit.FunSuite @@ -30,7 +29,7 @@ class GitHubFlavorSpec extends FunSuite with ParagraphCompanionShortcuts { val rootParser = new RootParser( Markdown, new OperationConfig(Markdown.extensions) - .withBundles(Seq(GitHubFlavor)).markupExtensions + .withBundles(Seq(Markdown.GitHubFlavor)).markupExtensions ) val defaultParser: Parser[RootElement] = rootParser.rootElement diff --git a/core/shared/src/test/scala/laika/parse/PositionTrackingSpec.scala b/core/shared/src/test/scala/laika/parse/PositionTrackingSpec.scala index 5a7844469..8527a6218 100644 --- a/core/shared/src/test/scala/laika/parse/PositionTrackingSpec.scala +++ b/core/shared/src/test/scala/laika/parse/PositionTrackingSpec.scala @@ -19,14 +19,13 @@ package laika.parse import laika.api.MarkupParser import laika.api.errors.ParserError import laika.format.Markdown -import laika.markdown.github.GitHubFlavor import munit.FunSuite /** @author Jens Halm */ class PositionTrackingSpec extends FunSuite { - private val parser = MarkupParser.of(Markdown).using(GitHubFlavor).build + private val parser = MarkupParser.of(Markdown).using(Markdown.GitHubFlavor).build def parseAndExtractMessage(input: String): String = parser.parse(input) match { case Left(ParserError(message)) => message diff --git a/core/shared/src/test/scala/laika/parse/code/languages/LanguageSpec.scala b/core/shared/src/test/scala/laika/parse/code/languages/LanguageSpec.scala index 0d35bac83..da245efa5 100644 --- a/core/shared/src/test/scala/laika/parse/code/languages/LanguageSpec.scala +++ b/core/shared/src/test/scala/laika/parse/code/languages/LanguageSpec.scala @@ -21,7 +21,6 @@ import laika.api.errors.ParserError import laika.ast.* import laika.config.{ LaikaKeys, SyntaxHighlighting } import laika.format.Markdown -import laika.markdown.github.GitHubFlavor import laika.parse.code.CodeCategory import laika.parse.code.CodeCategory.* import munit.FunSuite @@ -32,7 +31,7 @@ class LanguageSpec extends FunSuite { private val parser = MarkupParser .of(Markdown) - .using(GitHubFlavor, SyntaxHighlighting) + .using(Markdown.GitHubFlavor, SyntaxHighlighting) .withConfigValue(LaikaKeys.firstHeaderAsTitle, true) .build diff --git a/docs/src/02-running-laika/01-sbt-plugin.md b/docs/src/02-running-laika/01-sbt-plugin.md index f14f2e9a5..7b5d30a97 100644 --- a/docs/src/02-running-laika/01-sbt-plugin.md +++ b/docs/src/02-running-laika/01-sbt-plugin.md @@ -285,10 +285,10 @@ Register implementations of the `ExtensionBundle` API, either provided by the li Example: ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown import laika.config.SyntaxHighlighting -laikaExtensions := Seq(GitHubFlavor, SyntaxHighlighting) +laikaExtensions := Seq(Markdown.GitHubFlavor, SyntaxHighlighting) ``` - [Overriding Renderers]: adjust the rendered output for specific AST node types. diff --git a/docs/src/02-running-laika/02-library-api.md b/docs/src/02-running-laika/02-library-api.md index f8ca1a3a5..2c018f6cd 100644 --- a/docs/src/02-running-laika/02-library-api.md +++ b/docs/src/02-running-laika/02-library-api.md @@ -128,12 +128,10 @@ The instances are immutable and thread-safe. Example for creating a transformer for Markdown, including the GitHub-Flavor extensions: ```scala mdoc:silent -import laika.markdown.github.GitHubFlavor - val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .build ``` @@ -194,13 +192,12 @@ from cats.IO for initialization: ```scala mdoc import cats.effect.{ Async, Resource } import laika.io.api.TreeTransformer -import laika.markdown.github.GitHubFlavor def createTransformer[F[_]: Async]: Resource[F, TreeTransformer[F]] = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[F] .build ``` @@ -338,7 +335,7 @@ as well as copying static files over to the target directory. val transformerIO = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .build ``` @@ -366,7 +363,7 @@ merging all content from the input directories into a single, linearized e-book: val epubTransformer = Transformer .from(Markdown) .to(EPUB) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .build @@ -511,7 +508,7 @@ First we set up a parser and its configuration. We create a parallel parser that is capable of reading from a directory: ```scala mdoc:silent -val parserBuilder = MarkupParser.of(Markdown).using(GitHubFlavor) +val parserBuilder = MarkupParser.of(Markdown).using(Markdown.GitHubFlavor) val parser = parserBuilder.parallel[IO].build @@ -628,7 +625,7 @@ val theme = Helium.defaults val heliumTransformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .withTheme(theme) .build @@ -697,7 +694,7 @@ import laika.preview.ServerBuilder val parser = MarkupParser .of(Markdown) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .build diff --git a/docs/src/02-running-laika/03-configuration.md b/docs/src/02-running-laika/03-configuration.md index f5b54fd1a..73c0e3ae8 100644 --- a/docs/src/02-running-laika/03-configuration.md +++ b/docs/src/02-running-laika/03-configuration.md @@ -108,12 +108,11 @@ laikaConfig := LaikaConfig.defaults.strict ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .strict .build ``` @@ -151,12 +150,11 @@ laikaConfig := LaikaConfig.defaults.withRawContent ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withRawContent .build ``` @@ -254,12 +252,11 @@ laikaConfig := LaikaConfig.defaults import laika.api._ import laika.format._ import laika.ast.MessageFilter -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .failOnMessages(MessageFilter.None) .renderMessages(MessageFilter.Error) .build @@ -347,12 +344,11 @@ laikaConfig := LaikaConfig.defaults ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue("version.latest", "2.4.6") .withConfigValue("license", "Apache 2.0") .build diff --git a/docs/src/03-preparing-content/01-directory-structure.md b/docs/src/03-preparing-content/01-directory-structure.md index aa7023756..0151652b4 100644 --- a/docs/src/03-preparing-content/01-directory-structure.md +++ b/docs/src/03-preparing-content/01-directory-structure.md @@ -69,12 +69,11 @@ laikaConfig := LaikaConfig.defaults import laika.config.LaikaKeys import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LaikaKeys.titleDocuments.inputName, "title") .withConfigValue(LaikaKeys.titleDocuments.outputName, "title") .build diff --git a/docs/src/03-preparing-content/02-navigation.md b/docs/src/03-preparing-content/02-navigation.md index 6950190b2..bf44573a4 100644 --- a/docs/src/03-preparing-content/02-navigation.md +++ b/docs/src/03-preparing-content/02-navigation.md @@ -75,12 +75,11 @@ import laika.api._ import laika.ast.Path.Root import laika.config.LinkValidation import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkValidation.Global(excluded = Seq(Root / "generated"))) .build ``` @@ -143,12 +142,11 @@ laikaConfig := LaikaConfig.defaults import laika.api._ import laika.config.{ LinkConfig, TargetDefinition } import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkConfig.empty .addTargets( TargetDefinition.external("Example 1", "https://example1.com/"), @@ -263,12 +261,11 @@ laikaConfig := LaikaConfig.defaults import laika.api._ import laika.config.{ LinkConfig, ApiLinks } import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkConfig.empty .addApiLinks(ApiLinks(baseUri = "https://example.com/api")) ) @@ -297,12 +294,11 @@ laikaConfig := LaikaConfig.defaults import laika.api._ import laika.config.{ LinkConfig, ApiLinks } import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkConfig.empty .addApiLinks(ApiLinks("https://example.com/api")) .addApiLinks(ApiLinks("https://somewhere-else/").withPackagePrefix("com.lib42")) @@ -345,13 +341,12 @@ laikaConfig := LaikaConfig.defaults ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor import laika.config.{ LinkConfig, SourceLinks } val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkConfig.empty .addSourceLinks( SourceLinks(baseUri = "https://github.com/team/project", suffix = "scala") @@ -387,13 +382,12 @@ laikaConfig := LaikaConfig.defaults ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor import laika.config.{ LinkConfig, SourceLinks } val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkConfig.empty .addSourceLinks(SourceLinks( baseUri = "https://github.com/team/project", @@ -610,12 +604,11 @@ laikaConfig := LaikaConfig.defaults import laika.api._ import laika.config.AutonumberConfig import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(AutonumberConfig.allEnabled.withMaxDepth(3)) .build ``` diff --git a/docs/src/03-preparing-content/04-ebooks.md b/docs/src/03-preparing-content/04-ebooks.md index 1f6e6056c..957b062e5 100644 --- a/docs/src/03-preparing-content/04-ebooks.md +++ b/docs/src/03-preparing-content/04-ebooks.md @@ -35,12 +35,11 @@ import cats.effect.IO import laika.api._ import laika.format._ import laika.io.implicits._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(EPUB) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .build diff --git a/docs/src/03-preparing-content/05-syntax-highlighting.md b/docs/src/03-preparing-content/05-syntax-highlighting.md index 63c396e28..41071b1dc 100644 --- a/docs/src/03-preparing-content/05-syntax-highlighting.md +++ b/docs/src/03-preparing-content/05-syntax-highlighting.md @@ -26,10 +26,10 @@ so that you can still choose other existing solutions if you prefer. When using the sbt plugin it can be added to the `laikaExtensions` setting: ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown import laika.config.SyntaxHighlighting -laikaExtensions ++= Seq(GitHubFlavor, SyntaxHighlighting) +laikaExtensions ++= Seq(Markdown.GitHubFlavor, SyntaxHighlighting) ``` Note that you also have to add the `GitHubFlavor` extension so that you get the support for fenced code blocks. @@ -40,13 +40,12 @@ When using the Library API highlighting can be activated like all other extensio ```scala mdoc:silent import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor import laika.config.SyntaxHighlighting val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor, SyntaxHighlighting) + .using(Markdown.GitHubFlavor, SyntaxHighlighting) .build ``` @@ -160,7 +159,7 @@ object MyHighlighter extends SyntaxHighlighter { } laikaExtensions ++= Seq( - GitHubFlavor, + Markdown.GitHubFlavor, SyntaxHighlighting.withSyntax(MyHighlighter) ) ``` diff --git a/docs/src/05-extending-laika/01-overview.md b/docs/src/05-extending-laika/01-overview.md index eefc541a1..c4ab47b43 100644 --- a/docs/src/05-extending-laika/01-overview.md +++ b/docs/src/05-extending-laika/01-overview.md @@ -72,10 +72,10 @@ import laika.sbt.LaikaPlugin.autoImport._ ``` ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown laikaExtensions := Seq( - GitHubFlavor, + Markdown.GitHubFlavor, MyExtensions ) ``` @@ -84,12 +84,11 @@ laikaExtensions := Seq( ```scala mdoc:silent import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .using(MyExtensions) .build ``` diff --git a/docs/src/05-extending-laika/03-implementing-directives.md b/docs/src/05-extending-laika/03-implementing-directives.md index cd1a85ea1..83e92e175 100644 --- a/docs/src/05-extending-laika/03-implementing-directives.md +++ b/docs/src/05-extending-laika/03-implementing-directives.md @@ -220,10 +220,10 @@ import laika.sbt.LaikaPlugin.autoImport._ ``` ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown laikaExtensions := Seq( - GitHubFlavor, + Markdown.GitHubFlavor, MyDirectives ) ``` @@ -232,12 +232,11 @@ laikaExtensions := Seq( ```scala mdoc:silent import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .using(MyDirectives) .build ``` @@ -299,7 +298,7 @@ laikaConfig := LaikaConfig.defaults val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue("ticket.baseURL", "https://example.com/issues") .build ``` diff --git a/docs/src/05-extending-laika/04-writing-parser-extensions.md b/docs/src/05-extending-laika/04-writing-parser-extensions.md index a6478ac7f..956fce541 100644 --- a/docs/src/05-extending-laika/04-writing-parser-extensions.md +++ b/docs/src/05-extending-laika/04-writing-parser-extensions.md @@ -135,10 +135,10 @@ import laika.sbt.LaikaPlugin.autoImport._ ``` ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown laikaExtensions := Seq( - GitHubFlavor, + Markdown.GitHubFlavor, TicketSyntax ) ``` @@ -147,12 +147,11 @@ laikaExtensions := Seq( ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .using(TicketSyntax) .build ``` @@ -225,12 +224,11 @@ laikaConfig := LaikaConfig.defaults ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue("ticket.baseURL", "https://example.com/issues") .build ``` @@ -408,10 +406,10 @@ Finally you can register your extension together with any built-in extensions yo @:choice(sbt) ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown laikaExtensions := Seq( - GitHubFlavor, + Markdown.GitHubFlavor, QuotedBlocks ) ``` @@ -420,12 +418,11 @@ laikaExtensions := Seq( ```scala mdoc:silent import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val extendedTransformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .using(QuotedBlocks) .build ``` diff --git a/docs/src/05-extending-laika/06-adding-syntax-highlighters.md b/docs/src/05-extending-laika/06-adding-syntax-highlighters.md index 13a5d9ccf..afffc589e 100644 --- a/docs/src/05-extending-laika/06-adding-syntax-highlighters.md +++ b/docs/src/05-extending-laika/06-adding-syntax-highlighters.md @@ -399,10 +399,10 @@ import laika.sbt.LaikaPlugin.autoImport._ ``` ```scala mdoc:compile-only -import laika.markdown.github.GitHubFlavor +import laika.format.Markdown laikaExtensions := Seq( - GitHubFlavor, + Markdown.GitHubFlavor, MyExtensions ) ``` @@ -411,12 +411,11 @@ laikaExtensions := Seq( ```scala mdoc:silent import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .using(MyExtensions) .build ``` diff --git a/docs/src/07-reference/01-standard-directives.md b/docs/src/07-reference/01-standard-directives.md index d2fa74da4..3516d9900 100644 --- a/docs/src/07-reference/01-standard-directives.md +++ b/docs/src/07-reference/01-standard-directives.md @@ -229,12 +229,11 @@ import laika.ast._ import laika.api._ import laika.config.IconRegistry import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(IconRegistry("open" -> IconStyle("open"), "close" -> IconGlyph('\ueedd'))) .build ``` @@ -384,12 +383,11 @@ laikaConfig := LaikaConfig.defaults import laika.api._ import laika.config.{ ChoiceConfig, SelectionConfig, Selections } import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(Selections( SelectionConfig("config", ChoiceConfig("sbt", "sbt Plugin"), @@ -419,7 +417,7 @@ laikaConfig := LaikaConfig.defaults.strict val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .strict .build ``` diff --git a/docs/src/07-reference/02-substitution-variables.md b/docs/src/07-reference/02-substitution-variables.md index 02598285e..103f0b13c 100644 --- a/docs/src/07-reference/02-substitution-variables.md +++ b/docs/src/07-reference/02-substitution-variables.md @@ -142,12 +142,11 @@ laikaConfig := LaikaConfig.defaults ```scala mdoc:compile-only import laika.api._ import laika.format._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue("project.version", "2.4.6") .build ``` diff --git a/docs/src/07-reference/07-migration-guide.md b/docs/src/07-reference/07-migration-guide.md index b22a044cc..f3aecc805 100644 --- a/docs/src/07-reference/07-migration-guide.md +++ b/docs/src/07-reference/07-migration-guide.md @@ -35,7 +35,7 @@ val blocker = Blocker.liftExecutionContext( val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .io(blocker) .parallel[IO] .build @@ -48,12 +48,11 @@ import cats.effect.IO import laika.api._ import laika.format._ import laika.io.implicits._ -import laika.markdown.github.GitHubFlavor val transformer = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .build ``` diff --git a/io/src/test/scala/laika/helium/HeliumFORendererSpec.scala b/io/src/test/scala/laika/helium/HeliumFORendererSpec.scala index 0682918ce..be14b1c79 100644 --- a/io/src/test/scala/laika/helium/HeliumFORendererSpec.scala +++ b/io/src/test/scala/laika/helium/HeliumFORendererSpec.scala @@ -27,7 +27,6 @@ import laika.helium.config.ColorQuintet import laika.io.api.TreeTransformer import laika.io.helper.{ InputBuilder, ResultExtractor, StringOps } import laika.io.implicits._ -import laika.markdown.github.GitHubFlavor import laika.theme.ThemeProvider import laika.theme.config.Color import munit.CatsEffectSuite @@ -41,7 +40,7 @@ class HeliumFORendererSpec extends CatsEffectSuite with InputBuilder with Result .from(Markdown) .to(XSLFO) .using( - GitHubFlavor, + Markdown.GitHubFlavor, SyntaxHighlighting ) .parallel[IO] diff --git a/io/src/test/scala/laika/helium/HeliumHTMLHeadSpec.scala b/io/src/test/scala/laika/helium/HeliumHTMLHeadSpec.scala index 6a63f5a5f..fdfbbf523 100644 --- a/io/src/test/scala/laika/helium/HeliumHTMLHeadSpec.scala +++ b/io/src/test/scala/laika/helium/HeliumHTMLHeadSpec.scala @@ -27,7 +27,6 @@ import laika.io.api.{ TreeParser, TreeRenderer, TreeTransformer } import laika.io.helper.{ InputBuilder, ResultExtractor, StringOps, TestThemeBuilder } import laika.io.implicits.* import laika.io.model.InputTree -import laika.markdown.github.GitHubFlavor import laika.theme.ThemeProvider import laika.theme.config.{ CrossOrigin, @@ -46,7 +45,7 @@ class HeliumHTMLHeadSpec extends CatsEffectSuite with InputBuilder with ResultEx val parser: Resource[IO, TreeParser[IO]] = MarkupParser .of(Markdown) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .parallel[IO] .build @@ -67,7 +66,7 @@ class HeliumHTMLHeadSpec extends CatsEffectSuite with InputBuilder with ResultEx def transformer(theme: ThemeProvider): Resource[IO, TreeTransformer[IO]] = Transformer .from(Markdown) .to(HTML) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .withConfigValue(LinkValidation.Local) .parallel[IO] .withTheme(theme) diff --git a/io/src/test/scala/laika/helium/HeliumRenderOverridesSpec.scala b/io/src/test/scala/laika/helium/HeliumRenderOverridesSpec.scala index f9bcd6043..85a442117 100644 --- a/io/src/test/scala/laika/helium/HeliumRenderOverridesSpec.scala +++ b/io/src/test/scala/laika/helium/HeliumRenderOverridesSpec.scala @@ -28,7 +28,6 @@ import laika.helium.config.{ AnchorPlacement, HeliumIcon } import laika.io.api.TreeTransformer import laika.io.helper.{ InputBuilder, ResultExtractor, StringOps } import laika.io.implicits.* -import laika.markdown.github.GitHubFlavor import laika.theme.* import munit.CatsEffectSuite @@ -43,7 +42,8 @@ class HeliumRenderOverridesSpec extends CatsEffectSuite with InputBuilder with R theme: ThemeProvider, configure: ConfigureTransformer ): Resource[IO, TreeTransformer[IO]] = { - val builder = Transformer.from(Markdown).to(HTML).using(GitHubFlavor, SyntaxHighlighting) + val builder = + Transformer.from(Markdown).to(HTML).using(Markdown.GitHubFlavor, SyntaxHighlighting) configure(builder) .parallel[IO] .withTheme(theme) diff --git a/io/src/test/scala/laika/helium/LineEstimatesSpec.scala b/io/src/test/scala/laika/helium/LineEstimatesSpec.scala index 10d2c4923..154e249f7 100644 --- a/io/src/test/scala/laika/helium/LineEstimatesSpec.scala +++ b/io/src/test/scala/laika/helium/LineEstimatesSpec.scala @@ -19,7 +19,6 @@ package laika.helium import laika.api.{ MarkupParser, RenderPhaseRewrite } import laika.format.{ AST, Markdown } import laika.helium.builder.HeliumRewriteRules -import laika.markdown.github.GitHubFlavor import munit.FunSuite /** @author Jens Halm @@ -28,7 +27,7 @@ class LineEstimatesSpec extends FunSuite with RenderPhaseRewrite { private val parser = MarkupParser .of(Markdown) - .using(GitHubFlavor) + .using(Markdown.GitHubFlavor) .build def run(input: String, expected: Int)(implicit loc: munit.Location): Unit = {