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 <[email protected]> wrote:

> Hello,
>
> I try to implement in GtkSourceView this (properly working) RegEx:
>
> https://regex101.com/r/FjUQRK/1
>
> 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:
>
> https://pasteboard.co/Kiiwyi5.png
>
> Is it a bug in GtkSourceView or me doing something wrong?
>
> Thank you!
>
>
> [image: Screenshot from 2021-08-30 18-13-22.png]
>
>
>
>
_______________________________________________
gnome-devtools mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-devtools

Reply via email to