Code reference processing
Character set definition
DITA-OT supports defining the code reference target file encoding using the @format
attribute. The supported format is:
format (";" space* "charset=" charset)?
If a character set is not defined, the system default character set will be used. If the character set is not recognized or supported, the DOTJ052E error is thrown and the system default character set is used as a fall-back.
<coderef href="unicode.txt" format="txt; charset=UTF-8"/>
Line range extraction
Code references can be limited to extract only a specified line range by defining the
line-range
pointer in the URI fragment. The format is:
uri ("#line-range(" start ("," end)? ")" )?
Start and end line numbers start from 1 and are inclusive. If the end range is omitted, the range ends on the last line of the file.
<coderef href="Parser.scala#line-range(5, 10)" format="scala"/>
Only lines from 5 to 10 will be included in the output.
RFC 5147
DITA-OT implements line position and range from RFC 5147. The format for line range is:
uri ("#line=" start? "," end? )?
Start and end line numbers start from 0 and are inclusive and exclusive, respectively. If the start range is omitted, the range starts from the first line; if the end range is omitted, the range ends on the last line of the file. The format for line position is:
uri ("#line=" position )?
Position line number starts from 0.
<coderef href="Parser.scala#line=4,10" format="scala"/>
Only lines from 5 to 10 will be included in the output.