Difference between revisions of "Emmet-Pascal"

From Free Pascal wiki
Jump to navigationJump to search
(→‎Usage: v1.09)
Line 34: Line 34:
  
 
Result: sExpanded is the resulting expanded code. It may contain cursor | positions or selected tab ${1:charset} 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 expand options.
 +
 +
<syntaxhighlight>
 +
var
 +
  rOptions: TExpandOptions;
 +
begin
 +
  rOptions.Wordwrap := True;
 +
  rOptions.AddSlashToEmptyTags := False;
 +
  sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs, rOptions);
 +
</syntaxhighlight>
  
 
=Wrap with abbreviation=
 
=Wrap with abbreviation=

Revision as of 00:25, 28 July 2019

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

Cheat sheets:

Usage

First you need to create an Emmet object.

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

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 expand options.

var
  rOptions: TExpandOptions;
begin
  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:
Line 1
Line 2
Line 3
Line 4

You get the result

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

Download

GitHub: https://github.com/Alexey-T/Emmet-Pascal

Authors

  • Rickard Johansson - Emmet.pas
  • Alexey Torgashin - Misc files and demos