{"id":18292138,"url":"https://github.com/emmetio/py-emmet","last_synced_at":"2026-03-05T12:02:13.352Z","repository":{"id":53143697,"uuid":"220092553","full_name":"emmetio/py-emmet","owner":"emmetio","description":"Emmet abbreviation parser and expander, implemented in Python","archived":false,"fork":false,"pushed_at":"2024-03-13T14:48:20.000Z","size":193,"stargazers_count":41,"open_issues_count":1,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-09T06:22:09.692Z","etag":null,"topics":["css","emmet","front-end","html"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emmetio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"emmetio","patreon":null,"open_collective":"emmet","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-11-06T21:21:29.000Z","updated_at":"2024-11-22T08:36:37.000Z","dependencies_parsed_at":"2024-03-30T10:47:33.599Z","dependency_job_id":null,"html_url":"https://github.com/emmetio/py-emmet","commit_stats":{"total_commits":122,"total_committers":2,"mean_commits":61.0,"dds":0.008196721311475419,"last_synced_commit":"e3492636aaa66429a03983780ba3cebafac1444b"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/emmetio/py-emmet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmetio%2Fpy-emmet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmetio%2Fpy-emmet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmetio%2Fpy-emmet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmetio%2Fpy-emmet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emmetio","download_url":"https://codeload.github.com/emmetio/py-emmet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmetio%2Fpy-emmet/sbom","scorecard":{"id":376022,"data":{"date":"2025-08-11","repo":{"name":"github.com/emmetio/py-emmet","commit":"e3492636aaa66429a03983780ba3cebafac1444b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pythonpublish.yml:1","Warn: no topLevel permission defined: .github/workflows/unittest.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/pythonpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/pythonpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/pythonpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/pythonpublish.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pythonpublish.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/pythonpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/unittest.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/unittest.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/unittest.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/emmetio/py-emmet/unittest.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/pythonpublish.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/pythonpublish.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/unittest.yml:26","Warn: pipCommand not pinned by hash: .github/workflows/unittest.yml:27","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T14:15:55.845Z","repository_id":53143697,"created_at":"2025-08-18T14:15:55.845Z","updated_at":"2025-08-18T14:15:55.845Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30123729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T11:11:57.947Z","status":"ssl_error","status_checked_at":"2026-03-05T11:11:29.001Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","emmet","front-end","html"],"created_at":"2024-11-05T14:16:51.341Z","updated_at":"2026-03-05T12:02:13.336Z","avatar_url":"https://github.com/emmetio.png","language":"Python","funding_links":["https://github.com/sponsors/emmetio","https://opencollective.com/emmet"],"categories":[],"sub_categories":[],"readme":"# Emmet — the essential toolkit for web-developers\n\n\u003e This is the official Python port of original Emmet code base written in JavaScript: https://github.com/emmetio/emmet\n\nEmmet is a web-developer’s toolkit for boosting HTML \u0026 CSS code writing.\n\nWith Emmet, you can type expressions (_abbreviations_) similar to CSS selectors and convert them into code fragment with a single keystroke. For example, this abbreviation:\n\n```\nul#nav\u003eli.item$*4\u003ea{Item $}\n```\n\n...can be expanded into:\n\n```html\n\u003cul id=\"nav\"\u003e\n    \u003cli class=\"item1\"\u003e\u003ca href=\"\"\u003eItem 1\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\"item2\"\u003e\u003ca href=\"\"\u003eItem 2\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\"item3\"\u003e\u003ca href=\"\"\u003eItem 3\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\"item4\"\u003e\u003ca href=\"\"\u003eItem 4\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n```\n\n## Features\n\n* **Familiar syntax**: as a web-developer, you already know how to use Emmet. Abbreviation syntax is similar to CSS Selectors with shortcuts for id, class, custom attributes, element nesting and so on.\n* **Dynamic snippets**: unlike default editor snippets, Emmet abbreviations are dynamic and parsed as-you-type. No need to predefine them for each project, just type `MyComponent\u003ecustom-element` to convert any word into a tag.\n* **CSS properties shortcuts**: Emmet provides special syntax for CSS properties with embedded values. For example, `bd1-s#f.5` will be exampled to `border: 1px solid rgba(255, 255, 255, 0.5)`.\n* **Available for most popular syntaxes**: use single abbreviation to produce code for most popular syntaxes like HAML, Pug, JSX, SCSS, SASS etc.\n\n[Read more about Emmet features](https://docs.emmet.io)\n\n### Installation\n\nYou can install Emmet as a regular pip module:\n\n```bash\npip install py-emmet\n```\n\n## Usage\n\nTo expand abbreviation, pass it to `expand` function of `emmet` module:\n\n```py\nimport emmet\n\nprint(emmet.expand('p\u003ea')) # \u003cp\u003e\u003ca href=\"\"\u003e\u003c/a\u003e\u003c/p\u003e\n```\n\nBy default, Emmet expands *markup* abbreviation, e.g. abbreviation used for producing nested elements with attributes (like HTML, XML, HAML etc.). If you want to expand *stylesheet* abbreviation, you should pass it as a `type` property of second argument:\n\n```py\nimport emmet\n\nprint(emmet.expand('p10', { 'type': 'stylesheet' })) # padding: 10px\n```\n\nA stylesheet abbreviation has slightly different syntax compared to markup one: it doesn’t support nesting and attributes but allows embedded values in element name.\n\nAlternatively, Emmet supports *syntaxes* with predefined snippets and options:\n\n```py\nimport emmet\n\nprint(emmet.expand('p10', { 'syntax': 'css' })) # padding: 10px;\nprint(emmet.expand('p10', { 'syntax': 'stylus' })) # padding 10px\n```\n\nPredefined syntaxes already have `type` attribute which describes whether given abbreviation is markup or stylesheet, but if you want to use it with your custom syntax name, you should provide `type` config option as well (default is `markup`):\n\n```py\nimport emmet\n\nprint(emmet.expand('p10', {\n    'syntax': 'my-custom-syntax',\n    'type': 'stylesheet',\n    'options': {\n        'stylesheet.between': '__',\n        'stylesheet.after': '',\n    }\n})) # padding__10px\n```\n\nYou can pass `options` property as well to shape-up final output or enable/disable various features. See [`emmet/config.py`](emmet/config.py) for more info and available options.\n\n## Extracting abbreviations from text\n\nA common workflow with Emmet is to type abbreviation somewhere in source code and then expand it with editor action. To support such workflow, abbreviations must be properly _extracted_ from source code:\n\n```py\nimport emmet\n\nsource = 'Hello world ul.tabs\u003eli'\ndata = emmet.extract(source, 22) # { abbreviation: 'ul.tabs\u003eli' }\n\nprint(emmet.expand(data.abbreviation)) # \u003cul class=\"tabs\"\u003e\u003cli\u003e\u003c/li\u003e\u003c/ul\u003e\n```\n\nThe `extract` function accepts source code (most likely, current line) and character location in source from which abbreviation search should be started. The abbreviation is searched in backward direction: the location pointer is moved backward until it finds abbreviation bound. Returned result is an object with `abbreviation` property and `start` and `end` properties which describe location of extracted abbreviation in given source.\n\nMost current editors automatically insert closing quote or bracket for `(`, `[` and `{` characters so when user types abbreviation that uses attributes or text, it will end with the following state (`|` is caret location):\n\n```\nul\u003eli[title=\"Foo|\"]\n```\n\nE.g. caret location is not at the end of abbreviation and must be moved a few characters ahead. The `extract` function is able to handle such cases with `lookAhead` option (enabled by default). This this option enabled, `extract` method automatically detects auto-inserted characters and adjusts location, which will be available as `end` property of the returned result:\n\n```py\nimport emmet\n\nsource = 'a div[title] b'\nloc = 11 # right after \"title\" word\n\n# `lookAhead` is enabled by default\nprint(emmet.extract(source, loc)) # { abbreviation: 'div[title]', start: 2, end: 12 }\nprint(emmet.extract(source, loc, { 'lookAhead': false })) # { abbreviation: 'title', start: 6, end: 11 }\n```\n\nBy default, `extract` tries to detect _markup_ abbreviations (see above). _stylesheet_ abbreviations has slightly different syntax so in order to extract abbreviations for stylesheet syntaxes like CSS, you should pass `type: 'stylesheet'` option:\n\n```py\nimport emmet\n\nsource = 'a{b}'\nloc = 3 # right after \"b\"\n\nprint(emmet.extract(source, loc)); # { abbreviation: 'a{b}', start: 0, end: 4 }\n\n\n# Stylesheet abbreviations does not have `{text}` syntax\nprint(emmet.extract(source, loc, { 'type': 'stylesheet' })); # { abbreviation: 'b', start: 2, end: 3 }\n```\n\n### Extract abbreviation with custom prefix\n\nLots of developers uses React (or similar) library for writing UI code which mixes JS and XML (JSX) in the same source code. Since _any_ Latin word can be used as Emmet abbreviation, writing JSX code with Emmet becomes pain since it will interfere with native editor snippets and distract user with false positive abbreviation matches for variable names, methods etc.:\n\n```js\nvar div // `div` is a valid abbreviation, Emmet may transform it to `\u003cdiv\u003e\u003c/div\u003e`\n```\n\nA possible solution for this problem it to use _prefix_ for abbreviation: abbreviation can be successfully extracted only if its preceded with given prefix.\n\n```py\nimport emmet\n\nsource1 = '() =\u003e div'\nsource2 = '() =\u003e \u003cdiv'\n\nemmet.extract(source1, len(source1)) # Finds `div` abbreviation\nemmet.extract(source2, len(source2)) # Finds `div` abbreviation too\n\nemmet.extract(source1, len(source1), { 'prefix': '\u003c' }) # No match, `div` abbreviation is not preceded with `\u003c` prefix\nemmet.extract(source2, len(source2), { 'prefix': '\u003c' }) # Finds `div` since it preceded with `\u003c` prefix\n```\n\nWith `prefix` option, you can customize your experience with Emmet in any common syntax (HTML, CSS and so on) if user is distracted too much with Emmet completions for any typed word. A `prefix` may contain multiple character but the last one *must* be a character which is not part of Emmet abbreviation. Good candidates are `\u003c`, `\u0026`, `→` (emoji or Unicode symbol) and so on.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmetio%2Fpy-emmet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femmetio%2Fpy-emmet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmetio%2Fpy-emmet/lists"}