Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[doc2rst] Improve links

  • Loading branch information...
commit 8f7fd1a20fe25c166bf57318d6b2c90892099a3e 1 parent b19529c
Maks3w authored
Showing with 12 additions and 25 deletions.
  1. +2 −23 bin/doc2rst.php
  2. +10 −2 bin/doc2rst.xsl
25 bin/doc2rst.php
View
@@ -130,11 +130,8 @@
$output .= rtrim($line). "\n";
}
}
-// Add the list of the external links at the end of the document
-if(!empty(RstConvert::$links)) {
- $output .= "\n" . RstConvert::getLinks();
-}
-if(!empty(RstConvert::$footnote)) {
+// Add the list of footnotes at the end of the document
+if (!empty(RstConvert::$footnote)) {
$output .= "\n" . join("\n", RstConvert::$footnote);
}
@@ -147,7 +144,6 @@
*/
class RstConvert
{
- public static $links = array();
public static $footnote = array();
private static $indentation = 0;
@@ -332,23 +328,6 @@ public static function escapeChar($text, $char)
}
/**
- * Convert the link tag
- *
- * @param \DOMElement $node
- * @return string
- */
- public static function link($node)
- {
- $value = trim(self::formatText($node[0]->nodeValue));
- if ($node[0]->getAttribute('linkend')) {
- return ":ref:`$value <" . $node[0]->getAttribute('linkend') . ">`";
- } else {
- self::$links[$value] = trim($node[0]->getAttribute('xlink:href'));
- return "`$value`_";
- }
- }
-
- /**
* Convert the footnote
*
* @param \DOMElement $value
12 bin/doc2rst.xsl
View
@@ -114,8 +114,16 @@
</xsl:template>
<!-- link, uri, xref -->
- <xsl:template match="//doc:link|//doc:uri|//doc:xref" name="link">
- <xsl:value-of select="php:function('ZendBin\RstConvert::link', .)"/>
+ <xsl:template match="*[@href]">
+ <xsl:text />`<xsl:value-of select="normalize-space(text())" /> &lt;<xsl:value-of select="normalize-space(@href)" />&gt;`_<xsl:text />
+ <xsl:if test="name(following-sibling::node()[1]) != ''">
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- link, uri, xref -->
+ <xsl:template match="*[@linkend]">
+ <xsl:text />:ref:`<xsl:value-of select="normalize-space(text())" /> &lt;<xsl:value-of select="normalize-space(@href)" />&gt;`_<xsl:text />
<xsl:if test="name(following-sibling::node()[1]) != ''">
<xsl:text> </xsl:text>
</xsl:if>
Please sign in to comment.
Something went wrong with that request. Please try again.