Code Monkey home page Code Monkey logo

fox.jason.pretty-dita's Introduction

Pretty DITA for DITA-OT

license DITA-OT 4.2 CI Coverage Status Quality Gate Status

This is a DITA prettifier DITA-OT Plug-in which formats DITA XML in an aesthetically pleasing manner. <topic> elements, <section> elements, <p> elements etc are regularly indented so the raw DITA XML files can be scanned by humans:

Unformatted DITA

A typical DITA file can contain long lines, missing carriage returns and un-aligned elements:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="basic-usage"><title>Basic usage</title><body outputclass="language-markup">
<p>You will need to include the <codeph>prism.css</codeph> and <codeph>prism.js</codeph> files you downloaded in your page. Example:
</p>
<codeblock>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  ...
  &lt;link href="themes/prism.css" rel="stylesheet" /&gt;
  &gt;&lt;/head&gt;
&lt;body&gt;
  ...
  &lt;script src="prism.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;</codeblock>
   <p>Prism does its best to encourage good authoring practices.  Therefore,it only works with <codeph>&lt;code&gt;</codeph> elements,  since marking upcode without a <codeph>&lt;code&gt;</codeph> element is semantically invalid.<xref format="html" scope="external" href="https://www.w3.org/TR/html52/textlevel-semantics.html#the-code-element">According to the HTML5 spec</xref>, the recommended way to define a code language is a <codeph>language-xxxx</codeph> class, which is what Prism uses. Alternatively, Prism also supports a shorter version: <codeph>lang-xxxx</codeph>.
</p>
    <p> To make things easier however, Prism assumes that this language definition is inherited. Therefore, if multiple <codeph>&lt;code&gt;</codeph> elements have the same language, you can add the <codeph>language-xxxx</codeph> class on one of their common ancestors. This way, you can also define a document-wide default language, by adding a <codeph>language-xxxx</codeph> class on the <codeph>&lt;body&gt;</codeph> or <codeph>&lt;html&gt;</codeph> element.</p>
   <p> If you want to opt-out of highlighting for a <codeph>&lt;code&gt;</codeph> element that is a descendant of an element with a declared code language, you can add the class <codeph>language-none</codeph> to it (or any non-existing language, really).
  </p>
<p> The <xref format="html" scope="external" href="https://www.w3.org/TR/html5/grouping-content.html#the-pre-element">recommended way to mark up a code block</xref> (both for semantics and for Prism) is a <codeph>&lt;pre&gt;</codeph> element with a <codeph>&lt;code&gt;</codeph> element inside, like so:
</p>
<codeblock>&lt;pre&gt;&lt;code class="language-css"&gt;p { color: red }&lt;/code&gt;&lt;/pre&gt;</codeblock>
<p> If you use that pattern, the <codeph>&lt;pre&gt;</codeph> will automatically get the <codeph>language-xxxx</codeph> class (if it doesn’t already have it) and will be styled as a code block.
</p>
  <p> If you want to prevent any elements from being automatically highlighted, you can use the attribute <codeph>data-manual</codeph> on the <codeph>&lt;script&gt;</codeph> element you used for prism and use the <xref format="html" scope="external" href="https://prismjs.com/extending.html#api">API</xref>. Example:
    </p>
<section id="usage-with-webpack"><title>Usage with Webpack, Browserify, &amp; Other Bundlers</title><p>If you want to use Prism with a bundler, install Prism with <codeph>npm</codeph>:</p><codeblock>$ npm install prismjs</codeblock><p>You can then <codeph outputclass="language-js">import</codeph> into your bundle</p><codeblock outputclass="language-js">import Prism from 'prismjs';</codeblock><p>To make it easy to configure your Prism instance with only thelanguages and plugins you need, use the babel plugin, <xref format="html" scope="external" href="https://github.com/mAAdhaTTah/babel-plugin-prismjs">babel-plugin-prismjs</xref>. This will allow you to load the minimum number of languages and plugins to satisfy your needs. See that plugin's documentation for configuration details</p>
</section></body>
</topic>

Formatted DITA

After running pretty-dita the same file will have all its elements aligned, each block element on a new line and text should not overrun the side of a typical view screen (approx 120 characters)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="basic-usage">
    <title>Basic usage</title>
    <body outputclass="language-markup">
        <p>
          You will need to include the <codeph>prism.css</codeph> and <codeph>prism.js</codeph>
          files you downloaded in your page. Example:
        </p>
        <codeblock>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  ...
  &lt;link href="themes/prism.css" rel="stylesheet" /&gt;
  &gt;&lt;/head&gt;
&lt;body&gt;
  ...
  &lt;script src="prism.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;</codeblock>
        <p>
          Prism does its best to encourage good authoring practices.  Therefore,it only
          works with <codeph>&lt;code&gt;</codeph> elements,  since marking upcode
          without a <codeph>&lt;code&gt;</codeph> element is semantically invalid.<xref
          format="html" scope="external"
          href="https://www.w3.org/TR/html52/textlevel-semantics.html#the-code-element">According
          to the HTML5 spec</xref>, the recommended way to define a code language is a <codeph>language-xxxx</codeph>
          class, which is what Prism uses. Alternatively, Prism also supports a shorter version: <codeph>lang-xxxx</codeph>.
        </p>
        <p>
          To make things easier however, Prism assumes that this language definition is
          inherited. Therefore, if multiple <codeph>&lt;code&gt;</codeph> elements have
          the same language, you can add the <codeph>language-xxxx</codeph> class on one
          of their common ancestors. This way, you can also define a document-wide
          default language, by adding a <codeph>language-xxxx</codeph> class on the <codeph>&lt;body&gt;</codeph>
          or <codeph>&lt;html&gt;</codeph> element.
        </p>
        <p>
          If you want to opt-out of highlighting for a <codeph>&lt;code&gt;</codeph>
          element that is a descendant of an element with a declared code language, you
          can add the class <codeph>language-none</codeph> to it (or any non-existing
          language, really).
        </p>
        <p>
          The <xref format="html" scope="external"
          href="https://www.w3.org/TR/html5/grouping-content.html#the-pre-element">recommended
          way to mark up a code block</xref> (both for semantics and for Prism) is a <codeph>&lt;pre&gt;</codeph>
          element with a <codeph>&lt;code&gt;</codeph> element inside, like so:
        </p>
        <codeblock>&lt;pre&gt;&lt;code class="language-css"&gt;p { color: red }&lt;/code&gt;&lt;/pre&gt;</codeblock>
        <p>
          If you use that pattern, the <codeph>&lt;pre&gt;</codeph> will automatically get
          the <codeph>language-xxxx</codeph> class (if it doesn’t already have it) and
          will be styled as a code block.
        </p>
        <p>
          If you want to prevent any elements from being automatically highlighted, you
          can use the attribute <codeph>data-manual</codeph> on the <codeph>&lt;script&gt;</codeph>
          element you used for prism and use the <xref format="html" scope="external"
          href="https://prismjs.com/extending.html#api">API</xref>. Example:
        </p>
        <section id="usage-with-webpack">
            <title>Usage with Webpack, Browserify, &amp; Other Bundlers</title>
            <p>
              If you want to use Prism with a bundler, install Prism with <codeph>npm</codeph>:
            </p>
            <codeblock>$ npm install prismjs</codeblock>
            <p>
              You can then <codeph outputclass="language-js">import</codeph> into your bundle
            </p>
            <codeblock outputclass="language-js">import Prism from 'prismjs';</codeblock>
            <p>
              To make it easy to configure your Prism instance with only thelanguages and
              plugins you need, use the babel plugin, <xref format="html" scope="external"
              href="https://github.com/mAAdhaTTah/babel-plugin-prismjs">babel-plugin-prismjs</xref>.
              This will allow you to load the minimum number of languages and plugins to
              satisfy your needs. See that plugin's documentation for configuration details
            </p>
        </section>
    </body>
</topic>

▶️ Video from DITA-OT Day 2019

Table of Contents

Install

The Pretty DITA for DITA-OT has been tested against DITA-OT 4.x. It is recommended that you upgrade to the latest version.

Installing DITA-OT

The Pretty DITA for DITA-OT is a plug-in for the DITA Open Toolkit.

  • Full installation instructions for downloading DITA-OT can be found here.

    1. Download the dita-ot-4.2.zip package from the project website at dita-ot.org/download
    2. Extract the contents of the package to the directory where you want to install DITA-OT.
    3. Optional: Add the absolute path for the bin directory to the PATH system variable. This defines the necessary environment variable to run the dita command from the command line.
curl -LO https://github.com/dita-ot/dita-ot/releases/download/4.2/dita-ot-4.2.zip
unzip -q dita-ot-4.2.zip
rm dita-ot-4.2.zip

Installing the Plug-in

  • Run the plug-in installation command:
dita install https://github.com/jason-fox/fox.jason.pretty-dita/archive/master.zip

The dita command line tool requires no additional configuration.

Usage

Like any other transform, when invoked directly, the prettier requires an input document

Prettifying DITA files for a document

To prettify DITA files for a document, use the pretty-dita transform, set the --input parameter to point to a *.ditamap file:

PATH_TO_DITA_OT/bin/dita -f pretty-dita -i document.ditamap

All *.dita and *.ditamap files under that directory will be updated in place.

Prettifying DITA files under a directory

To prettify DITA files within a directory, use the pretty-dita transform, set the --input parameter to point to the directory :

PATH_TO_DITA_OT/bin/dita -f pretty-dita -i /path-to-directory

All *.dita and *.ditamap files under that directory will be updated in place.

Prettifying a single DITA file

Alternatively, to prettify a single DITA file, set the --input parameter to point to a *.dita file:

PATH_TO_DITA_OT/bin/dita -f pretty-dita -i topic.dita

The specified file will be updated in place.

Parameter Reference

  • args.indent - How many characters to indent (default 4)

  • args.style - Whether to indent using tabs or spaces (default spaces)

  • args.print-width - Specify the line length that the printer will wrap on (default 80)

  • args.require-pragma - Restrict the plug-in to only format files that contain a special comment, called a pragma, at the top of the file (default false)

    This is very useful when gradually transitioning large, unformatted codebases to pretty-dita.

    For example, a file containing either of the following comments will be formatted when args.require-pragma is supplied:

<!-- @prettier -->
<!-- @format -->
  • args.insert-pragma - Insert a special @format marker at the top of files specifying that the file has been formatted with the plugin (default false)

Ignoring DITA files

The prettifier will ignore any DITA file containing a comment starting prettier-ignore - the file will not be updated.

...
<topic id="basic-usage">
    <!-- prettier-ignore -->
    <title>Basic usage</title>
    <body outputclass="language-markup">
<lines>
This file really doesn't need formatting
    We want it to look this way.
</lines>
        <p>This will also be left alone.</p>
            <p>This will be left as well
        </p>
    </body>
</topic>

Formatting Rules

The pretty-dita DITA-OT Plug-in is an opinionated code formatter, DITA files are formatted to according to a well-defined set of rules.

Basic Block Elements

By default all DITA elements (not listed in the categories below) are indented one level further than the containing DITA element

Example

<topic id="basic-usage">
    <title>Basic usage</title>
    <body outputclass="language-markup">
        ...etc
    </body>
</topic>

Indented Block Elements

The following elements frequently contain a large body of text within them. The opening and closing tags are therefore always placed on a separate line before displaying the text found within them:

  • Topic elements: <abstract>, <shortdesc>
  • Body elements: <p>, <li>, <note>, <lq>

Example

<ul>
    <li>
      This is an item in an unordered list.
    </li>
    <li>
      To separate it from other items in the list, the formatter puts a bullet beside it.
    </li>
    <li>
      The following paragraph, contained in the list item element, is part of the list
      item which contains it.
        <p>
          This is the contained paragraph.
        </p>
    </li>
    <li>
      This is the last list item in our unordered list.
    </li>
</ul>

Inline Elements

The following elements are treated as inline elements, they do not warrant an additional line and are kept within the surrounding text

  • Body elements: <ph>, <codeph>, <synph>, <term>, <xref>, <cite>, <q>, <boolean>, <state>, <keyword>, <option>, <tm>, <fn>, <xref>
  • Programming elements: <parmname>, <apiname>
  • Typographic elements: <b>, <i>, <sup>, <sub>, <tt>, <u>
  • Software elements: <filepath>, <msgph>, <userinput>, <systemoutput>, <cmdname>, <msgnum>, <varname>
  • Userinteface elements: <uicontrol>, <menucascade>, <wintitle>
  • XML Mention Domain: <numcharref>, <parameterentity>, <textentity>, <xmlatt>, <xmlelement>, <xmlnsname>, <xmlpi>

Example

<p>
  <b>STOP!</b> This is <b>very</b> important! Unplug the unit <i>before</i> placing the
  metal screwdriver against the terminal screw.
</p>

Text Elements

Text elements on a single line are kept within the containing element Text element on multiple lines are indented one level further than the surrounding text. Long lines of text are truncated to approximately 80 characters length by default before adding a carriage return. Carriage returns are usually placed so as not to split inline elements, but this is sometimes not feasable within the line limits, so a line break may occur before an inline attribute.

Example

<p>
  The <xref format="html" scope="external"
  href="https://www.w3.org/TR/html5/grouping-content.html#the-pre-element">recommended
  way to mark up a code block</xref> (both for semantics and for Prism) is a <codeph>&lt;pre&gt;</codeph>
  element with a <codeph>&lt;code&gt;</codeph> element inside, like so:
</p>

Whitespace sensitive elements

The following elements are whitespace sensitive and require special processing:

  • <codeblock>, <lines>, <msgblock>, <pre>, <foreign>

The opening tag of a <codeblock> is indented normally, the text within a <codeblock> (if any) is not indented

<topic id="basic-usage">
    <title>Basic usage</title>
    <body outputclass="language-markup">
        <p>
          You will need to include the <codeph>prism.css</codeph> and <codeph>prism.js</codeph>
          files you downloaded in your page. Example:
        </p>
        <codeblock>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  ...
  &lt;link href="themes/prism.css" rel="stylesheet" /&gt;
  &gt;&lt;/head&gt;
&lt;body&gt;
  ...
  &lt;script src="prism.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;</codeblock>
        ...etc

<codeblock> elements containing <coderef> elements are indented as shown:

<codeblock outputclass="language-markup">
    <coderef href="../src/logo.svg"/>
</codeblock>

Other white-space sensitive elements such as <lines> are supported in a similar manner. If processing is found to be incorrect due to embedded elements, it is suggested that the author uses the pretty-ignore directive to maintain whitespace.

Contribute

PRs accepted.

License

Apache 2.0 © 2019 - 2024 Jason Fox

fox.jason.pretty-dita's People

Contributors

actions-user avatar dependabot[bot] avatar jason-fox avatar

Stargazers

 avatar

Watchers

 avatar

fox.jason.pretty-dita's Issues

Indents foreign blocks

When pretty-printing the following:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="redundancy-handling" xml:lang="en-us">
               <title>Redundancy Handling</title>
   <body>
    <p>
     <fig id="redundancy-handling-1">
       <title>Startup of ...</title>
       <foreign outputclass="embed-plant-uml">
         @startuml
             scale 0.6
             autonumber "&lt;b>[0]"

             title Startup of ...

             group startup
                 Gateway -> XXX : Query DMI pos
             end
         @enduml
       </foreign>
     </fig>
    </p>
    </body>

</topic>

it processes / indents the <foreign> content invalidly towards:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="redundancy-handling" xml:lang="en-us">
    <title>Redundancy Handling</title>
    <body>
        <p>
            <fig id="redundancy-handling-1">
                <title>Startup of ...</title>
                <foreign outputclass="embed-plant-uml">
                   @startuml scale 0.6 autonumber "&lt;b&gt;[0]" title Startup of ... group startup
                   Gateway -&gt; XXX : Query DMI pos end @enduml
       </foreign>
            </fig>
        </p>
    </body>
</topic>

which will break plantuml-processing.

Does not reformat topics

Another one:

When i run dita-pretty on:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="the-update-mechanism-in-general" xml:lang="en-us">
	<title>The update mechanism in general</title>
	<body>
<p id="watch-update">
The state of a update process can be observed by different means:
<ol>
<li id="sound-beep">
	When the update is finished a beep is played:
	<ul>
		<li>
			<p>
Beep duration
<b>3 times 0.5s</b>
: update finished successfully
				</p>
			</li>
			<li>
<p>
	Beep duration
	<b>30 times 0.1s</b>
	: update finished with errors
</p>
			</li>
		</ul>
	</li>
	</ol>
		</p>
	</body>
</topic>

nothing is reformatted.

Does not resolves relative topic dirs correctly

Anogther one i found:

I am using relative paths in our dita map like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
  <title>DMI Integration Handbook</title>
  <topichead navtitle="Introduction">
    <topicref href="topics/intro-audience.dita"/>
    <topicref href="../../src-cmake/generic-dmi/doc/topics/intro/dmi-intro-hw.dita"/>
  </topichead>
</map>

When i run dita-prettty like this:

hcw@nvidion:~/work/Deuta/dmi-projects/05-Implementation/build-x86-debug$ ./src-cmake/generic-dmi/doc/dita-plugins/dita-ot-3.3.4/src/dita-dl/bin/dita -f pretty-dita -i ../doc/IntegrationHandbook/DMI_Integration_Handbook.ditamap

it only picks up the first dita topic, but does not touch the second one.

Looks like the tool is evaluating the relative path statement not relative to the ditamap (as it should be, at least as DITA-OT also does it).

Creates a blank line after codeblock if <b> is within codeblock

If pretty-printing:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="sound-add">
    <title>Adds a blank at end of codeblock if it contains b</title>
    <shortdesc>
    ...
    </shortdesc>
    <taskbody>
        <steps>
            <step>
                <cmd>
                </cmd>
                <stepxmp>
                    <codeblock>&lt;project&gt;
&lt;display id="displayConfig"&gt;
                    name=" <b>EVT_Sound_SignalHorn </b>"/&gt;
&lt;/project&gt;
                    </codeblock>
                </stepxmp>
            </step>
        </steps>
    </taskbody>
</task>

i get:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="sound-add">
    <title>Adds a blank at end of codeblock if it contains b</title>
    <shortdesc>
      ...
    </shortdesc>
    <taskbody>
        <steps>
            <step>
                <cmd/>
                <stepxmp>
                    <codeblock>&lt;project&gt;
&lt;display id="displayConfig"&gt;
                    name=" <b>EVT_Sound_SignalHorn </b>"/&gt;
&lt;/project&gt;
                    
                    </codeblock>
                </stepxmp>
            </step>
        </steps>
    </taskbody>
</task>

Note the extra empty line in front of the closing </codeblock>.
On each run another extra line is added.

Does not pretty-print glossentry

Thanks for your plugin, works great (and is heavily needed if working with different XML tools for DITA).

However, i noticed that it will not touch glossentry like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glossentry PUBLIC "-//OASIS//DTD DITA Glossary Entry//EN"
"glossentry.dtd">
<glossentry id="gloss-cfgdir">
  <glossterm>[cfgdir]</glossterm>

  <glossdef>
The directory containing all source files and cmake tools which
  are needed to create the configuration files.</glossdef>

  <glossBody>
    <glossUsage>
...</glossUsage>

    <note><p>In the GIT source code repository....</p></note>
  </glossBody>
</glossentry>

Any plans to make indentation configurable?

💡 Interesting idea to implement a pretty-printer as an OT plug-in. 🤔

I appreciate the concept of an opinionated code formatter, but I find the results here a bit surprising, as most elements are indented with 3 spaces, but things like paragraph contents by 4.

I'm also seeing unexpected results for unordered lists within paragraphs, and varying line lengths.

Here's a sample from the preprocess-metadata.dita file in the DITA-OT docs, which was already formatted consistently with oXygen's Format & Indent command:

<?xml version="1.0" encoding="UTF-8"?>
<!--  This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license.  -->
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="preprocess-metadata" xml:lang="en-US">
   <title>Move metadata (move-meta-entries) and pull content into maps (mappull) </title>
   <shortdesc>The <codeph>move-meta-entries</codeph> step pushes metadata back and forth between maps and topics. For
    example, index entries and copyrights in the map are pushed into affected topics, so that the topics can be
    processed later in isolation while retaining all relevant metadata. This step is implemented in Java.
   </shortdesc>
   <conbody>
      <note>As of DITA-OT 2.2, the <codeph>move-meta-entries</codeph> and <codeph>mappull</codeph> steps have been merged.
      The <codeph>mappull</codeph> step has been moved into <codeph>move-meta-entries</codeph>.
      </note>
      <section>
         <p>
             The <codeph>mappull</codeph> step pulls content from referenced
             topics into maps, and then cascades data within maps. This step is implemented in XSLT. 
        </p>
         <p>
                   The <codeph>mappull</codeph> step makes the following changes to the
                   DITA map:  <ul>                <li>Titles are pulled from referenced DITA
                   topics. Unless the  <xmlatt>locktitle</xmlatt> attribute is set to "yes", the
                   pulled titles replace the navigation titles specified on the <xmlelement>topicref</xmlelement>
                   elements. 
              </li>

               <!-- ⋮ more list items -->

</ul>
              
        </p>
      </section>
   </conbody>
</concept>

It seems that closing tags for some elements (like </shortdesc>) align with the opening angle brackets of their opening counterparts as usual, but others (like </p>) appear "outdented" to align with the element name.

Might be good to document these choices so people know what to expect when formatting a large codebase, and consider options (transtypes?) that would allow users to influence the results.

Creates too long lines in <task><cmd> containing a <filepath>

When pretty-printing the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="sound-add">
    <title>Title</title>
    <shortdesc>...
    </shortdesc>
    <taskbody>
        <context>
            <p>
            Bad indent of filepath in cmd.
            </p>
        </context>
        <steps>
            <step>
                <cmd>
                  Trigger that event either by a logic(SW change needed) 
                  or by a button binding (see click sounds for button). 
                  <filepath>dmi/Base/config/fragments/Config-base.xml</filepath>.
                </cmd>
            </step>
        </steps>
    </taskbody>
</task>

i get a too-long line:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="sound-add">
    <title>Title</title>
    <shortdesc>
      ...
    </shortdesc>
    <taskbody>
        <context>
            <p>
              Bad indent of filepath in cmd.
            </p>
        </context>
        <steps>
            <step>
                <cmd>
                  Trigger that event either by a logic(SW change needed) or by a button binding (see click sounds for button). <filepath>dmi/Base/config/fragments/Config-base.xml</filepath>.
                </cmd>
            </step>
        </steps>
    </taskbody>
</task>

Inserts linefeed in codeblock

Another one... 8->

When pretty-printing the following, a newline is inserted after the "cd" before the "abbreviated-form".

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="dialog-add-new-language">
    <title>Extend...</title>
    <shortdesc>
       Allow...
    </shortdesc>
    <taskbody>
        <steps>
            <step>
                <cmd>Regenerate the configuration files.</cmd>
                <stepxmp>
                    <codeblock>$ cd <abbreviated-form keyref="gloss-cfgdir"/>/build
$ make
                    </codeblock>
                </stepxmp>
            </step>
        </steps>
    </taskbody>
</task>

Moves codeblocks to begin of paragraph

When doing pretty-print on the following file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="concept_g4t_tdy_flb">
    <title>Code block moving bug</title>
    <shortdesc>
Code block moving bug    </shortdesc>
    <conbody>
        <p>
        para
        </p>
        <p>
            Looks like this:
            <codeblock>&lt;logic  &gt;
&lt;/logic&gt;</codeblock>
        </p>
        <p>  looks like this: 
          <codeblock>&lt;logic type="SpeedLogicBL3" id="speedLogicBL3"&gt;
&lt;/logic&gt;</codeblock> 
            text
         </p>
        <p>
          and looks like this:
          <codeblock>&lt;logic type="SpeedLogicLZB" id="speedLogicLZB"&gt;
&lt;/logic&gt;</codeblock>
  
            <note>
    Values are:
                <codeblock>speedWidgetBL3
                ...
                </codeblock>
                more text
            </note>
        </p>
    </conbody>
</concept>

i get the following result (where code blocks are moved to the front of the paragraphs:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="concept_g4t_tdy_flb">
    <title>Code block moving bug</title>
    <shortdesc>
      Code block moving bug
    </shortdesc>
    <conbody>
        <p>
          para
        </p>
        <p>
            <codeblock>&lt;logic  &gt;
&lt;/logic&gt;</codeblock>
          Looks like this:
        </p>
        <p>
            <codeblock>&lt;logic type="SpeedLogicBL3" id="speedLogicBL3"&gt;
&lt;/logic&gt;</codeblock> 
          looks like this: text
        </p>
        <p>
            <codeblock>&lt;logic type="SpeedLogicLZB" id="speedLogicLZB"&gt;
&lt;/logic&gt;</codeblock>
          and looks like this:
            <note>
                <codeblock>speedWidgetBL3
                ...
                </codeblock>
              Values are: more text
            </note>
        </p>
    </conbody>
</concept>

Note the looks like this: locations and Values are: before / after.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.