extended-functionality.dita 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd">
  3. <!--This file is part of the DITA Open Toolkit project. See the accompanying LICENSE.md file for applicable licenses.-->
  4. <reference id="extended-functionality">
  5. <title>Extended functionality</title>
  6. <shortdesc>DITA-OT provides additional code reference processing support beyond that which is mandated by the DITA
  7. specification. These extensions can be used to define character encodings or line ranges for use in code
  8. blocks.</shortdesc>
  9. <reference id="code-reference">
  10. <title>Code reference processing</title>
  11. <refbody>
  12. <section id="coderef-charset">
  13. <title>Character set definition</title>
  14. <p>DITA-OT supports defining the code reference target file encoding using the <xmlatt>format</xmlatt>
  15. attribute. The supported format is:</p>
  16. <codeblock>format (";" space* "charset=" charset)?</codeblock>
  17. <p>If a character set is not defined, the system default character set will be used. If the character set is not
  18. recognized or supported, the <msgnum>DOTJ052E</msgnum> error is thrown and the system default character set is
  19. used as a fall-back.</p>
  20. </section>
  21. <example>
  22. <codeblock>&lt;coderef href="unicode.txt" format="txt; charset=UTF-8"/></codeblock>
  23. </example>
  24. <section>
  25. <title>Line range extraction</title>
  26. <p>Code references can be limited to extract only a specified line range by defining the
  27. <codeph>line-range</codeph> pointer in the URI fragment. The format is:</p>
  28. <codeblock>uri ("#line-range(" start ("," end)? ")" )?</codeblock>
  29. <p>Start and end line numbers start from 1 and are inclusive. If the end range is omitted, the range ends on the
  30. last line of the file.</p>
  31. </section>
  32. <example>
  33. <codeblock>&lt;coderef href="Parser.scala#line-range(5, 10)" format="scala"/></codeblock>
  34. <p>Only lines from 5 to 10 will be included in the output.</p>
  35. </example>
  36. <section>
  37. <title>RFC 5147</title>
  38. <p>DITA-OT implements line position and range from <xref keyref="rfc5147"/>. The format for line range is:</p>
  39. <codeblock>uri ("#line=" start? "," end? )?</codeblock>
  40. <p>Start and end line numbers start from 0 and are inclusive and exclusive, respectively. If the start range is
  41. omitted, the range starts from the first line; if the end range is omitted, the range ends on the last line of
  42. the file. The format for line position is:</p>
  43. <codeblock>uri ("#line=" position )?</codeblock>
  44. <p>Position line number starts from 0.</p>
  45. </section>
  46. <example>
  47. <codeblock>&lt;coderef href="Parser.scala#line=4,10" format="scala"/></codeblock>
  48. <p>Only lines from 5 to 10 will be included in the output.</p>
  49. </example>
  50. </refbody>
  51. </reference>
  52. </reference>