Recent

Author Topic: CommonMark Processor  (Read 4399 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
CommonMark Processor
« on: January 07, 2019, 10:04:15 pm »
I've updated my markdown code to support CommonMark as well as the original markdown (https://github.com/grahamegrieve/delphi-markdown).

I've just tried to get it compiling/working under FPC (/Lazarus), but I don't know how to do several things: DUnitX, RegEx, Json, and how to get Unicode Character Category. Does someone want to help?

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: CommonMark Processor
« Reply #1 on: January 09, 2019, 02:30:34 pm »
RegEx: FPC 3.x has unit RegExpr. Examples exist in FPC-
C:\fpcupdeluxe\fpcsrc\packages\regexpr\examples\testreg1.pp

JSON: FPC 3.0.4 has FCL-Json lib.
C:\fpcupdeluxe\fpcsrc\packages\fcl-json

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: CommonMark Processor
« Reply #2 on: January 09, 2019, 02:34:02 pm »
Unicode category-
Code: Pascal  [Select][+][-]
  1. uses UnicodeData;
  2.  
  3.  function IsCharWord(ch: WideChar): boolean;
  4.  var
  5.    NType: byte;
  6.  begin
  7.    case ch of
  8.      '0'..'9',
  9.      'a'..'z',
  10.      'A'..'Z',
  11.      '_':
  12.        exit(true);
  13.    end;
  14.  
  15.    if Ord(ch)<128 then
  16.      Result:= false
  17.    else
  18.    if Ord(ch)>=LOW_SURROGATE_BEGIN then
  19.      exit(false)
  20.    else
  21.    begin
  22.      NType:= GetProps(Ord(ch))^.Category;
  23.      Result:= (NType<=UGC_OtherNumber);
  24.    end;
  25.  end;
  26.  

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: CommonMark Processor
« Reply #3 on: January 12, 2019, 01:57:01 pm »
Thanks - committed. ... but not yet tested - I will get to that as soon as I can

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: CommonMark Processor
« Reply #4 on: January 12, 2019, 02:09:53 pm »
I'm not sure that new func IsMMMMPunctuation has OK results.

 

TinyPortal © 2005-2018