Sign in Join
Wiki copytemporary

Emmet-Pascal: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# About
22
33Emmet 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]].
44
55Cheat sheets:
66
77- Emmet-Pascal - <https://www.rj-texted.se/Help/Emmetcheatsheet.html>
88- Standard Emmet - <https://docs.emmet.io/cheat-sheet/>
99
1010Engine gives special abbreviations for different file types:
1111
1212- HTML: about 200 items
1313- XSL: about 40 items
1414- SVG: about 50 items
1515- CSS: about 650 items
1616- Markdown: about 20 items
1717
1818# Usage
1919
2020First you need to create an Emmet object.
2121
2222``` pascal
2323FEmmet := TEmmet.Create(snippetsPath, loremPath);
2424```
2525
2626- snippetsPath: The file path to Snippets.ini e.g. "c:\foo\Snipptes.ini"
2727- loremPath: The file path to Lorem.txt e.g. "c:\foo\Lorem.txt"
2828
2929To expand an abbreviation, use
3030
3131``` pascal
3232sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs);
3333```
3434
3535Parameters:
3636
3737- sAbbr: Abbreviation e.g. "ul\>li*5"
3838- sSyntax: Code language in lowercase e.g. "html". Available values are: html, css, xsl, svg, xml, jsx, less, sass, scss.
3939- sSelText: Text is used to wrap with abbreviation
4040- sSection: Gets the section used in snippets.ini e.g. "html"
4141- bMultiCursorTabs: Gets True if cursor positions in expanded string should be handled as multi cursor positions
4242
4343Result: sExpanded is the resulting expanded code. It may contain cursor \| positions or selected tab \${1:charset} positions.
4444
4545# Wrap with abbreviation
4646
4747To use this feature, use parameter sSelText. E.g. if you call ExpandAbbreviation() with:
4848
4949- sAbbrev: ul\>li*
5050- sSelText:
5151
52-`Line 1`\
53-`Line 2`\
54-`Line 3`\
55-`Line 4`
52+```text
53+Line 1
54+Line 2
55+Line 3
56+Line 4
57+```
5658
5759You get the result
5860
5961 <ul>
6062 <li>Line 1</li>
6163 <li>Line 2</li>
6264 <li>Line 3</li>
6365 <li>Line 4</li>
6466 </ul>
6567
6668# Filters
6769
6870TEmmet can handle some filters. A filter is added at the end of the abbreviation using a pipe \|. E.g.
6971
70-`ul>li*|t`
72+```text
73+ul>li*|t
74+```
7175
7276- c - Comment important tags (containing class or id attributes).
7377- e - Escape XML-unsafe characters: \<, \> and &.
7478- s - Single line. Expand everything to a single line of code.
7579- t - Trim line markers from wrapped lines e.g. "* ", "- " or "1."
7680- w - Wordwrap selected or lorem generated text. Default width is 80.
7781- w\<x\> - Wordwrap at column x. E.g. \|w120 will wrap lines at column 120.
7882
7983Example:
8084
8185 sAbbrev = ul>li*|t
8286
8387 sSelText =
8488 * Line 1
8589 * Line 2
8690
8791 Result =
8892 <ul>
8993 <li>Line 1</li>
9094 <li>Line 2</li>
9195 </ul>
9296
9397# Options
9498
9599Several options exist in a record "TExpandOptions" that can be passed to the expand function. Options are:
96100
97101- AddSlashToEmptyTags: Boolean; // Add a slash to empty tags e.g. \<img src="" /\>
98102- AlwaysAddNewLine: Boolean; // Always add linefeed after each tag (usually used in XML)
99103- CommentTags: Boolean; // Comment important tags (containing class or id attributes).
100104- IndentChilds: Boolean; // Indent child tags. If you set this to false - no indention will be used.
101105- SingleLine: Boolean // Expand everything to a single line of code.
102106- TabSize: Integer; // Tab size in characters. This is only used with wordwrap.
103107- TrimLineMarkers: Boolean; // Trim line markers from wrapped lines e.g. "* ", "- " or "1."
104108- Wordwrap: Boolean; // Word wrap selected or lorem generated text.
105109- WordwrapAt: Integer; // Wrap at given column. The nearest space or symbol will be used as wrap position.
106110
107111Use the overloaded version of ExpandAbbreviation to set these options.
108112
109113``` pascal
110114var
111115 rOptions: TExpandOptions;
112116begin
113117 rOptions.Wordwrap := True;
114118 rOptions.AddSlashToEmptyTags := False;
115119 sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs, rOptions);
116120```
117121
118122# Abbreviations for Markdown
119123
120124In files with .md extension, special abbreviations are supported:
121125
122-`     a           = link`\
123-`     b           = bold`\
124-`     bq          = blockquote`\
125-`     code        = inline code snippet`\
126-`     h1..h6      = heading`\
127-`     hr          = horizontal rule`\
128-`     i           = italic`\
129-`     img         = image`\
130-`     ol          = ordered list`\
131-`     pre         = code block with language based highlighting`\
132-`     strike      = strike through`\
133-`     table       = table`\
134-`     ul          = unordered list`\
135-`     @l or @l80  = create lorem generated text`
126+```text
127+ a = link
128+ b = bold
129+ bq = blockquote
130+ code = inline code snippet
131+ h1..h6 = heading
132+ hr = horizontal rule
133+ i = italic
134+ img = image
135+ ol = ordered list
136+ pre = code block with language based highlighting
137+ strike = strike through
138+ table = table
139+ ul = unordered list
140+ @l or @l80 = create lorem generated text
141+```
136142
137143# Download
138144
139145GitHub: <https://github.com/rickard67/Emmet-Pascal>
140146
141147Originally was in the "Alexey-T" account, later was moved to Rickard's account, the author of Emmet-Pascal.
142148
143149# Authors
144150
145151- Rickard Johansson - "emmet" unit
146152- Alexey Torgashin - "emmethelper" unit and FPC demos
147153
148154---
149155*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](/wiki-contact).*
150156Category: Components

Back to history