@@ -1753,73 +1753,73 @@ public function format_constant($open, $name, $attrs, $props)
1753
1753
}
1754
1754
return "<strong><code> " ;
1755
1755
}
1756
-
1756
+
1757
1757
if ($ this ->getRole () === "constant_group " ) {
1758
1758
$ this ->popRole ();
1759
-
1759
+
1760
1760
$ value = str_replace (
1761
1761
["<replaceable xmlns= \"http://docbook.org/ns/docbook \"> " , "</replaceable> " ],
1762
1762
["<span class= \"replaceable \"> " , "</span> " ],
1763
1763
strip_tags ($ this ->cchunk ["constant " ], "<replaceable> " )
1764
1764
);
1765
-
1765
+
1766
1766
$ link = $ this ->createReplaceableConstantLink (strip_tags ($ this ->cchunk ["constant " ], "<replaceable> " ));
1767
1767
$ this ->cchunk ["constant " ] = "" ;
1768
-
1768
+
1769
1769
if ($ link === "" ) {
1770
1770
return $ value . '</code></strong> ' ;
1771
1771
}
1772
-
1772
+
1773
1773
return '<a href=" ' . $ link . '"> ' . $ value . '</a></code></strong> ' ;
1774
1774
}
1775
1775
return "</code></strong> " ;
1776
1776
}
1777
1777
1778
1778
/**
1779
- * Creates a link to the first constant in the index
1779
+ * Creates a link to the first constant in the index
1780
1780
* that matches the pattern of a constant containing a <replaceable> tag
1781
1781
* or returns an empty string if no match was found.
1782
- *
1782
+ *
1783
1783
* This works only with one set of <replaceable> tags in a constant
1784
1784
* e.g. CURLE_<replaceable>*</replaceable> or DOM_<replaceable>*</replaceable>_NODE
1785
1785
*/
1786
1786
private function createReplaceableConstantLink (string $ constant ): string {
1787
1787
$ pattern = "/ " . preg_replace (
1788
- "/<replaceable.*<\/replaceable>/ " ,
1789
- ".* " ,
1788
+ "/<replaceable.*<\/replaceable>/ " ,
1789
+ ".* " ,
1790
1790
str_replace (
1791
- ". " ,
1792
- "\. " ,
1791
+ ". " ,
1792
+ "\. " ,
1793
1793
$ this ->convertConstantNameToId ($ constant )
1794
1794
)
1795
1795
) ."/ " ;
1796
-
1796
+
1797
1797
$ matchingConstantId = "" ;
1798
1798
foreach ($ this ->indexes as $ index ) {
1799
1799
if (preg_match ($ pattern , $ index ["docbook_id " ])) {
1800
1800
$ matchingConstantId = $ index ["docbook_id " ];
1801
1801
break ;
1802
1802
}
1803
1803
}
1804
-
1804
+
1805
1805
return $ matchingConstantId === "" ? "" : $ this ->createLink ($ matchingConstantId );
1806
1806
}
1807
-
1807
+
1808
1808
private function convertConstantNameToId (string $ constantName ): string {
1809
1809
$ tempLinkValue = str_replace (
1810
1810
array ("\\" , "_ " ),
1811
1811
array ("- " , "- " ),
1812
1812
trim ($ this ->normalizeFQN ($ constantName ), "_ " )
1813
1813
);
1814
-
1814
+
1815
1815
if (str_contains ($ constantName , ':: ' )) {
1816
1816
// class constant
1817
1817
list ($ extensionAndClass , $ constant ) = explode (":: " , $ tempLinkValue );
1818
1818
$ normalizedLinkFormat = $ extensionAndClass . ".constants. " . trim ($ constant , "- " );
1819
1819
} else {
1820
1820
$ normalizedLinkFormat = 'constant. ' . $ tempLinkValue ;
1821
1821
}
1822
-
1822
+
1823
1823
return $ normalizedLinkFormat ;
1824
1824
}
1825
1825
@@ -1829,7 +1829,7 @@ public function format_constant_text($value, $tag) {
1829
1829
}
1830
1830
1831
1831
$ normalizedLinkFormat = $ this ->convertConstantNameToId ($ value );
1832
-
1832
+
1833
1833
$ link = $ this ->createLink ($ normalizedLinkFormat );
1834
1834
1835
1835
if ($ link === null ) {
@@ -1844,34 +1844,34 @@ public function format_replaceable($open, $name, $attrs, $props) {
1844
1844
}
1845
1845
return false ;
1846
1846
}
1847
-
1847
+
1848
1848
public function format_property_text ($ value , $ tag ) {
1849
1849
if (! str_contains ($ value , ':: ' )) {
1850
1850
return $ value ;
1851
1851
}
1852
-
1852
+
1853
1853
$ tempLinkValue = str_replace (
1854
1854
["\\" , "_ " , "$ " ],
1855
1855
["- " , "- " , "" ],
1856
1856
trim ($ this ->normalizeFQN ($ value ), "_ " )
1857
1857
);
1858
-
1858
+
1859
1859
list ($ extensionAndClass , $ property ) = explode (":: " , $ tempLinkValue );
1860
1860
$ normalizedLinkFormat = $ extensionAndClass . ".props. " . trim ($ property , "- " );
1861
-
1861
+
1862
1862
$ link = $ this ->createLink ($ normalizedLinkFormat );
1863
-
1863
+
1864
1864
if ($ link === null || $ link === "" ) {
1865
1865
return $ value ;
1866
1866
}
1867
-
1867
+
1868
1868
return '<a href=" ' . $ link . '"> ' . $ value . '</a> ' ;
1869
1869
}
1870
-
1870
+
1871
1871
protected function normalizeFQN (string $ fqn ): string {
1872
1872
return \ltrim (\strtolower ($ fqn ), "\\" );
1873
1873
}
1874
-
1874
+
1875
1875
public function admonition_title ($ title , $ lang )
1876
1876
{
1877
1877
return '<strong class=" ' .(strtolower ($ title )). '"> ' .($ this ->autogen ($ title , $ lang )). '</strong> ' ;
0 commit comments