Changeset 25 for trunk


Ignore:
Timestamp:
May 8, 2016, 10:56:38 PM (9 years ago)
Author:
chronos
Message:
  • Added: Use block start/end for source import format parsing.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/AcronymDecoder.lpi

    r22 r25  
    167167        <IsPartOfProject Value="True"/>
    168168        <ComponentName Value="FormImportFormat"/>
     169        <HasResources Value="True"/>
    169170        <ResourceBaseClass Value="Form"/>
    170171      </Unit12>
  • trunk/Example acronyms.adp

    r24 r25  
    839839    </Acronym>
    840840  </Acronyms>
    841   <ImportFormats>
     841 <ImportFormats>
    842842    <ImportFormat>
    843843      <Id>1</Id>
    844844      <Name>Mediawiki acronyms</Name>
     845      <BlockStartString/>
     846      <BlockEndString/>
    845847      <AcronymStartString>&lt;li&gt;&lt;b&gt;</AcronymStartString>
    846848      <AcronymEndString>&lt;/b&gt;</AcronymEndString>
     
    853855      <Id>2</Id>
    854856      <Name>MediaWiki Lingo</Name>
     857      <BlockStartString/>
     858      <BlockEndString/>
    855859      <AcronymStartString>mw-lingo-tooltip-abbr"&gt;</AcronymStartString>
    856860      <AcronymEndString>&lt;/span&gt;</AcronymEndString>
     
    863867      <Id>3</Id>
    864868      <Name>MediaWiki 2</Name>
     869      <BlockStartString>&lt;/ul&gt;</BlockStartString>
     870      <BlockEndString>&lt;table style</BlockEndString>
    865871      <AcronymStartString>&lt;li&gt;</AcronymStartString>
    866872      <AcronymEndString>—</AcronymEndString>
  • trunk/Forms/UFormImportFormat.lfm

    r22 r25  
    77  ClientHeight = 433
    88  ClientWidth = 664
    9   LCLVersion = '1.6.0.4'
     9  LCLVersion = '1.7'
    1010  object ButtonOk: TButton
    1111    Left = 560
     
    2828  object Label1: TLabel
    2929    Left = 20
    30     Height = 24
     30    Height = 22
    3131    Top = 16
    32     Width = 56
     32    Width = 49
    3333    Caption = 'Name:'
    3434    ParentColor = False
     
    3636  object EditName: TEdit
    3737    Left = 179
    38     Height = 34
     38    Height = 32
    3939    Top = 11
    4040    Width = 461
     
    4444  object Label2: TLabel
    4545    Left = 20
    46     Height = 24
    47     Top = 53
    48     Width = 126
     46    Height = 22
     47    Top = 133
     48    Width = 112
    4949    Caption = 'Acronym start:'
    5050    ParentColor = False
     
    5252  object EditAcronymStart: TEdit
    5353    Left = 179
    54     Height = 34
    55     Top = 48
     54    Height = 32
     55    Top = 128
    5656    Width = 461
    5757    Anchors = [akTop, akLeft, akRight]
     
    6060  object Label3: TLabel
    6161    Left = 20
    62     Height = 24
    63     Top = 93
    64     Width = 118
     62    Height = 22
     63    Top = 173
     64    Width = 105
    6565    Caption = 'Acronym end:'
    6666    ParentColor = False
     
    6868  object EditAcronymEnd: TEdit
    6969    Left = 179
    70     Height = 34
    71     Top = 88
     70    Height = 32
     71    Top = 168
    7272    Width = 461
    7373    Anchors = [akTop, akLeft, akRight]
     
    7676  object Label4: TLabel
    7777    Left = 20
    78     Height = 24
    79     Top = 133
    80     Width = 124
     78    Height = 22
     79    Top = 213
     80    Width = 111
    8181    Caption = 'Meaning start:'
    8282    ParentColor = False
     
    8484  object EditMeaningStart: TEdit
    8585    Left = 179
    86     Height = 34
    87     Top = 128
     86    Height = 32
     87    Top = 208
    8888    Width = 461
    8989    Anchors = [akTop, akLeft, akRight]
     
    9292  object Label5: TLabel
    9393    Left = 20
    94     Height = 24
    95     Top = 173
    96     Width = 116
     94    Height = 22
     95    Top = 253
     96    Width = 104
    9797    Caption = 'Meaning end:'
    9898    ParentColor = False
     
    100100  object EditMeaningEnd: TEdit
    101101    Left = 179
    102     Height = 34
    103     Top = 168
     102    Height = 32
     103    Top = 248
    104104    Width = 461
    105105    Anchors = [akTop, akLeft, akRight]
     
    108108  object Label6: TLabel
    109109    Left = 20
    110     Height = 24
    111     Top = 213
    112     Width = 148
     110    Height = 22
     111    Top = 293
     112    Width = 132
    113113    Caption = 'Description start:'
    114114    ParentColor = False
     
    116116  object EditDescriptionStart: TEdit
    117117    Left = 179
    118     Height = 34
    119     Top = 208
     118    Height = 32
     119    Top = 288
    120120    Width = 461
    121121    Anchors = [akTop, akLeft, akRight]
     
    124124  object Label7: TLabel
    125125    Left = 20
    126     Height = 24
    127     Top = 253
    128     Width = 140
     126    Height = 22
     127    Top = 333
     128    Width = 125
    129129    Caption = 'Description end:'
    130130    ParentColor = False
     
    132132  object EditDescriptionEnd: TEdit
    133133    Left = 179
    134     Height = 34
    135     Top = 248
     134    Height = 32
     135    Top = 328
    136136    Width = 461
    137137    Anchors = [akTop, akLeft, akRight]
    138138    TabOrder = 8
    139139  end
     140  object Label8: TLabel
     141    Left = 24
     142    Height = 22
     143    Top = 53
     144    Width = 85
     145    Caption = 'Block start:'
     146    ParentColor = False
     147  end
     148  object EditBlockStart: TEdit
     149    Left = 179
     150    Height = 32
     151    Top = 48
     152    Width = 461
     153    Anchors = [akTop, akLeft, akRight]
     154    TabOrder = 9
     155  end
     156  object Label9: TLabel
     157    Left = 24
     158    Height = 22
     159    Top = 93
     160    Width = 78
     161    Caption = 'Block end:'
     162    ParentColor = False
     163  end
     164  object EditBlockEnd: TEdit
     165    Left = 179
     166    Height = 32
     167    Top = 88
     168    Width = 461
     169    Anchors = [akTop, akLeft, akRight]
     170    TabOrder = 10
     171  end
    140172end
  • trunk/Forms/UFormImportFormat.lrt

    r22 r25  
    99TFORMIMPORTFORMAT.LABEL6.CAPTION=Description start:
    1010TFORMIMPORTFORMAT.LABEL7.CAPTION=Description end:
     11TFORMIMPORTFORMAT.LABEL8.CAPTION=Block start:
     12TFORMIMPORTFORMAT.LABEL9.CAPTION=Block end:
  • trunk/Forms/UFormImportFormat.pas

    r22 r25  
    1616    ButtonOk: TButton;
    1717    ButtonCancel: TButton;
     18    EditBlockEnd: TEdit;
     19    EditBlockStart: TEdit;
    1820    EditName: TEdit;
    1921    EditAcronymStart: TEdit;
     
    3032    Label6: TLabel;
    3133    Label7: TLabel;
     34    Label8: TLabel;
     35    Label9: TLabel;
    3236  private
    3337    { private declarations }
     
    4953begin
    5054  EditName.Text := ImportFormat.Name;
     55  EditBlockStart.Text := ImportFormat.Block.StartString;
     56  EditBlockEnd.Text := ImportFormat.Block.EndString;
    5157  EditAcronymStart.Text := ImportFormat.Acronym.StartString;
    5258  EditAcronymEnd.Text := ImportFormat.Acronym.EndString;
     
    6066begin
    6167  ImportFormat.Name := EditName.Text;
     68  ImportFormat.Block.StartString := EditBlockStart.Text;
     69  ImportFormat.Block.EndString := EditBlockEnd.Text;
    6270  ImportFormat.Acronym.StartString := EditAcronymStart.Text;
    6371  ImportFormat.Acronym.EndString := EditAcronymEnd.Text;
  • trunk/Languages/AcronymDecoder.cs.po

    r23 r25  
    229229msgstr "Konec popisu:"
    230230
     231#: tformimportformat.label8.caption
     232msgid "Block start:"
     233msgstr "Začátek bloku:"
     234
     235#: tformimportformat.label9.caption
     236msgid "Block end:"
     237msgstr "Konec bloku:"
     238
    231239#: tformimportformats.aadd.caption
    232240msgctxt "tformimportformats.aadd.caption"
     
    561569msgid "modified"
    562570msgstr "upraveno"
    563 
  • trunk/Languages/AcronymDecoder.po

    r23 r25  
    219219msgstr ""
    220220
     221#: tformimportformat.label8.caption
     222msgid "Block start:"
     223msgstr ""
     224
     225#: tformimportformat.label9.caption
     226msgid "Block end:"
     227msgstr ""
     228
    221229#: tformimportformats.aadd.caption
    222230msgctxt "TFORMIMPORTFORMATS.AADD.CAPTION"
  • trunk/UAcronym.pas

    r24 r25  
    120120    Id: Integer;
    121121    Name: string;
     122    Block: TImportPattern;
    122123    Acronym: TImportPattern;
    123124    Meaning: TImportPattern;
     
    233234begin
    234235  Name := Source.Name;
     236  Block.StartString := Source.Block.StartString;
     237  Block.EndString := Source.Block.EndString;
    235238  Acronym.StartString := Source.Acronym.StartString;
    236239  Acronym.EndString := Source.Acronym.EndString;
     
    245248  WriteInteger(Node, 'Id', Id);
    246249  WriteString(Node, 'Name', Name);
     250  WriteString(Node, 'BlockStartString', Block.StartString);
     251  WriteString(Node, 'BlockEndString', Block.EndString);
    247252  WriteString(Node, 'AcronymStartString', Acronym.StartString);
    248253  WriteString(Node, 'AcronymEndString', Acronym.EndString);
     
    257262  Id := ReadInteger(Node, 'Id', 0);
    258263  Name := ReadString(Node, 'Name', '');
     264  Block.StartString := ReadString(Node, 'BlockStartString', '');
     265  Block.EndString := ReadString(Node, 'BlockEndString', '');
    259266  Acronym.StartString := ReadString(Node, 'AcronymStartString', '');
    260267  Acronym.EndString := ReadString(Node, 'AcronymEndString', '');
     
    385392  NewAcronym: TAcronymEntry;
    386393  P: Integer;
     394  NewName: string;
    387395begin
    388396  Stream := TMemoryStream.Create;
     
    393401      SetLength(S, Stream.Size);
    394402      Stream.Read(S[1], Length(S));
     403      if Format.Block.StartString <> '' then begin
     404        P := Pos(Format.Block.StartString, S);
     405        if P > 0 then
     406          Delete(S, 1, P + Length(Format.Block.StartString) - 1);
     407      end;
     408      if Format.Block.EndString <> '' then begin
     409        P := Pos(Format.Block.EndString, S);
     410        if P > 0 then
     411          Delete(S, P, Length(S));
     412      end;
     413
    395414      repeat
    396415        P := Pos(Format.Acronym.StartString, S);
     
    399418          Delete(S, 1, P + Length(Format.Acronym.StartString) - 1);
    400419          P := Pos(Format.Acronym.EndString, S);
    401           NewAcronym.Name := Trim(StripHTML(Copy(S, 1, P - 1)));
     420          NewName := Trim(StripHTML(Copy(S, 1, P - 1)));
     421          if NewName <> '' then NewAcronym.Name := NewName;
    402422          Delete(S, 1, P + Length(Format.Acronym.EndString) - 1);
    403423
Note: See TracChangeset for help on using the changeset viewer.