Exclude mini-toc from a chapter based on output class and wrong links formating

Post here questions and problems related to editing and publishing DITA content.
elisabete reis
Posts: 10
Joined: Thu Mar 10, 2022 6:07 pm

Exclude mini-toc from a chapter based on output class and wrong links formating

Post by elisabete reis »

Hi,
I need to have mini-toc in some chapters but not all. I have tried several approaches with no success.
Can you please tell me how I can hide the mini-toc for a chapter or a topicref that has outputclass="no-minitoc"?

Another issue is with how links are published in pdf.
I have the following css definition for links:

Code: Select all

*[class ~= "topic/xref"]:before {
	content: target-counters(attr(href), chapter-and-sections, ".") ". "  !important;	
}
*[class ~= "topic/xref"],
*[class ~= "topic/link"] {
    font-family : "Amadeus Neue", Symbol, SimSun, "Malgun Gothic", "Microsoft JhengHei" !important;
    text-decoration: underline;
    color: #2e70ce; 
    font-weight: 300 !important; 
    font-size: 14pt;
    line-height: 150%;
}
But when I run the pdf transformation some links have a bold underline, some not (images attached):. Why is this happening and how can i solve it?

Thanks,
Elisabete
links-example-minitoc.png
links-example.png
links-example2.png
You do not have the required permissions to view the files attached to this post.
julien_lacour
Posts: 818
Joined: Wed Oct 16, 2019 3:47 pm

Re: Exclude mini-toc from a chapter based on output class and wrong links formating

Post by julien_lacour »

Hi Elisabete,

You can remove the minitoc from topics with outputclass="no-minitoc" by using the following CSS rule:

Code: Select all

*[class ~= "topic/topic"][outputclass ~= "no-minitoc"] > *[class ~= "chapter/minitoc"] {
  display: none;
}
Regarding the bold links, the only I've found are in the minitoc, this is because by default in HTML5 outputs, the links are wrapped in <strong> elements, but you can remove them by using an XSLT extension. For this:
  1. Declare a new extension in your publishing template:

    Code: Select all

    <xslt>
      <extension file="merged2html5Extension.xsl" id="com.oxygenxml.pdf.css.xsl.merged2html5"/>
    </xslt>
    
  2. Add the following template in the merged2html5Extension.xsl stylesheet:

    Code: Select all

    <!-- Remove the <strong> node wrapping minitoc links -->
    <xsl:template match="strong[parent::*[contains(@class, 'topic/link')]]" mode="remove.br">
      <xsl:apply-templates mode="#current"/>
    </xsl:template>
    
If you have other bold links, please send us the DITA source file so we can reproduce on our side (you can randomize the content, no need to send the exact text).

Regards,
Julien
elisabete reis
Posts: 10
Joined: Thu Mar 10, 2022 6:07 pm

Re: Exclude mini-toc from a chapter based on output class and wrong links formating

Post by elisabete reis »

Hi,

thanks, the mini-toc is sorted out. But not the links.

This happens everywhere in the ditamap, not only in the mini-toc. And what is bold is the line under the link, not the link itself, for instance:
    In the image links-example the first and third links have an underline line ticker than the second one.
    links-example.png

    Code: Select all

     <li>
                    <p>Complete the fields as described in the relevant section:</p>
                    <ul>
                        <li><xref keyref="how-to-add-a-simple-rule-criterion-to-a-rule"/>.</li>  
                        <li><xref keyref="how-to-add-a-multiple-rule-criterion-to-a-rule"/>.</li>
                        <li><xref keyref="how-to-add-a-relative-rule-criterion-to-a-rule"/>.</li>
                    </ul>
                </li>
      In the image links-example2 both links have a ticker line for half of the link (after changing line).
      links-example2.png

      Code: Select all

            <li>
                      <p>Select the parameter and operator from the drop-down lists.</p>
                      <p>For more information, see <xref keyref="ap-pcv-parameters"/>. and <xref
                              keyref="ap-operators-and-wildcards"/>. </p>
                  </li>
      links-example2.png
      You do not have the required permissions to view the files attached to this post.
      julien_lacour
      Posts: 818
      Joined: Wed Oct 16, 2019 3:47 pm

      Re: Exclude mini-toc from a chapter based on output class and wrong links formating

      Post by julien_lacour »

      Hi Elisabete,

      If you increase the zoom in Acrobat, does the underlining remains thicker?
      This problem seems similar to disappearing thin lines in cells.

      Regards,
      Julien
      elisabete reis
      Posts: 10
      Joined: Thu Mar 10, 2022 6:07 pm

      Re: Exclude mini-toc from a chapter based on output class and wrong links formating

      Post by elisabete reis »

      Hi,

      With zoom the problem is the same but disabling the "Enhance thin lines" solved the problem.
      Thanks a lot :-)

      Elisabete
      elisabete reis
      Posts: 10
      Joined: Thu Mar 10, 2022 6:07 pm

      Re: Exclude mini-toc from a chapter based on output class and wrong links formating

      Post by elisabete reis »

      Hi,
      I found some situations where the code given to hide the mini-toc doesn't work properly, using this:

      Code: Select all

      *[class ~= "topic/topic"][outputclass ~= "no-minitoc"] > *[class ~= "chapter/minitoc"] {
        display: none;
      }
      It works if the topic does not have any text. If it has text in the body, then the text is also hidden, for example:
      this topic has a child but I don't want the minitoc to be displayed. I added the outputclass="no-minitoc" to the topic in the ditamap but the result is an empty topic with just the title:
      Code for the Topic:

      Code: Select all

      <?xml version="1.0" encoding="utf-8"?><!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd"[]>
      <topic id="how-to">
          <title>Introduction</title>
          <body>
              <p>This document explains how to use the application to define rules .</p>
               <p id="p-2">To ensure safe and correct operation, this manual should be read before using
                  the application. It should be kept in an accessible location and made available to
                  any personnel required to use the application.</p>
              <p id="p-4">The manufacturer reserves the right to carry out modifications to this manual
                  without prior notice.</p>
              <note id="note" type="note">The names of the users, and travelers' data presented in the
                  images of this manual are merely indicative.</note>
                  </body>
                  </topic>
      Code in the bookmap:

      Code: Select all

      <chapter keyref="introduction" outputclass="no-minitoc">
          <topicref keyref="about" outputclass="page-break"/>
        </chapter>
      And the result is this:
      mini-toc-empty.png
      How can I hide the mini-toc but display the text in the topic?

      Thanks,
      Elisabete Reis
      You do not have the required permissions to view the files attached to this post.
      julien_lacour
      Posts: 818
      Joined: Wed Oct 16, 2019 3:47 pm

      Re: Exclude mini-toc from a chapter based on output class and wrong links formating

      Post by julien_lacour »

      Hi Elisabete,

      You're right my first rule was too strict, you need to filter chapter/minitoc children:

      Code: Select all

      *[class ~= "topic/topic"][outputclass ~= "no-minitoc"] *[class ~= "chapter/minitoc-links"] {
        display: none;
      }
      /* Reset topic layout */
      *[class ~= "topic/topic"][outputclass ~= "no-minitoc"] *[class~="chapter/minitoc-desc"] {
        display: block;
        width: unset;
        padding-left: 0;
        border-left: none;
      }
      
      Regards,
      Julien
      elisabete reis
      Posts: 10
      Joined: Thu Mar 10, 2022 6:07 pm

      Re: Exclude mini-toc from a chapter based on output class and wrong links formating

      Post by elisabete reis »

      Hi,

      Now I have the content in the chapter but it is formatted as it was a minitoc.
      I have defined css to style the minitoc. So when I have a minitoc it looks like this:
      mini-toc-ok.png
      And now in the topics with outputclass="no-minitoc" I have the text but it looks like this:
      mini-toc-wrong.png
      My css for the minitoc is

      Code: Select all

      *[class ~= "topic/topic"][outputclass ~= "no-minitoc"] *[class ~= "chapter/minitoc-links"] {
        display: none;
      }
      /* Reset topic layout */
      *[class ~= "topic/topic"][outputclass ~= "no-minitoc"] *[class~="chapter/minitoc-desc"] {
        display: block;
        width: unset;
        padding-left: 0;
        border-left: none;
      }
      *[class ~= "topic/topic"] > *[class ~= "chapter/minitoc"]:not([outputclass ~= "no-minitoc"]) {
          border-style:solid;
          border-color:#DCDCDC;
          border-width:1pt;
          border-radius: 10px;
          width: 80%;
          margin-left: 30pt;
      }
      *[class~="chapter/minitoc-links"] *[class~="topic/desc"] {
      	display:none;
      }
      *[class~="chapter/minitoc-desc"], *[class~="chapter/minitoc-links"] {
          display:block;
          margin-left: 20pt;
          margin-bottom: 20pt;
          margin-right: 10pt;
      }
      *[class~="chapter/minitoc-links"] *[class~="topic/link"]{
          margin-bottom: 4px;
          margin-top: 4px;
      }
      *[class~="chapter/minitoc-links"] *[class~="topic/link"] a {
          color : var(--color-dark-sky);
          font-weight: normal;
          font-size: var(--default-font-size);
          line-height: 150%;
          text-decoration: underline;    
      }
      
      *[class~="chapter/minitoc-links"] *[class~="topic/link"] a::after {
          content: leader('-') target-counter(attr(href), page) !important;
          font-size : var(--default-font-size);
          font-weight : normal ;
          color : var(--color-dark-sky);
          text-decoration: underline;
      }
      
      *[class~="chapter/minitoc-links"] *[class~="topic/link"] a::before {
          content: target-counters(attr(href), chapter-and-sections, ".") ". "  !important;
      	text-decoration: underline
      }
      What am I doing wrong?
      You do not have the required permissions to view the files attached to this post.
      elisabete reis
      Posts: 10
      Joined: Thu Mar 10, 2022 6:07 pm

      Re: Exclude mini-toc from a chapter based on output class and wrong links formating

      Post by elisabete reis »

      Hi,

      I found how to solve the issue. :D

      Code: Select all

      *[class ~= "topic/topic"]:not([outputclass ~= "no-minitoc"]) > *[class ~= "chapter/minitoc"] {
          border-style:solid;
          border-color:var(--default-link-color);
          border-width:1pt;
          border-radius: 10px;
          width: 80%;
          margin-left: 30pt;
      }
      thanks for the support,
      elisabete
      Post Reply