Re: GtkSourceView: RegEx issues



The language definition file in question is here:

https://gitlab.com/pninim.org/dar/dar-syntax/-/blob/master/dar.lang

The problematic line is here:

https://gitlab.com/pninim.org/dar/dar-syntax/-/blob/master/dar.lang#L293

Example syntax file to test the RegEx (see screenshot in the first email):

https://gitlab.com/pninim.org/dar/dar-syntax/-/blob/master/syntax.dar


Thank you!




On Mon, Aug 30, 2021 at 8:18 PM Sim Tov <smntov gmail com> wrote:
Also tried this RegEx:

^(\[\^)([^\]\s\p{C}]+)(\])\ (\P{C}*(?:\n(?!\n[\[\n])\P{C}*)*)

and again here it works:

https://regex101.com/r/Zl3te8/1

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>


On Mon, Aug 30, 2021 at 6:53 PM Sim Tov <smntov gmail com> wrote:
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.

I tried to implement the same RegEx in GtkSourceView as follows ( https://paste.debian.net/1209662/ )  :

    <!-- 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!


Screenshot from 2021-08-30 18-13-22.png





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]