Changeset 24


Ignore:
Timestamp:
May 5, 2016, 12:09:19 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Better import source parsing.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Example acronyms.adp

    r22 r24  
    860860      <DescriptionEndString/>
    861861    </ImportFormat>
     862    <ImportFormat>
     863      <Id>3</Id>
     864      <Name>MediaWiki 2</Name>
     865      <AcronymStartString>&lt;li&gt;</AcronymStartString>
     866      <AcronymEndString>—</AcronymEndString>
     867      <MeaningStartString/>
     868      <MeaningEndString>&lt;/li&gt;</MeaningEndString>
     869      <DescriptionStartString/>
     870      <DescriptionEndString/>
     871    </ImportFormat>
    862872  </ImportFormats>
    863873  <ImportSources>
     
    872882      <ImportFormat>2</ImportFormat>
    873883    </ImportSource>
     884    <ImportSource>
     885      <Name>Wikipedia - List of energy abbreviations</Name>
     886      <URL>https://en.wikipedia.org/wiki/List_of_energy_abbreviations</URL>
     887      <ImportFormat>3</ImportFormat>
     888    </ImportSource>
    874889  </ImportSources>
    875890</AcronymDecoderProject>
  • trunk/UAcronym.pas

    r22 r24  
    217217  while (TagBegin > 0) do begin  // while there is a < in S
    218218    TagEnd := Pos('>', S);              // find the matching >
    219     TagLength := TagEnd - TagBegin + 1;
    220     Delete(S, TagBegin, TagLength);     // delete the tag
    221     TagBegin:= Pos( '<', S);            // search for next <
     219    if TagEnd = 0 then TagLength := Length(S) - TagBegin
     220      else TagLength := TagEnd - TagBegin + 1;
     221    if TagLength > 0 then
     222      Delete(S, TagBegin, TagLength)     // delete the tag
     223      else Delete(S, 1, TagEnd);     // delete the tag
     224    TagBegin := Pos( '<', S);            // search for next <
    222225  end;
    223226
     
    400403
    401404          // Meaning
    402           P := Pos(Format.Meaning.StartString, S);
    403           Delete(S, 1, P + Length(Format.Meaning.StartString) - 1);
     405          if Length(Format.Meaning.StartString) > 0 then begin
     406            P := Pos(Format.Meaning.StartString, S);
     407            Delete(S, 1, P + Length(Format.Meaning.StartString) - 1);
     408          end;
    404409          P := Pos(Format.Meaning.EndString, S);
    405410          NewAcronym.Meaning := Trim(StripHTML(Copy(S, 1, P - 1)));
Note: See TracChangeset for help on using the changeset viewer.