Add Php to Htmllanguage

SyntaxEditor for WPF Forum

Posted 5 months ago by Kevin Knöller
Version: 19.1.0685
Avatar

Hi, i need in the the HTML-language the support for PHP with that code:

<div>
<?php echo "text"; ?>
</div>

For this i add this in the HTML-Language:

<State Key="PhpStartTag" DefaultTokenKey="StartTagText" DefaultClassificationTypeKey="XmlComment">
<State.Scopes>
<Scope>
<Scope.StartPatternGroup>
<ExplicitPatternGroup TokenKey="PhpStartDelimiter" ClassificationTypeKey="XmlDelimiter" Pattern="&lt;?php" />
</Scope.StartPatternGroup>
<Scope.EndPatternGroup>
<ExplicitPatternGroup TokenKey="PhpEndDelimiter" ClassificationTypeKey="XmlDelimiter" Pattern="?&gt;" />
</Scope.EndPatternGroup>
<Scope.Transition>
<StateTransition>
<StateTransition.ChildLanguage>
<LanguageRef ManifestResourceStreamName="UWS_ServerManager.SyntaxEditor.Definitions.Php.langdef" />
</StateTransition.ChildLanguage>
<StateTransition.ChildScope>
<Scope>
<Scope.EndPatternGroup>
<RegexPatternGroup TokenKey="PhpEndDelimiter" ClassificationTypeKey="XmlDelimiter" Pattern="?&gt;" />
</Scope.EndPatternGroup>
</Scope>
</StateTransition.ChildScope>
</StateTransition>
</Scope.Transition>
</Scope>
</State.Scopes>
<RegexPatternGroup Pattern="[^(&lt;\?php)(\?&gt;)]+" />
</State>

<?php and ?> it will print in the XmlDelimiter-Color, but the content with the XmlComment -Color. 

When i use complete tags like <php></php>, then it will run, but these is wrong of course^^

What am I doing wrong?

Thanks in advance!

Comments (2)

Answer - Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

This code seemed to work for me when pasting it in our sample's Html.langdef file:

<State Key="PhpStartTag" DefaultTokenKey="StartTagText" DefaultClassificationTypeKey="XmlComment">
	<State.Scopes>
		<Scope>
			<Scope.StartPatternGroup>
				<ExplicitPatternGroup TokenKey="PhpStartTag" ClassificationTypeKey="XmlDelimiter" Pattern="&lt;?php" />
			</Scope.StartPatternGroup>
			<Scope.EndPatternGroup>
				<ExplicitPatternGroup TokenKey="PhpEndDelimiter" ClassificationTypeKey="XmlDelimiter" Pattern="?&gt;" />
			</Scope.EndPatternGroup>
		</Scope>
	</State.Scopes>
	<State.Transition>
		<StateTransition>
			<StateTransition.ChildLanguage>
				<LanguageRef ManifestResourceStreamName="ActiproSoftware.ProductSamples.SyntaxEditorSamples.Languages.Definitions.Php.langdef" />
			</StateTransition.ChildLanguage>
		</StateTransition>
	</State.Transition>
</State>

With this added right after the Comment state ref in the Default state's ChildStates:

<StateRef Key="PhpStartTag" />


Actipro Software Support

Posted 5 months ago by Kevin Knöller
Avatar

Thanks for you answer! I found my mistake. In the examples, the Tag Scope.Transition are in the Scopes and not at the end... Now it run correctly.

The latest build of this product (v2019.1 build 0686) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.