Changeset 99267 in vbox for trunk/doc/manual
- Timestamp:
- Apr 3, 2023 9:08:40 PM (22 months ago)
- Location:
- trunk/doc/manual
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/docbook-refentry-to-manual-dita.xsl
r99198 r99267 34 34 35 35 <xsl:import href="string.xsl"/> 36 <xsl:import href="common-formatcfg.xsl"/> 36 37 37 38 <xsl:output method="xml" version="1.0" encoding="utf-8" indent="no"/> … … 46 47 Note! If the monospace font used in the PDF doesn't support it, 47 48 then '#' shows up instead for instance. This is currently 48 the case, so it's disabled by default. --> 49 the case, so it's disabled by default. When we switch to 50 4.0.x with the latest com.elovirta.pdf plugin (2023-03-xx 51 or later), we can enable this by default again. --> 49 52 <xsl:param name="g_fReplaceHypens">false</xsl:param> 53 54 <!-- Render the syntax diagram more as text than as proper markup. --> 55 <xsl:param name="g_fRenderSyntaxAsText">true</xsl:param> 50 56 51 57 … … 259 265 <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute> 260 266 </xsl:if> 261 <xsl:apply-templates /> 267 <xsl:choose> 268 <xsl:when test="$g_fRenderSyntaxAsText = 'true'"> 269 <xsl:element name="groupseq"> 270 <xsl:apply-templates /> 271 </xsl:element> 272 </xsl:when> 273 274 <xsl:otherwise> 275 <xsl:apply-templates /> 276 </xsl:otherwise> 277 </xsl:choose> 262 278 </xsl:element> 263 279 … … 273 289 </xsl:template> 274 290 291 <!-- TODO: sbr cannot be translated, it seems. Whether we wrap things in 292 synblk, groupcomp or groupseq elements, the result is always the same: 293 - HTML: ignored. 294 - PDF: condensed arguments w/o spaces between. 4.0.2 doesn't seem 295 to condense stuff any more inside synblk elements, but then the 296 rending isn't much changed for PDFs anyway since its one element 297 per line. 298 Update: Turns out the condensing was because we stripped element 299 whitespace instead of preserving it. svn copy. sigh. --> 275 300 <xsl:template match="cmdsynopsis[sbr]"> 301 <xsl:variable name="sWrapperElement"> 302 <xsl:choose> 303 <xsl:when test="$g_fRenderSyntaxAsText = 'true'"><xsl:text>groupseq</xsl:text></xsl:when> 304 <xsl:otherwise><!--synblk--></xsl:otherwise> 305 </xsl:choose> 306 </xsl:variable> 307 276 308 <xsl:element name="syntaxdiagram"> 277 309 <xsl:attribute name="rev">cmdsynopsis</xsl:attribute> … … 281 313 <xsl:for-each select="sbr"> 282 314 <xsl:variable name="idxSbr" select="position()"/> 283 <!-- TODO: sbr cannot be translated, it seems. Whether we wrap things in 284 synblk, groupcomp or groupseq elements, the result is always the same: 285 - HTML: ignored. 286 - PDF: condensed arguments w/o spaces between. 4.0.2 doesn't seem 287 to condense stuff any more inside synblk elements, but then the 288 rending isn't much changed for PDFs anyway since its one element 289 per line. 290 Update: Turns out the condensing was because we stripped element 291 whitespace instead of preserving it. svn copy. sigh. --> 292 <!-- <xsl:element name="synblk"> 293 <xsl:attribute name="rev">sbr/<xsl:value-of select="position()"/></xsl:attribute> --> 294 295 <xsl:if test="$idxSbr = 1"> 296 <xsl:apply-templates select="preceding-sibling::node()"/> 297 </xsl:if> 298 <xsl:if test="$idxSbr != 1"> 299 <xsl:apply-templates select="preceding-sibling::node()[ count(. | ../sbr[$idxSbr - 1]/following-sibling::node()) 300 = count(../sbr[$idxSbr - 1]/following-sibling::node())]"/> 301 </xsl:if> 302 <!-- </xsl:element> --> 315 316 <xsl:choose> 317 <xsl:when test="$sWrapperElement != ''"> 318 <xsl:element name="{$sWrapperElement}"> 319 <xsl:attribute name="rev">sbr/<xsl:value-of select="position()"/></xsl:attribute> 320 321 <xsl:if test="$idxSbr = 1"> 322 <xsl:apply-templates select="preceding-sibling::node()"/> 323 </xsl:if> 324 <xsl:if test="$idxSbr != 1"> 325 <xsl:apply-templates select="preceding-sibling::node()[ count(. | ../sbr[$idxSbr - 1]/following-sibling::node()) 326 = count(../sbr[$idxSbr - 1]/following-sibling::node())]"/> 327 </xsl:if> 328 </xsl:element> 329 </xsl:when> 330 331 <xsl:otherwise> 332 <xsl:if test="$idxSbr = 1"> 333 <xsl:apply-templates select="preceding-sibling::node()"/> 334 </xsl:if> 335 <xsl:if test="$idxSbr != 1"> 336 <xsl:apply-templates select="preceding-sibling::node()[ count(. | ../sbr[$idxSbr - 1]/following-sibling::node()) 337 = count(../sbr[$idxSbr - 1]/following-sibling::node())]"/> 338 </xsl:if> 339 </xsl:otherwise> 340 </xsl:choose> 341 303 342 <!-- Ensure some space between these.--> 304 343 <xsl:text> 305 344 </xsl:text> 306 <xsl:if test="$idxSbr = last()"> 307 <!-- <xsl:element name="synblk"> 308 <xsl:attribute name="rev">sbr/<xsl:value-of select="position()"/></xsl:attribute> --> 345 346 <xsl:if test="$idxSbr = last()"> 347 <xsl:choose> 348 <xsl:when test="$sWrapperElement != ''"> 349 <xsl:element name="{$sWrapperElement}"> 350 <xsl:attribute name="rev">sbr/<xsl:value-of select="position()"/></xsl:attribute> 351 <xsl:apply-templates select="following-sibling::node()"/> 352 </xsl:element> 353 </xsl:when> 354 355 <xsl:otherwise> 309 356 <xsl:apply-templates select="following-sibling::node()"/> 310 <!-- </xsl:element> --> 311 </xsl:if> 357 </xsl:otherwise> 358 </xsl:choose> 359 </xsl:if> 312 360 </xsl:for-each> 313 361 </xsl:element> … … 323 371 </xsl:if> 324 372 </xsl:template> 373 374 <!-- text (whitespace) under synopsis may need removing. --> 375 <xsl:template match="cmdsynopsis/text()"> 376 <xsl:if test="normalize-space(.) != ''"> 377 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>text in cmdsynopsis '<xsl:value-of select="."/>'</xsl:message> 378 </xsl:if> 379 380 <xsl:choose> 381 <xsl:when test="$g_fRenderSyntaxAsText = 'true'"> 382 </xsl:when> 383 384 <xsl:otherwise> 385 <xsl:value-of select="."/> 386 </xsl:otherwise> 387 </xsl:choose> 388 </xsl:template> 389 325 390 326 391 <!-- command with text and/or replaceable in cmdsynopsis -> groupseq + kwd --> … … 424 489 </xsl:element> 425 490 </xsl:if> 426 <xsl:if test="contains(., ' ') ">491 <xsl:if test="contains(., ' ') and $g_fRenderSyntaxAsText != 'true'"> 427 492 <xsl:value-of select="."/> 428 493 </xsl:if> … … 451 516 <!-- arg -> groupseq or groupcomp and optionally a repsep element if repeatable. --> 452 517 <xsl:template match="arg" > 453 <!-- If it's a tighly packed arg, we use groupcomp instead of groupseq to try 454 avoid it being split in the middle. --> 455 <xsl:variable name="sGroupType"> 456 <xsl:call-template name="determine_arg_wrapper_element"/> 457 </xsl:variable> 458 <xsl:element name="{$sGroupType}"> 459 <xsl:attribute name="rev">arg[<xsl:value-of select="concat(@choice,',',@rep)"/>]</xsl:attribute> 460 <xsl:choose> 461 <xsl:when test="not(@choice) or @choice = 'opt'"> 462 <xsl:attribute name="importance">optional</xsl:attribute> 463 </xsl:when> 464 <xsl:when test="@choice = 'req'"> 465 <xsl:attribute name="importance">required</xsl:attribute> 466 </xsl:when> 467 <xsl:when test="@choice = 'plain'"/> 468 <xsl:otherwise> 469 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Unexpected @choice value: <xsl:value-of select="@choice"/></xsl:message> 470 </xsl:otherwise> 471 </xsl:choose> 472 473 <xsl:apply-templates /> 474 475 <xsl:if test="@rep = 'repeat'"> 476 <!-- repsep can only be placed at the start of a groupseq/whatever and 477 the documenation and examples of the element is very sparse. The 478 PDF output plugin will place the '...' where it finds it and do 479 nothing if it's empty. The XHTML output plugin ignores it, it seems. --> 480 <xsl:element name="sep"> 481 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 482 <xsl:text> </xsl:text> 518 <xsl:choose> 519 <xsl:when test="$g_fRenderSyntaxAsText = 'true'"> 520 <xsl:call-template name="arg_or_group_as_text"/> 521 </xsl:when> 522 523 <xsl:otherwise> 524 <!-- If it's a tighly packed arg, we use groupcomp instead of groupseq to try 525 avoid it being split in the middle. --> 526 <xsl:variable name="sGroupType"> 527 <xsl:call-template name="determine_arg_wrapper_element"/> 528 </xsl:variable> 529 <xsl:element name="{$sGroupType}"> 530 <xsl:attribute name="rev">arg[<xsl:value-of select="concat(@choice,',',@rep)"/>]</xsl:attribute> 531 <xsl:choose> 532 <xsl:when test="not(@choice) or @choice = 'opt'"> 533 <xsl:attribute name="importance">optional</xsl:attribute> 534 </xsl:when> 535 <xsl:when test="@choice = 'req'"> 536 <xsl:attribute name="importance">required</xsl:attribute> 537 </xsl:when> 538 <xsl:when test="@choice = 'plain'"/> 539 <xsl:otherwise> 540 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Unexpected @choice value: <xsl:value-of select="@choice"/></xsl:message> 541 </xsl:otherwise> 542 </xsl:choose> 543 544 <xsl:apply-templates /> 545 546 <xsl:if test="@rep = 'repeat'"> 547 <!-- repsep can only be placed at the start of a groupseq/whatever and 548 the documenation and examples of the element is very sparse. The 549 PDF output plugin will place the '...' where it finds it and do 550 nothing if it's empty. The XHTML output plugin ignores it, it seems. --> 551 <xsl:element name="sep"> 552 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 553 <xsl:text> </xsl:text> 554 </xsl:element> 555 <xsl:element name="groupcomp"> 556 <xsl:attribute name="importance">optional</xsl:attribute> 557 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 558 <xsl:attribute name="outputclass">repeatarg</xsl:attribute> <!-- how to make xhtml pass these thru... --> 559 <xsl:element name="repsep"> 560 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 561 <xsl:text>...</xsl:text> 562 </xsl:element> 563 </xsl:element> 564 </xsl:if> 565 483 566 </xsl:element> 484 <xsl:element name="groupcomp"> 485 <xsl:attribute name="importance">optional</xsl:attribute> 486 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 487 <xsl:attribute name="outputclass">repeatarg</xsl:attribute> <!-- how to make xhtml pass these thru... --> 488 <xsl:element name="repsep"> 489 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 490 <xsl:text>...</xsl:text> 491 </xsl:element> 492 </xsl:element> 493 </xsl:if> 494 495 </xsl:element> 567 </xsl:otherwise> 568 </xsl:choose> 496 569 497 570 <xsl:if test="parent::group and @choice != 'plain'"> … … 511 584 </xsl:template> 512 585 513 <!-- Plain (required) argument in group with only text() content -> kwd; -->514 <!--515 <xsl:template match="group/arg[@choice='plain' and (not(@rep) or @rep='norepeat') and not(replaceable) and not(arg) and not(group)]" >516 <xsl:call-template name="check-children" />517 <xsl:element name="kwd">518 <xsl:attribute name="rev">arg[plain#3]</xsl:attribute>519 <xsl:value-of select="."/>520 </xsl:element>521 </xsl:template> -->522 523 586 <!-- replaceable under arg -> var --> 524 587 <xsl:template match="arg/replaceable" > … … 579 642 </xsl:template> 580 643 581 <!-- Required group under arg or cmdsynopsis -> groupchoice w/attrib --> 582 <xsl:template match="arg/group | cmdsynopsis/group"> 583 <xsl:element name="groupchoice"> 644 <!-- group -> groupchoice w/attrib --> 645 <xsl:template match="group"> 646 <xsl:choose> 647 <xsl:when test="$g_fRenderSyntaxAsText = 'true'"> 648 <xsl:call-template name="arg_or_group_as_text"/> 649 </xsl:when> 650 <xsl:otherwise> 651 652 <xsl:element name="groupchoice"> 653 <xsl:choose> 654 <xsl:when test="@choice = 'req'"> 655 <xsl:attribute name="rev">group[req]</xsl:attribute> 656 <xsl:attribute name="importance">required</xsl:attribute> 657 </xsl:when> 658 <xsl:when test="@choice = 'plain'"> 659 <xsl:attribute name="rev">group[plain]</xsl:attribute> 660 <!-- We don't set the importance here. @todo Check what it does to the output formatting --> 661 </xsl:when> 662 <xsl:otherwise> 663 <xsl:attribute name="rev">group[opt]</xsl:attribute> 664 <xsl:attribute name="importance">optional</xsl:attribute> 665 </xsl:otherwise> 666 </xsl:choose> 667 668 <xsl:apply-templates /> 669 670 <xsl:if test="@rep = 'repeat'"> 671 <!-- repsep can only be placed at the start of a groupseq/whatever and 672 the documenation and examples of the element is very sparse. The 673 PDF output plugin will place the '...' where it finds it and do 674 nothing if it's empty. The XHTML output plugin ignores it, it seems. --> 675 <xsl:message terminate="no"><xsl:call-template name="error-prefix"/>Repeating group is not a good idea...</xsl:message> 676 <xsl:element name="sep"> 677 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 678 <xsl:text> </xsl:text> 679 </xsl:element> 680 <xsl:element name="groupcomp"> 681 <xsl:attribute name="importance">optional</xsl:attribute> 682 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 683 <xsl:attribute name="outputclass">repeatarg</xsl:attribute> <!-- how to make xhtml pass these thru... --> 684 <xsl:element name="repsep"> 685 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 686 <xsl:text>...</xsl:text> 687 </xsl:element> 688 </xsl:element> 689 </xsl:if> 690 </xsl:element> 691 692 </xsl:otherwise> 693 </xsl:choose> 694 </xsl:template> 695 696 <!-- text under a group may need removing. --> 697 <xsl:template match="group/text()"> 698 <xsl:if test="normalize-space(.) != ''"> 699 <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>text in group: '<xsl:value-of select="."/>'</xsl:message> 700 </xsl:if> 701 702 <xsl:choose> 703 <xsl:when test="$g_fRenderSyntaxAsText = 'true'"> 704 </xsl:when> 705 706 <xsl:otherwise> 707 <xsl:value-of select="."/> 708 </xsl:otherwise> 709 </xsl:choose> 710 </xsl:template> 711 712 713 <!-- 714 arg or group -> kwd + text 715 (Code duplicated in docbook-refentry-to-C-help.xsl & docbook2latex.xsl, with local differences.) 716 --> 717 <xsl:template name="arg_or_group_as_text" > 718 <xsl:variable name="fWrappers" select="not(ancestor::group)"/> 719 720 <!-- lead separators --> 721 <xsl:variable name="sLeadSeps"> 722 <xsl:call-template name="arg_or_group_as_text_calc_lead_seps"> 723 <xsl:with-param name="a_fWrappers" select="$fWrappers"/> 724 </xsl:call-template> 725 </xsl:variable> 726 <xsl:if test="$sLeadSeps != ''"> 727 <xsl:element name="sep"> 728 <xsl:value-of select="$sLeadSeps"/> 729 </xsl:element> 730 </xsl:if> 731 732 <!-- render the arg (TODO: may need to do more work here) --> 733 <xsl:apply-templates /> 734 735 <!-- repeat wrapping --> 736 <xsl:choose> 737 <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/> 738 <xsl:when test="@rep = 'repeat'"> <xsl:element name="sep"><xsl:value-of select="$arg.rep.repeat.str"/></xsl:element></xsl:when> 739 <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise> 740 </xsl:choose> 741 742 <!-- close wrapping --> 743 <xsl:if test="$fWrappers"> 584 744 <xsl:choose> 585 <xsl:when test="@choice = 'req'"> 586 <xsl:attribute name="rev">group[req]</xsl:attribute> 587 <xsl:attribute name="importance">required</xsl:attribute> 588 </xsl:when> 589 <xsl:when test="@choice = 'plain'"> 590 <xsl:attribute name="rev">group[plain]</xsl:attribute> 591 <!-- We don't set the importance here. @todo Check what it does to the output formatting --> 592 </xsl:when> 593 <xsl:otherwise> 594 <xsl:attribute name="rev">group[opt]</xsl:attribute> 595 <xsl:attribute name="importance">optional</xsl:attribute> 596 </xsl:otherwise> 745 <xsl:when test="not(@choice) or @choice = ''"> <xsl:element name="sep"><xsl:value-of select="$arg.choice.def.close.str"/></xsl:element></xsl:when> 746 <xsl:when test="@choice = 'opt'"> <xsl:element name="sep"><xsl:value-of select="$arg.choice.opt.close.str"/></xsl:element></xsl:when> 747 <xsl:when test="@choice = 'req'"> <xsl:element name="sep"><xsl:value-of select="$arg.choice.req.close.str"/></xsl:element></xsl:when> 597 748 </xsl:choose> 598 599 <xsl:apply-templates /> 600 601 <xsl:if test="@rep = 'repeat'"> 602 <!-- repsep can only be placed at the start of a groupseq/whatever and 603 the documenation and examples of the element is very sparse. The 604 PDF output plugin will place the '...' where it finds it and do 605 nothing if it's empty. The XHTML output plugin ignores it, it seems. --> 606 <xsl:message terminate="no"><xsl:call-template name="error-prefix"/>Repeating group is not a good idea...</xsl:message> 607 <xsl:element name="sep"> 608 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 609 <xsl:text> </xsl:text> 610 </xsl:element> 611 <xsl:element name="groupcomp"> 612 <xsl:attribute name="importance">optional</xsl:attribute> 613 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 614 <xsl:attribute name="outputclass">repeatarg</xsl:attribute> <!-- how to make xhtml pass these thru... --> 615 <xsl:element name="repsep"> 616 <xsl:attribute name="rev">arg[<xsl:value-of select="@choice"/>,repeat]</xsl:attribute> 617 <xsl:text>...</xsl:text> 618 </xsl:element> 619 </xsl:element> 749 <!-- Add a space padding if we're the last element in a repeating arg or group --> 750 <!-- 2023-03-22 bird: This is incorrectly written. Fix as needed... 751 <xsl:if test="(parent::arg or parent::group) and not(following-sibiling) and not(ancestor::*[@role='compact'])"> 752 <xsl:text> </xsl:text> 620 753 </xsl:if> 621 </xsl:element> 622 </xsl:template> 754 --> 755 </xsl:if> 756 757 </xsl:template> 758 759 <!-- Helper for arg_or_group_as_text. --> 760 <xsl:template name="arg_or_group_as_text_calc_lead_seps"> 761 <xsl:param name="a_fWrappers"/> 762 <xsl:variable name="idSelf" select="generate-id(.)"/> 763 764 <!-- separator char if we're not the first child --> 765 <xsl:if test="../*[generate-id(.) = $idSelf and position() > 1]"> 766 <!--<xsl:value-of select="concat('*',name(),'=', position(),'#')"/>--> 767 <xsl:choose> 768 <xsl:when test="parent::group and ancestor::*[@role='compact']"><xsl:value-of select="$arg.or.sep.compact"/></xsl:when> 769 <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when> 770 <xsl:when test="ancestor::*[@role='compact']"></xsl:when> 771 <xsl:when test="ancestor::*/@sepchar"><xsl:value-of select="ancestor::*/@sepchar"/></xsl:when> 772 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise> 773 </xsl:choose> 774 </xsl:if> 775 776 <!-- open wrapping --> 777 <xsl:if test="$a_fWrappers"> 778 <xsl:choose> 779 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when> 780 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when> 781 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when> 782 <xsl:when test="@choice = 'plain'"/> 783 <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise> 784 </xsl:choose> 785 </xsl:if> 786 787 </xsl:template> 788 623 789 624 790 <!-- option --> … … 767 933 <xsl:param name="a_sText" select="."/> 768 934 <xsl:choose> 769 <xsl:when test="$g_fReplaceHypens = 'true' or $g_fReplaceHypens = 'yes'"> 770 <xsl:message terminate="yes">wtf?</xsl:message> 935 <xsl:when test="$g_fReplaceHypens = 'true'"> 771 936 <xsl:call-template name="str:subst"> 772 <xsl:with-param name="text" 937 <xsl:with-param name="text" select="$a_sText"/> 773 938 <xsl:with-param name="replace">-</xsl:with-param> 774 939 <xsl:with-param name="with">‑</xsl:with-param> <!-- U+2011 / ‑ -->
Note:
See TracChangeset
for help on using the changeset viewer.