<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nethackwiki.com/index.php?action=history&amp;feed=atom&amp;title=User%3APaxed%2FMixedSyntaxHighlight</id>
	<title>User:Paxed/MixedSyntaxHighlight - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nethackwiki.com/index.php?action=history&amp;feed=atom&amp;title=User%3APaxed%2FMixedSyntaxHighlight"/>
	<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;action=history"/>
	<updated>2026-07-21T20:19:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.5</generator>
	<entry>
		<id>https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;diff=57173&amp;oldid=prev</id>
		<title>Paxed: /* Code for MixedSyntaxHighlight.php */ fix.</title>
		<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;diff=57173&amp;oldid=prev"/>
		<updated>2010-11-20T13:03:34Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code for MixedSyntaxHighlight.php: &lt;/span&gt; fix.&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 13:03, 20 November 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l44&quot; &gt;Line 44:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 44:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     function languageGetMagic(&amp;amp;$magicWords, $langCode) {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     function languageGetMagic(&amp;amp;$magicWords, $langCode) {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         $magicWords[MAG_MIXEDSYNTAXHIGHLIGHT] = array( 0, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'&lt;/del&gt;__MIXEDSYNTAXHIGHLIGHT__&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;' &lt;/del&gt;);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         $magicWords[MAG_MIXEDSYNTAXHIGHLIGHT] = array( 0, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&lt;/ins&gt;__MIXEDSYNTAXHIGHLIGHT__&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;\n&amp;quot; &lt;/ins&gt;);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         return true;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         return true;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Paxed</name></author>
		
	</entry>
	<entry>
		<id>https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;diff=57171&amp;oldid=prev</id>
		<title>Paxed: add link to the wikification script.</title>
		<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;diff=57171&amp;oldid=prev"/>
		<updated>2010-11-20T12:19:44Z</updated>

		<summary type="html">&lt;p&gt;add link to the wikification script.&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 12:19, 20 November 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each line that is supposed to be hilighted should be in the format&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each line that is supposed to be hilighted should be in the format&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;nowiki&amp;gt;&amp;quot; &amp;lt;span id=&amp;quot;line1234&amp;quot;&amp;gt;1234. line of code&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/nowiki&amp;gt; (Note the space at the beginning of the line)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;nowiki&amp;gt;&amp;quot; &amp;lt;span id=&amp;quot;line1234&amp;quot;&amp;gt;1234. line of code&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/nowiki&amp;gt; (Note the space at the beginning of the line)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The files were normal C source code, mangled with [[User:Jayt#Source_wikification_script|Jayt's script]].&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code for MixedSyntaxHighlight.php==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code for MixedSyntaxHighlight.php==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Paxed</name></author>
		
	</entry>
	<entry>
		<id>https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;diff=57170&amp;oldid=prev</id>
		<title>Paxed: document the extension.</title>
		<link rel="alternate" type="text/html" href="https://nethackwiki.com/index.php?title=User:Paxed/MixedSyntaxHighlight&amp;diff=57170&amp;oldid=prev"/>
		<updated>2010-11-20T12:15:45Z</updated>

		<summary type="html">&lt;p&gt;document the extension.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a small extension that adds the magic word _&amp;lt;nowiki&amp;gt;_MIXEDSYNTAXHIGHLIGHT&amp;lt;/nowiki&amp;gt;__ and is used on the NetHackWiki source code pages to automatically hilite source lines with GeSHi (using [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi SyntaxHighlight_GeSHi] while still allowing interspersed wiki markup.&lt;br /&gt;
&lt;br /&gt;
Each line that is supposed to be hilighted should be in the format&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&amp;quot; &amp;lt;span id=&amp;quot;line1234&amp;quot;&amp;gt;1234. line of code&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/nowiki&amp;gt; (Note the space at the beginning of the line)&lt;br /&gt;
&lt;br /&gt;
==Code for MixedSyntaxHighlight.php==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
if (!defined('MEDIAWIKI')) {&lt;br /&gt;
    die(&amp;quot;Sorry.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$wgExtensionCredits['parserhook'][] = array(&lt;br /&gt;
                                            'name' =&amp;gt; 'MixedSyntaxHighlight',&lt;br /&gt;
                                            'version' =&amp;gt; 0.1,&lt;br /&gt;
                                            'author' =&amp;gt; '[http://nethackwiki.com/wiki/User:Paxed Pasi Kallinen]',&lt;br /&gt;
                                            'description' =&amp;gt; 'Add MagicWord &amp;quot;_&amp;lt;nowiki&amp;gt;_MIXEDSYNTAXHIGHLIGHT&amp;lt;/nowiki&amp;gt;__&amp;quot;.',&lt;br /&gt;
                                            'url' =&amp;gt; 'http://nethackwiki.com/wiki/User:Paxed/MixedSyntaxHighlight',&lt;br /&gt;
                                            );&lt;br /&gt;
&lt;br /&gt;
$mixedSyntaxHighlight = new MixedSyntaxHighlight();&lt;br /&gt;
&lt;br /&gt;
$wgHooks['MagicWordMagicWords'][] = array($mixedSyntaxHighlight, 'addMagicWord');&lt;br /&gt;
$wgHooks['MagicWordwgVariableIDs'][] = array($mixedSyntaxHighlight, 'addMagicWordId');&lt;br /&gt;
$wgHooks['LanguageGetMagic'][] = array($mixedSyntaxHighlight, 'languageGetMagic');&lt;br /&gt;
$wgHooks['ParserBeforeStrip'][] = array($mixedSyntaxHighlight, 'parserBeforeStrip');&lt;br /&gt;
&lt;br /&gt;
class MixedSyntaxHighlight {                &lt;br /&gt;
    //    private $mixed_hilite_enabled = false;                                                                                             &lt;br /&gt;
&lt;br /&gt;
    function MixedSyntaxHighlight() { }&lt;br /&gt;
&lt;br /&gt;
    function addMagicWord(&amp;amp;$magicWords) {&lt;br /&gt;
        $magicWords[] = 'MAG_MIXEDSYNTAXHIGHLIGHT';&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function addMagicWordId(&amp;amp;$magicWords) {&lt;br /&gt;
        $magicWords[] = MAG_MIXEDSYNTAXHIGHLIGHT;&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function languageGetMagic(&amp;amp;$magicWords, $langCode) {&lt;br /&gt;
        $magicWords[MAG_MIXEDSYNTAXHIGHLIGHT] = array( 0, '__MIXEDSYNTAXHIGHLIGHT__' );&lt;br /&gt;
        return true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function parserBeforeStrip( &amp;amp;$parser, &amp;amp;$text ) {&lt;br /&gt;
        if (MagicWord::get(MAG_MIXEDSYNTAXHIGHLIGHT)-&amp;gt;matchAndRemove( $text )) {&lt;br /&gt;
            $text = $this-&amp;gt;doTaggingExchange($text, 'lang=&amp;quot;c&amp;quot; line lineid=&amp;quot;line&amp;quot;');&lt;br /&gt;
        }&lt;br /&gt;
        return true;&lt;br /&gt;
    }     &lt;br /&gt;
          &lt;br /&gt;
    function doTaggingExchange($text, $query='') {&lt;br /&gt;
        $tmp = preg_split(&amp;quot;/\n/&amp;quot;, $text);&lt;br /&gt;
        $text = '';&lt;br /&gt;
        $codeline = -1;&lt;br /&gt;
&lt;br /&gt;
        foreach ($tmp as $line) {&lt;br /&gt;
            if (preg_match('/^ &amp;lt;span id=\&amp;quot;line([0-9]{1,4})&amp;quot;&amp;gt;[0-9]{1,4}\. *(.*)&amp;lt;\/span&amp;gt;$/', $line, $matches)) {&lt;br /&gt;
                if ($codeline == -1) {&lt;br /&gt;
                    $codeline = $matches[1];&lt;br /&gt;
                    $text .= &amp;quot;&amp;lt;&amp;quot;.&amp;quot;syntaxhighlight &amp;quot;.$query.&amp;quot; start=\&amp;quot;&amp;quot;.$codeline.&amp;quot;\&amp;quot;&amp;gt;\n&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
                $text .= $matches[2].&amp;quot;\n&amp;quot;;&lt;br /&gt;
            } else {&lt;br /&gt;
                if ($codeline != -1) {&lt;br /&gt;
                    $text .= &amp;quot;\n&amp;lt;&amp;quot;.&amp;quot;/syntaxhighlight&amp;gt;\n&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
                $codeline = -1;&lt;br /&gt;
                $text .= $line.&amp;quot;\n&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return $text;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Paxed</name></author>
		
	</entry>
</feed>