@@ -722,31 +722,38 @@ public void visitPassthroughBlock(final PassthroughBlock element) {
722722
723723 @ Override
724724 public void visitOpenBlock (final OpenBlock element ) {
725- state .stackChain (element .children (), () -> {
726- boolean skipDiv = false ;
727- if (element .options ().get ("abstract" ) != null ) {
728- builder .append (" <div" );
729- writeCommonAttributes (element .options (), c -> "abstract quoteblock" + (c == null ? "" : (' ' + c )));
730- builder .append (">\n " );
731- } else if (element .options ().get ("partintro" ) != null ) {
732- builder .append (" <div" );
733- writeCommonAttributes (element .options (), c -> "openblock " + (c == null ? "" : (' ' + c )));
725+ switch (element .options ().getOrDefault ("" , "" )) {
726+ case "NOTE" -> visitAsAdmonition (Admonition .Level .NOTE , element );
727+ case "TIP" -> visitAsAdmonition (Admonition .Level .TIP , element );
728+ case "IMPORTANT" -> visitAsAdmonition (Admonition .Level .IMPORTANT , element );
729+ case "WARNING" -> visitAsAdmonition (Admonition .Level .WARNING , element );
730+ case "CAUTION" -> visitAsAdmonition (Admonition .Level .CAUTION , element );
731+ default -> state .stackChain (element .children (), () -> {
732+ boolean skipDiv = false ;
733+ if (element .options ().get ("abstract" ) != null ) {
734+ builder .append (" <div" );
735+ writeCommonAttributes (element .options (), c -> "abstract quoteblock" + (c == null ? "" : (' ' + c )));
736+ builder .append (">\n " );
737+ } else if (element .options ().get ("partintro" ) != null ) {
738+ builder .append (" <div" );
739+ writeCommonAttributes (element .options (), c -> "openblock " + (c == null ? "" : (' ' + c )));
740+ builder .append (">\n " );
741+ } else {
742+ skipDiv = true ;
743+ }
744+ writeBlockTitle (element .options ());
745+ builder .append (" <div" );
746+ if (skipDiv ) {
747+ writeCommonAttributes (element .options (), c -> "content" + (c == null ? "" : (' ' + c )));
748+ }
734749 builder .append (">\n " );
735- } else {
736- skipDiv = true ;
737- }
738- writeBlockTitle (element .options ());
739- builder .append (" <div" );
740- if (skipDiv ) {
741- writeCommonAttributes (element .options (), c -> "content" + (c == null ? "" : (' ' + c )));
742- }
743- builder .append (">\n " );
744- Visitor .super .visitOpenBlock (element );
745- builder .append (" </div>\n " );
746- if (!skipDiv ) {
747- builder .append (" </div>\n " );
748- }
749- });
750+ Visitor .super .visitOpenBlock (element );
751+ builder .append (" </div>\n " );
752+ if (!skipDiv ) {
753+ builder .append (" </div>\n " );
754+ }
755+ });
756+ }
750757 }
751758
752759 @ Override
@@ -1132,6 +1139,18 @@ private int extractNumbers(final String col) {
11321139 }
11331140 }
11341141
1142+ private void visitAsAdmonition (final Admonition .Level level , final OpenBlock element ) {
1143+ visitAdmonition (new Admonition (
1144+ level , element .children ().size () == 1 ?
1145+ element .children ().get (0 ) :
1146+ new Paragraph (element .children (),
1147+ element .options ().size () == 1 ?
1148+ Map .of () :
1149+ element .options ().entrySet ().stream ()
1150+ .filter (it -> !"" .equals (it .getKey ()))
1151+ .collect (toMap (Map .Entry ::getKey , Map .Entry ::getValue )))));
1152+ }
1153+
11351154 @ Getter
11361155 public static class Configuration {
11371156 private String sectionTag = "div" ;
0 commit comments