Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

Emmet-Pascal

Emmet engine for Delphi and Free Pascal.

Anyone may press Interesting, signed in or not. It helps others find this project.

In the Online Package Manager

Install it from inside Lazarus through Package, Online Package Manager.

Member rating

No ratings yet.

Sign in to rate this project.

README

Emmet engine for Delphi and Free Pascal

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. This is Emmet for Delphi and Free Pascal. It is written from scratch and is used in RJ TextEd and CudaText applications.

Getting Started

Download the files and include the Pascal files in your project.

Usage

First you need to create an Emmet object.

pascal
FEmmet := TEmmet.Create(snippetsPath, loremPath);
  • snippetsPath: The file path to Snippets.ini e.g. "c:\foo\Snipptes.ini"
  • loremPath: The file path to Lorem.txt e.g. "c:\foo\Lorem.txt"

To expand an abbreviation, use

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

Parameters:

  • sAbbr: Abbreviation e.g. "ul>li*5"
  • sSyntax: Code language in lowercase e.g. "html". Available values are: html, css, xsl, svg, xml, jsx, less, sass, scss.
  • sSelText: Text is used to wrap with abbreviation
  • sSection: Gets the section used in snippets.ini e.g. "html"
  • bMultiCursorTabs: Gets True if cursor positions in expanded string should be handled as multi cursor positions

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

Using the overloaded version you can set some options.

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

Wrap with abbreviation

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

  • sAbbrev: ul>li*
  • sSelText:
pascal
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>

Cheat sheets

Authors