Skip to content

Commit f77d16a

Browse files
committed
Handle external links with HTTPS
* external links that are relative are converted into a deliverable/prebuilt * external links that are HTTPS links stay in the <external> tag
1 parent f0912c0 commit f77d16a

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

src/docbuild/config/xml/data/convert-v6-to-v7.xsl

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,16 @@
439439
</xsl:when>
440440
<xsl:otherwise>
441441
<xsl:apply-templates select="@*|node()[not(self::external)]" />
442-
<xsl:call-template name="docset-without-builddocs" ></xsl:call-template>
442+
443+
<xsl:if test="external/link[not(starts-with(language/url/@href, 'https://'))]">
444+
<xsl:call-template name="docset-without-builddocs" ></xsl:call-template>
445+
</xsl:if>
446+
447+
<xsl:if test="external/link[starts-with(language/url/@href, 'https://')]">
448+
<external>
449+
<xsl:apply-templates select="external/link[starts-with(language/url/@href, 'https://')]" mode="external-link"/>
450+
</external>
451+
</xsl:if>
443452
</xsl:otherwise>
444453
</xsl:choose>
445454
</docset>
@@ -476,20 +485,45 @@
476485

477486
<xsl:template name="docset-without-builddocs">
478487
<resources>
479-
<xsl:apply-templates select="external" mode="builddocs" />
488+
<xsl:apply-templates select="external[link[not(starts-with(language/url/@href, 'https://'))]]" mode="builddocs" />
480489
</resources>
481490
</xsl:template>
482491

483492

484493
<xsl:template match="docset/external" mode="builddocs">
485494
<locale lang="en-us">
486-
<xsl:apply-templates select="link" mode="builddocs" />
495+
<xsl:apply-templates select="link[not(starts-with(language/url/@href, 'https://'))]" mode="builddocs" />
487496
</locale>
488-
<xsl:if test="link[@lang != 'en-us']">
497+
<xsl:if test="link[not(starts-with(language/url/@href, 'https://')) and @lang != 'en-us']">
489498
<xsl:message>TODO: Found non-English links in docset/external</xsl:message>
490499
</xsl:if>
491500
</xsl:template>
492501

502+
<xsl:template match="link" mode="external-link">
503+
<link>
504+
<xsl:copy-of select="@category|@gated|@titleformat"/>
505+
<xsl:for-each select="language/url">
506+
<url>
507+
<xsl:copy-of select="@href|@format"/>
508+
</url>
509+
</xsl:for-each>
510+
511+
<descriptions>
512+
<xsl:for-each select="language">
513+
<desc>
514+
<xsl:attribute name="lang">
515+
<xsl:choose>
516+
<xsl:when test="@lang"><xsl:value-of select="@lang"/></xsl:when>
517+
<xsl:otherwise>en-us</xsl:otherwise>
518+
</xsl:choose>
519+
</xsl:attribute>
520+
<title><xsl:value-of select="@title"/></title>
521+
</desc>
522+
</xsl:for-each>
523+
</descriptions>
524+
</link>
525+
</xsl:template>
526+
493527
<xsl:template match="link" mode="builddocs">
494528
<deliverable type="prebuilt" category="{@category}">
495529
<xsl:apply-templates mode="builddocs" />

0 commit comments

Comments
 (0)