Sign in Join
Wiki copytemporary

Emmet-Pascal

About

Emmet is mostly used by web-developers to simplify and speed up editing. Emmet can take an abbreviation and expand it into a structured code block. Standard Emmet is written in JavaScript and available in many text editors or web development tools. Emmet for Delphi and Free Pascal is written from scratch in Delphi and is used in RJ TextEd and CudaText.

Cheat sheets:

Engine gives special abbreviations for different file types:

Usage

First you need to create an Emmet object.

pascal
FEmmet := TEmmet.Create(snippetsPath, loremPath);

To expand an abbreviation, use

pascal
sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs);

Parameters:

Result: sExpanded is the resulting expanded code. It may contain cursor | positions or selected tab ${1:charset} positions.

Wrap with abbreviation

To use this feature, use parameter sSelText. E.g. if you call ExpandAbbreviation() with:

text
Line 1
Line 2
Line 3
Line 4

You get the result

pascal
<ul>
  <li>Line 1</li>
  <li>Line 2</li>
  <li>Line 3</li>
  <li>Line 4</li>
</ul>

Filters

TEmmet can handle some filters. A filter is added at the end of the abbreviation using a pipe |. E.g.

text
ul>li*|t

Example:

pascal
sAbbrev = ul>li*|t
pascal
sSelText =
  * Line 1
  * Line 2
pascal
Result =
  <ul>
    <li>Line 1</li>
    <li>Line 2</li>
  </ul>

Options

Several options exist in a record "TExpandOptions" that can be passed to the expand function. Options are:

Use the overloaded version of ExpandAbbreviation to set these options.

pascal
var
  rOptions: TExpandOptions;
begin
  rOptions.Wordwrap := True;
  rOptions.AddSlashToEmptyTags := False;
  sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs, rOptions);

Abbreviations for Markdown

In files with .md extension, special abbreviations are supported:

text
     a           = link
     b           = bold
     bq          = blockquote
     code        = inline code snippet
     h1..h6      = heading
     hr          = horizontal rule
     i           = italic
     img         = image
     ol          = ordered list
     pre         = code block with language based highlighting
     strike      = strike through
     table       = table
     ul          = unordered list
     @l or @l80  = create lorem generated text

Download

GitHub: https://github.com/rickard67/Emmet-Pascal

Originally was in the "Alexey-T" account, later was moved to Rickard's account, the author of Emmet-Pascal.

Authors


From the Free Pascal wiki, page "Emmet-Pascal", as it stood on 2020-12-25 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.