Re: GtkSourceView: RegEx issues
- From: Sim Tov <smntov gmail com>
 
- To: gnome-devtools gnome org
 
- Subject: Re: GtkSourceView: RegEx issues
 
- Date: Tue, 31 Aug 2021 00:43:00 +0300
 
The language definition file in question is here:
The problematic line is here:
Example syntax file to test the RegEx (see screenshot in the first email):
Thank you!
Also tried this RegEx:
^(\[\^)([^\]\s\p{C}]+)(\])\ (\P{C}*(?:\n(?!\n[\[\n])\P{C}*)*)
and again here it works:
But inside GtkSourceView it doesn't (i.e. provides the same results as in the picture above):
    <!-- Examples:
        [^note_name] note body
       RegEx: ^(\[\^)([^\]\s\p{C}]+)(\])\ (\P{C}*(?:\n(?!\n[\[\n])\P{C}*)*)
    -->
    <context id="note">
      <match extended="true">
        ^(\[\^)                               # Opening bracket and the caret at line begin.
        ([^\]\s\p{C}]+)                       # note_name.
        (\])                                  # Closing bracket.
        \ (\P{C}*(?:\n(?!\n[\[\n])\P{C}*)*)   # One space and note body; till a new note (i.e. new line + opening bracket) or three new lines or end of string.
      </match>
      <include>
        <context sub-pattern="1" class="no-spell-check" style-ref="note-marker"/>
        <context sub-pattern="2" class="no-spell-check" style-ref="note-name"/>
        <context sub-pattern="3" class="no-spell-check" style-ref="note-marker"/>
        <context sub-pattern="4" style-ref="note-body"/>
      </include>
    </context>
Hello,
I try to implement in GtkSourceView this (properly working) RegEx:
As you can see there the second footnote [^1] ... spans over several paragraphs and all are captured by the RegEx.
    <!-- Examples:
        [^note_name] note body
       RegEx: ^(\[\^)([^\s\p{C}\]]+)(\])\ ([\P{C}\n]*?)(?=\n\[|\n\n\n|\Z)
    -->
    <context id="note">
      <match extended="true">
        ^(\[\^)              # Opening bracket and the caret at line begin.
        ([^\s\p{C}\]]+)      # note_name.
        (\])                 # Closing bracket.
        \ ([\P{C}\n]*?)      # One space and note body.
        (?=\n\[|\n\n\n|\Z)   # Till a new note (i.e. new line + opening bracket) or three new lines or end of string.
      </match>
      <include>
        <context sub-pattern="1" class="no-spell-check" style-ref="note-marker"/>
        <context sub-pattern="2" class="no-spell-check" style-ref="note-name"/>
        <context sub-pattern="3" class="no-spell-check" style-ref="note-marker"/>
        <context sub-pattern="4" style-ref="note-body"/>
      </include>
    </context>
However only the first paragraph of [^1]... is captured and not the rest... Here is how it looks:
Is it a bug in GtkSourceView or me doing something wrong?
Thank you!
 
 
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]