Pascal Emmet

I'll try to publish some code I use in my program.
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

Users need to get Lorem text even w/o any HTML, for ex in Markdown files, how to do it? @lorem don't work- it gives 2 tags.
inspector71
Posts: 220
Joined: 22 Sep 2017 07:59

Re: Pascal Emmet

Post by inspector71 »

Just noticed this thread.

Wow, you published / open sourced some of your code Rickard! That's sensational. Cannot be over-rated. I know there's a lot of open source code out there but you have made a step from closed to open and that is no doubt a great benefit for others and I find that a very promising and much appreciated effort ... even though I do not at presently code in Delphi / Pascal :) !! Never the less it's so great that other Pascal devs can benefit from your classy work!

Great stuff :)
Last edited by inspector71 on 20 Mar 2020 02:46, edited 1 time in total.
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

Please move
cMultiplicationMax = 1000;
into options record, as field, so user can change it to e.g. 1500 when need to generate very long result.
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

Code: Select all

    i := Pos('id=',s);
    
    i := Pos('class=',s);
I don't think it will work with uppercased tags, no?
User avatar
Rickard Johansson
Site Admin
Posts: 6575
Joined: 19 Jul 2006 14:29

Re: Pascal Emmet

Post by Rickard Johansson »

Updated the Pascal Emmet files to version 1.13.

Added Markdown support (including lorem generated text @l or @l200).
Added a TEmmet property to set the multiplication limit. Default is still cMultiplicationMax = 1000.
User avatar
Rickard Johansson
Site Admin
Posts: 6575
Joined: 19 Jul 2006 14:29

Re: Pascal Emmet

Post by Rickard Johansson »

i := Pos('id=',s);
i := Pos('class=',s);
Shouldn't be a problem. All tags in the snippets file are in lowercase. Abbreviations including .class should also be entered in lowercase.
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

I have problem with UNSUPPORTED tags. for ex, "bs4bp". my editor allows expanding of this snippet via its own plugin, and editor calls Emmet too. if "my plugin" is not installed, editor calls Emmet, Emmet gives something for "bs4bp" - 2 tags. not good. users don't need result when "my plugin for bs4bp" is absent.
can we NOT expand unknown tags in Emmet, plz? by option or always?
User avatar
Rickard Johansson
Site Admin
Posts: 6575
Joined: 19 Jul 2006 14:29

Re: Pascal Emmet

Post by Rickard Johansson »

Updated Emmet code to version 1.14.

The following was fixed:
* Fixed ${1:tabstop} index issue
* Fixed a class issue with span tag
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

thanks. can we have option
cMultiplicationMax = 1000;
in the options "record", not as "const", please?

Edit. you already did it.
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

RJ, can you please see report at viewtopic.php?p=17013#p17013 ?
User avatar
Rickard Johansson
Site Admin
Posts: 6575
Joined: 19 Jul 2006 14:29

Re: Pascal Emmet

Post by Rickard Johansson »

It's not that simple. Not all HTML tags are added as abbreviations in the snippets file and XML tags are impossible to add, since they can be anything.

HTML
You may want this to work: p.myclass => <p class="myclass"></p> . But p is not added as an abbreviation, so with an option to only expand known tags - this wont work.

XML
In XML you can type something like this: developer#rickard{@lorem} => <developer id="rickard"> ... </developer>. This, of course, wont work either.

Maybe you could use a dedicated shortcut to expand Emmet abbreviations. And something else for other tasks?
User avatar
Rickard Johansson
Site Admin
Posts: 6575
Joined: 19 Jul 2006 14:29

Re: Pascal Emmet

Post by Rickard Johansson »

Updated to version 1.15.

Version 1.15
* Added option to replace cursor positions | with indexed tab positions ${x}
Alextp
Posts: 69
Joined: 23 Aug 2014 23:36

Re: Pascal Emmet

Post by Alextp »

FPC 3.0.4 compile error
emmet.pas

function TEmmet.ExpandAbbreviation(AString: string; const ASyntax, ASelText:
string; out ASection: string; out bMultiCursorTabs: Boolean): string;
..
opt.AlwaysReturnIndexedTabs := False;

while record has another member

Code: Select all

  TExpandOptions = record
    AddSlashToEmptyTags: Boolean; // Add a slash to empty tags e.g. <img src="" />
    AlwaysAddNewLine: Boolean;    // Always add linefeed after each tag (usually used in XML)
    AlwaysReturnIndexedTabStops: Boolean; // Convert all cursor positions | to indexed tab positions ${x} (HMTL,XML)
User avatar
Rickard Johansson
Site Admin
Posts: 6575
Joined: 19 Jul 2006 14:29

Re: Pascal Emmet

Post by Rickard Johansson »

I've updated the archive file and should now contain the correct version.
Post Reply