Sign in Join
Wiki copytemporary

Emmet-Pascal: what changed

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

Title: Emmet-Pascal

OldNewLine
1+# About
2+
3+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]].
4+
5+Cheat sheets:
6+
7+- Emmet-Pascal - <https://www.rj-texted.se/Help/Emmetcheatsheet.html>
8+- Standard Emmet - <https://docs.emmet.io/cheat-sheet/>
9+
10+Engine gives special abbreviations for different file types:
11+
12+- HTML: about 200 items
13+- XSL: about 40 items
14+- SVG: about 50 items
15+- CSS: about 650 items
16+- Markdown: about 20 items
17+
18+# Usage
19+
20+First you need to create an Emmet object.
21+
22+``` pascal
23+FEmmet := TEmmet.Create(snippetsPath, loremPath);
24+```
25+
26+- snippetsPath: The file path to Snippets.ini e.g. "c:\foo\Snipptes.ini"
27+- loremPath: The file path to Lorem.txt e.g. "c:\foo\Lorem.txt"
28+
29+To expand an abbreviation, use
30+
31+``` pascal
32+sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs);
33+```
34+
35+Parameters:
36+
37+- sAbbr: Abbreviation e.g. "ul\>li*5"
38+- sSyntax: Code language in lowercase e.g. "html". Available values are: html, css, xsl, svg, xml, jsx, less, sass, scss.
39+- sSelText: Text is used to wrap with abbreviation
40+- sSection: Gets the section used in snippets.ini e.g. "html"
41+- bMultiCursorTabs: Gets True if cursor positions in expanded string should be handled as multi cursor positions
42+
43+Result: sExpanded is the resulting expanded code. It may contain cursor \| positions or selected tab \${1:charset} positions.
44+
45+# Wrap with abbreviation
46+
47+To use this feature, use parameter sSelText. E.g. if you call ExpandAbbreviation() with:
48+
49+- sAbbrev: ul\>li*
50+- sSelText:
51+
52+`Line 1`\
53+`Line 2`\
54+`Line 3`\
55+`Line 4`
56+
57+You get the result
58+
59+ <ul>
60+ <li>Line 1</li>
61+ <li>Line 2</li>
62+ <li>Line 3</li>
63+ <li>Line 4</li>
64+ </ul>
65+
66+# Filters
67+
68+TEmmet can handle some filters. A filter is added at the end of the abbreviation using a pipe \|. E.g.
69+
70+`ul>li*|t`
71+
72+- c - Comment important tags (containing class or id attributes).
73+- e - Escape XML-unsafe characters: \<, \> and &.
74+- s - Single line. Expand everything to a single line of code.
75+- t - Trim line markers from wrapped lines e.g. "* ", "- " or "1."
76+- w - Wordwrap selected or lorem generated text. Default width is 80.
77+- w\<x\> - Wordwrap at column x. E.g. \|w120 will wrap lines at column 120.
78+
79+Example:
80+
81+ sAbbrev = ul>li*|t
82+
83+ sSelText =
84+ * Line 1
85+ * Line 2
86+
87+ Result =
88+ <ul>
89+ <li>Line 1</li>
90+ <li>Line 2</li>
91+ </ul>
92+
93+# Options
94+
95+Several options exist in a record "TExpandOptions" that can be passed to the expand function. Options are:
96+
97+- AddSlashToEmptyTags: Boolean; // Add a slash to empty tags e.g. \<img src="" /\>
98+- AlwaysAddNewLine: Boolean; // Always add linefeed after each tag (usually used in XML)
99+- CommentTags: Boolean; // Comment important tags (containing class or id attributes).
100+- IndentChilds: Boolean; // Indent child tags. If you set this to false - no indention will be used.
101+- SingleLine: Boolean // Expand everything to a single line of code.
102+- TabSize: Integer; // Tab size in characters. This is only used with wordwrap.
103+- TrimLineMarkers: Boolean; // Trim line markers from wrapped lines e.g. "* ", "- " or "1."
104+- Wordwrap: Boolean; // Word wrap selected or lorem generated text.
105+- WordwrapAt: Integer; // Wrap at given column. The nearest space or symbol will be used as wrap position.
106+
107+Use the overloaded version of ExpandAbbreviation to set these options.
108+
109+``` pascal
110+var
111+ rOptions: TExpandOptions;
112+begin
113+ rOptions.Wordwrap := True;
114+ rOptions.AddSlashToEmptyTags := False;
115+ sExpanded := FEmmet.ExpandAbbreviation(sAbbr, sSyntax, sSelText, sSection, bMultiCursorTabs, rOptions);
116+```
117+
118+# Abbreviations for Markdown
119+
120+In files with .md extension, special abbreviations are supported:
121+
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`
136+
137+# Download
138+
139+GitHub: <https://github.com/rickard67/Emmet-Pascal>
140+
141+Originally was in the "Alexey-T" account, later was moved to Rickard's account, the author of Emmet-Pascal.
142+
143+# Authors
144+
145+- Rickard Johansson - "emmet" unit
146+- Alexey Torgashin - "emmethelper" unit and FPC demos
147+
148+---
149+*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).*
150+Category: Components

Back to history