Changeset 37


Ignore:
Timestamp:
Jun 4, 2014, 1:31:13 PM (7 years ago)
Author:
vadim.godunko
Message:

Improve regular expressions to extract text without leading/trailing
spaces.

Location:
trunk/forge/source/wiki
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/forge/source/wiki/forge-wiki-block_parsers-headers.adb

    r36 r37  
    114114      Forge.Wiki.Parsers.Register_Block_Parser
    115115       (League.Strings.To_Universal_String
    116          ("^\p{White_Space}*(\=+)\p{White_Space}*(\P{White_Space})"),
     116         ("^\p{White_Space}* (\=+) \p{White_Space}*"
     117            & " (\P{White_Space}+) \p{White_Space}* \=*$"),
    117118        2,
    118119        1,
  • trunk/forge/source/wiki/forge-wiki-block_parsers-lists.adb

    r32 r37  
    116116      Forge.Wiki.Parsers.Register_Block_Parser
    117117       (League.Strings.To_Universal_String
    118          ("^\p{White_Space}*(\-)\p{White_Space}*(\P{White_Space})"),
     118         ("^\p{White_Space}* (\-) \p{White_Space}*"
     119            & " (\P{White_Space}.*) \p{White_Space}*$"),
    119120        2,
    120121        1,
  • trunk/forge/source/wiki/forge-wiki-block_parsers-paragraphs.adb

    r32 r37  
    9797      Forge.Wiki.Parsers.Register_Paragraph_Block_Parser
    9898       (League.Strings.To_Universal_String
    99          ("^\p{White_Space}*(\P{White_Space})"),
     99         ("^\p{White_Space}* (\P{White_Space}.*) \p{White_Space}*$"),
    100100        1,
    101101        1,
  • trunk/forge/source/wiki/forge-wiki-parsers.adb

    r36 r37  
    185185      Line           : Positive := 1;
    186186      Match          : League.Regexps.Regexp_Match;
    187       Text_Offset    : Natural;
     187      Text_First     : Natural;
     188      Text_Last      : Natural;
    188189      Found          : Boolean;
    189190      Previous_Block : Forge.Wiki.Block_Parsers.Block_Parser_Access;
     
    214215                 <= Match.Last_Index (Item.Match_Group)
    215216            then
    216                Text_Offset := Match.First_Index (Item.Offset_Group);
     217               Text_First := Match.First_Index (Item.Offset_Group);
     218               Text_Last  := Match.Last_Index (Item.Offset_Group);
    217219
    218220               if Item.Is_Start
     
    230232                      (if Item.Markup_Group = 0
    231233                         then 0 else Match.First_Index (Item.Markup_Group)),
    232                       Text_Offset);
     234                      Text_First);
    233235
    234236                  Previous_Block := Self.Block_State;
     
    267269               end if;
    268270
    269                Self.Block_State.Line (Lines (Line).Tail_From (Text_Offset));
     271               Self.Block_State.Line
     272                (Lines (Line).Slice (Text_First, Text_Last));
    270273
    271274               --  Detect whether block element occupy only one line.
Note: See TracChangeset for help on using the changeset viewer.