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