Skip to content

Commit

Permalink
Merge pull request #229 from jelovirt/feature/case-insensitive-admoni…
Browse files Browse the repository at this point in the history
…tion-type

Add support for case-insensitive admonition type
  • Loading branch information
jelovirt authored Aug 22, 2024
2 parents fd537e6 + 33b7c50 commit 7197c45
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private void render(final AbbreviationBlock node, final NodeRendererContext cont
private void render(final AdmonitionBlock node, final NodeRendererContext context, final SaxWriter html) {
final String type = node.getInfo().toString();
final AttributesBuilder atts = new AttributesBuilder(NOTE_ATTS);
switch (type) {
switch (type.toLowerCase()) {
case "note":
case "tip":
case "fastpath":
Expand All @@ -298,7 +298,7 @@ private void render(final AdmonitionBlock node, final NodeRendererContext contex
case "danger":
case "warning":
case "trouble":
atts.add("type", type);
atts.add("type", type.toLowerCase());
break;
default:
atts.add("type", "other").add("othertype", type);
Expand Down
22 changes: 13 additions & 9 deletions src/main/resources/dita2markdownImpl.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,14 @@
<xsl:call-template name="setidaname"/>
<!-- Normal flags go before the generated title; revision flags only go on the content. -->
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/prop" mode="ditaval-outputflag"/>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Caution'"/>
</xsl:call-template>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'ColonSymbol'"/>
</xsl:call-template>
<strong>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Caution'"/>
</xsl:call-template>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'ColonSymbol'"/>
</xsl:call-template>
</strong>
</div>
<div>
<xsl:call-template name="commonattributes">
Expand All @@ -514,9 +516,11 @@
<xsl:call-template name="setidaname"/>
<!-- Normal flags go before the generated title; revision flags only go on the content. -->
<xsl:apply-templates select="*[contains(@class, ' ditaot-d/ditaval-startprop ')]/prop" mode="ditaval-outputflag"/>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Danger'"/>
</xsl:call-template>
<strong>
<xsl:call-template name="getVariable">
<xsl:with-param name="id" select="'Danger'"/>
</xsl:call-template>
</strong>
</div>
<div>
<xsl:call-template name="commonattributes">
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/dita/admonition.dita
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<note class="- topic/note " type="trouble">
<p class="- topic/p ">block content</p>
</note>
<note class="- topic/note " type="caution">
<p class="- topic/p ">Uppercase type</p>
</note>
<ol class="- topic/ol ">
<li class="- topic/li ">
List item
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/markdown/admonition.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Open by default
!!! trouble ""
block content

!!! CAUTION
Uppercase type

1. List item
!!! note
block content
2 changes: 1 addition & 1 deletion src/test/resources/output/ast/admonition.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><pandoc><div><header id="admonition" level="1">Admonition</header><div><para>Block-Styled Side Content</para><div class="note"><para><strong>qualifier:</strong></para><para>Optional Title</para><para>block content</para><para>block content</para></div><para>No-Heading Content</para><div class="note"><para><strong>qualifier:</strong></para><para>block content</para></div><div class="note"><para><strong>qualifier:</strong></para><para>block content</para></div><para>Collapsible Block-Styled Side Content:</para><para>Collapsed by default</para><div class="note"><para><strong>qualifier:</strong></para><para>Optional Title</para><para>block content</para></div><para>Open by default</para><div class="note"><para><strong>qualifier:</strong></para><para>Optional Title</para><para>block content</para></div><div class="note"><para><strong>Note:</strong></para><para>block content</para></div><div class="tip"><para><strong>Tip:</strong></para><para>block content</para></div><div class="fastpath"><para><strong>Fastpath:</strong></para><para>block content</para></div><div class="restriction"><para><strong>Restriction:</strong></para><para>block content</para></div><div class="important"><para><strong>Important:</strong></para><para>block content</para></div><div class="remember"><para><strong>Remember:</strong></para><para>block content</para></div><div class="attention"><para><strong>Attention:</strong></para><para>block content</para></div><div class="cautiontitle"><para>Caution:</para></div><div class="caution"><para>block content</para></div><div class="note"><para><strong>Note:</strong></para><para>block content</para></div><div class="dangertitle"><para>Danger</para></div><div class="danger"><para>block content</para></div><div class="warning"><para><strong>Warning:</strong></para><para>block content</para></div><div class="trouble"><para><strong>Trouble:</strong></para><para>block content</para></div><orderedlist><li><plain>List item</plain><div class="note"><para><strong>Note:</strong></para><para>block content</para></div></li></orderedlist></div></div></pandoc>
<?xml version="1.0" encoding="UTF-8"?><pandoc><div><header id="admonition" level="1">Admonition</header><div><para>Block-Styled Side Content</para><div class="note"><para><strong>qualifier:</strong></para><para>Optional Title</para><para>block content</para><para>block content</para></div><para>No-Heading Content</para><div class="note"><para><strong>qualifier:</strong></para><para>block content</para></div><div class="note"><para><strong>qualifier:</strong></para><para>block content</para></div><para>Collapsible Block-Styled Side Content:</para><para>Collapsed by default</para><div class="note"><para><strong>qualifier:</strong></para><para>Optional Title</para><para>block content</para></div><para>Open by default</para><div class="note"><para><strong>qualifier:</strong></para><para>Optional Title</para><para>block content</para></div><div class="note"><para><strong>Note:</strong></para><para>block content</para></div><div class="tip"><para><strong>Tip:</strong></para><para>block content</para></div><div class="fastpath"><para><strong>Fastpath:</strong></para><para>block content</para></div><div class="restriction"><para><strong>Restriction:</strong></para><para>block content</para></div><div class="important"><para><strong>Important:</strong></para><para>block content</para></div><div class="remember"><para><strong>Remember:</strong></para><para>block content</para></div><div class="attention"><para><strong>Attention:</strong></para><para>block content</para></div><div class="cautiontitle"><para><strong>Caution:</strong></para></div><div class="caution"><para>block content</para></div><div class="note"><para><strong>Note:</strong></para><para>block content</para></div><div class="dangertitle"><para><strong>Danger</strong></para></div><div class="danger"><para>block content</para></div><div class="warning"><para><strong>Warning:</strong></para><para>block content</para></div><div class="trouble"><para><strong>Trouble:</strong></para><para>block content</para></div><div class="cautiontitle"><para><strong>Caution:</strong></para></div><div class="caution"><para>Uppercase type</para></div><orderedlist><li><plain>List item</plain><div class="note"><para><strong>Note:</strong></para><para>block content</para></div></li></orderedlist></div></div></pandoc>
2 changes: 1 addition & 1 deletion src/test/resources/output/ast/note.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><pandoc><div><header id="note" level="1">Note</header><div><div class="note"><para><strong>Note:</strong> Note</para></div><div class="cautiontitle"><para>Caution:</para></div><div class="caution"><para>Caution</para></div><div class="dangertitle"><para>Danger</para></div><div class="danger"><para>Danger</para></div><div class="note"><para><strong>Note:</strong> Note</para></div><div class="note"><para><strong>Note:</strong> Notice</para></div><div class="trouble"><para><strong>Trouble:</strong> Trouble</para></div><div class="warning"><para><strong>Warning:</strong> Warning</para></div></div></div></pandoc>
<?xml version="1.0" encoding="UTF-8"?><pandoc><div><header id="note" level="1">Note</header><div><div class="note"><para><strong>Note:</strong> Note</para></div><div class="cautiontitle"><para><strong>Caution:</strong></para></div><div class="caution"><para>Caution</para></div><div class="dangertitle"><para><strong>Danger</strong></para></div><div class="danger"><para>Danger</para></div><div class="note"><para><strong>Note:</strong> Note</para></div><div class="note"><para><strong>Note:</strong> Notice</para></div><div class="trouble"><para><strong>Trouble:</strong> Trouble</para></div><div class="warning"><para><strong>Warning:</strong> Warning</para></div></div></div></pandoc>
8 changes: 6 additions & 2 deletions src/test/resources/output/markdown/admonition.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ block content

block content

Caution:
**Caution:**

block content

**Note:**

block content

Danger
**Danger**

block content

Expand All @@ -86,6 +86,10 @@ block content

block content

**Caution:**

Uppercase type

1. List item

**Note:**
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/output/markdown/note.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

**Note:** Note

Caution:
**Caution:**

Caution

Danger
**Danger**

Danger

Expand Down

0 comments on commit 7197c45

Please sign in to comment.