# COMMENTS IN WPF EDITOR WITH HTMLSCRIPTPARSER

**URL:** <https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135>\
**Category:** AlterNET Studio Support\
**Tags:** wpf, editor\
**Created:** [November 7, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135 "2018-11-07T00:00:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kai.wachter](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/k/606060/32.png) [@kai.wachter](https://forum.alternetsoft.com/u/kai.wachter)\
**Post date:** [November 7, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/1 "2018-11-07T00:00:00Z")

</div>

Hello,  
we are using the WPF Editor with the HtmlScriptParser as Lexer.  
We have two issues:  
1. CSS comments are not highlighted in green (not highlighted at all)  
2. When using Ctrl+K, Ctrl+C to comment the current selection within CSS or Javascript, the comment looks like an HTML comment and not like a Javascript comment.  
Highlighting Javascript comments works tho, just not setting the comments via keyboard shortcut.  
  
Regards

---

<div class="post-metadata">

**Author:** ![kai.wachter](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/k/606060/32.png) [@kai.wachter](https://forum.alternetsoft.com/u/kai.wachter)\
**Post date:** [November 7, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/2 "2018-11-07T00:00:00Z")

</div>

Is there a method in the TextSource class to comment (and uncomment) the current selection. So basically a method we can call to execute the comment/uncomment keyboard shortcuts

---

<div class="post-metadata">

**Author:** ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)\
**Post date:** [November 11, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/3 "2018-11-11T00:00:00Z")

</div>

Hi Kai,  
We currently do not have support for highlighting Css code in html code, but this should be fairly simple to implement.   
We will provide you an sample shortly.  
You can call Selection.CommentSelection method, which will comment out current selection with single or multi-line comment (this needs to be provided by parser):  
[https://drive.google.com/open?id=1IQye94nbCVoFMTKEKd-\_5bJL1Cu3n0B8](https://drive.google.com/open?id=1IQye94nbCVoFMTKEKd-_5bJL1Cu3n0B8)  
regards,  
Andrew

---

<div class="post-metadata">

**Author:** ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)\
**Post date:** [November 13, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/4 "2018-11-13T00:00:00Z")

</div>

Hi Kai,  
I've uploaded modified with support for CSS code highlighting in HTML:  
[https://drive.google.com/open?id=16\_yC-O7St3lzUgBcUaeiyN4pbxG4pm1S](https://drive.google.com/open?id=16_yC-O7St3lzUgBcUaeiyN4pbxG4pm1S)  
regards,  
Andrew

---

<div class="post-metadata">

**Author:** ![kai.wachter](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/k/606060/32.png) [@kai.wachter](https://forum.alternetsoft.com/u/kai.wachter)\
**Post date:** [November 16, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/5 "2018-11-16T00:00:00Z")

</div>

Hi Andrew,  
  
there are a few issues with the sample.  
1. An infinite loop occurs if you delete the tag "" in line 15  
2. Highlighting the CSS /\*comments\*/ still does not work. Currently the editor highlights comments within CSS that start with "//" like in JavaScript, but CSS comments should always look /\*like this\*/ even if single line.  
  
Regards

---

<div class="post-metadata">

**Author:** ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)\
**Post date:** [November 17, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/6 "2018-11-17T00:00:00Z")

</div>

Hi Kai,  
thank you for the bug report.  
I've uploaded fixed version.  
[https://drive.google.com/open?id=16\_yC-O7St3lzUgBcUaeiyN4pbxG4pm1S](https://drive.google.com/open?id=16_yC-O7St3lzUgBcUaeiyN4pbxG4pm1S)  
Please try them and let me know whether it works as expected.  
regards,  
Andrew

---

<div class="post-metadata">

**Author:** ![kai.wachter](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/k/606060/32.png) [@kai.wachter](https://forum.alternetsoft.com/u/kai.wachter)\
**Post date:** [November 19, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/7 "2018-11-19T00:00:00Z")

</div>

Hi Andrew,  
it's better now, but there is still a highlighting issue regarding CSS attributes. If you highlight the line "text-align: center;" in the CSS and you use Ctrl+K, Ctrl+C to comment the attribute, then the comment will not be highlighted.  
Regards

---

<div class="post-metadata">

**Author:** ![kai.wachter](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/k/606060/32.png) [@kai.wachter](https://forum.alternetsoft.com/u/kai.wachter)\
**Post date:** [November 19, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/8 "2018-11-19T00:00:00Z")

</div>

Should clarify:  
we want the line "text-align: center;" to be displayed in green when changed to "/\*text-align: center;\*/"  
Regards

---

<div class="post-metadata">

**Author:** ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)\
**Post date:** [November 19, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/9 "2018-11-19T00:00:00Z")

</div>

Hi Kai,  
I'm uploading modified CssParser:  
[https://drive.google.com/open?id=1JvDg6BdH0KSGihicY6gN1hY9kbFfXAbU](https://drive.google.com/open?id=1JvDg6BdH0KSGihicY6gN1hY9kbFfXAbU)  
regards,  
Andrew

---

<div class="post-metadata">

**Author:** ![kai.wachter](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/k/606060/32.png) [@kai.wachter](https://forum.alternetsoft.com/u/kai.wachter)\
**Post date:** [November 20, 2018, 12:00am UTC](https://forum.alternetsoft.com/t/comments-in-wpf-editor-with-htmlscriptparser/135/10 "2018-11-20T00:00:00Z")

</div>

Hi Andrew,  
thank you, I think we have most of what we need for now.  
Regards
