{"id":28471960,"url":"https://github.com/designliquido/lmht-js","last_synced_at":"2026-02-27T03:06:40.106Z","repository":{"id":59849663,"uuid":"539168324","full_name":"DesignLiquido/lmht-js","owner":"DesignLiquido","description":"Biblioteca de transformação de documentos LMHT para HTML para JavaScript.","archived":false,"fork":false,"pushed_at":"2024-07-05T00:15:23.000Z","size":639,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"principal","last_synced_at":"2025-06-07T11:09:25.682Z","etag":null,"topics":["hacktoberfest","lmht","portugues","portuguese","xml","xslt"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/DesignLiquido.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"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}},"created_at":"2022-09-20T19:54:42.000Z","updated_at":"2024-07-05T00:15:27.000Z","dependencies_parsed_at":"2024-01-26T01:27:58.637Z","dependency_job_id":"2b91e551-df82-4d0a-98ab-4010fc90da31","html_url":"https://github.com/DesignLiquido/lmht-js","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.41463414634146345","last_synced_commit":"4260f8006a289d38f5447deac35d92e3a7d9af98"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/DesignLiquido/lmht-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DesignLiquido%2Flmht-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DesignLiquido%2Flmht-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DesignLiquido%2Flmht-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DesignLiquido%2Flmht-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DesignLiquido","download_url":"https://codeload.github.com/DesignLiquido/lmht-js/tar.gz/refs/heads/principal","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DesignLiquido%2Flmht-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263046061,"owners_count":23405126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["hacktoberfest","lmht","portugues","portuguese","xml","xslt"],"created_at":"2025-06-07T11:09:30.777Z","updated_at":"2026-02-27T03:06:40.078Z","avatar_url":"https://github.com/DesignLiquido.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lmht-js\n\nBiblioteca de transformação de documentos [LMHT](https://github.com/DesignLiquido/LMHT) para HTML, para JavaScript e TypeScript.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/DesignLiquido/lmht-js/issues\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/issues/Designliquido/lmht-js\" /\u003e\n    \u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/Designliquido/lmht-js\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/forks/Designliquido/lmht-js\" /\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@designliquido/lmht-js\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/@designliquido/lmht-js\" /\u003e\n    \u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dw/@designliquido/lmht-js\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/DesignLiquido/lmht-js\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./recursos/imagens/badge-statements.svg\" /\u003e\n    \u003cimg src=\"./recursos/imagens/badge-lines.svg\" /\u003e\n    \u003cimg src=\"./recursos/imagens/badge-functions.svg\" /\u003e\n    \u003cimg src=\"./recursos/imagens/badge-branches.svg\" /\u003e\n\u003c/p\u003e\n\n## Formas de uso\n\n### Versão 0.5.0 ou superiores\n\n```js\nimport { ConversorLmht } from \"@designliquido/lmht-js\";\n\nconst conversorLmht = new ConversorLmht();\n// Ou\nconst resultado = await conversorLmht.converterPorArquivo(\"meu-arquivo.lmht\");\nconsole.log(resultado);\n\n// Ou\nconversorLmht.converterPorArquivo(\"meu-arquivo.lmht\").then(resultado =\u003e {\n    console.log(resultado);\n});\n```\n\n```js\nimport { ConversorLmht } from \"@designliquido/lmht-js\";\n\nconst conversorLmht = new ConversorLmht();\n// Ou\nconst resultado = await conversorLmht.converterPorTexto(\"\u003clmht\u003e\u003ccabeca\u003e\u003ctitulo\u003eTeste\u003c/titulo\u003e\u003c/cabeca\u003e\u003ccorpo\u003eTeste\u003c/corpo\u003e\u003c/lmht\u003e\");\nconsole.log(resultado); // Resultado: \u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTeste\u003c/title\u003e\u003c/head\u003e\u003cbody\u003eTeste\u003c/body\u003e\u003c/html\u003e\n\n// Ou\nconversorLmht.converterPorTexto(\"\u003clmht\u003e\u003ccabeca\u003e\u003ctitulo\u003eTeste\u003c/titulo\u003e\u003c/cabeca\u003e\u003ccorpo\u003eTeste\u003c/corpo\u003e\u003c/lmht\u003e\").then(resultado =\u003e {\n    console.log(resultado); // Resultado: \u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTeste\u003c/title\u003e\u003c/head\u003e\u003cbody\u003eTeste\u003c/body\u003e\u003c/html\u003e\n});\n```\n\n```js\nimport { ConversorHtml } from \"@designliquido/lmht-js\";\n\nconst conversorHtml = new ConversorHtml();\n// Ou\nconst resultado = await conversorHtml.converterPorArquivo(\"meu-arquivo.html\");\nconsole.log(resultado);\n\n// Ou\nconversorHtml.converterPorArquivo(\"meu-arquivo.html\").then(resultado =\u003e {\n    console.log(resultado);\n});\n```\n\n```js\nimport { ConversorHtml } from \"@designliquido/lmht-js\";\n\nconst conversorHtml = new ConversorHtml();\n// Ou\nconst resultado = await conversorHtml.converterPorTexto(\"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTeste\u003c/title\u003e\u003c/head\u003e\u003cbody\u003eTeste\u003c/body\u003e\u003c/html\u003e\");\nconsole.log(resultado); // Resultado: \u003clmht\u003e\u003ccabeca\u003e\u003ctitulo\u003eTeste\u003c/titulo\u003e\u003c/cabeca\u003e\u003ccorpo\u003eTeste\u003c/corpo\u003e\u003c/lmht\u003e\n\n// Ou\nconversorHtml.converterPorTexto(\"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTeste\u003c/title\u003e\u003c/head\u003e\u003cbody\u003eTeste\u003c/body\u003e\u003c/html\u003e\").then(resultado =\u003e {\n    console.log(resultado); // Resultado: \u003clmht\u003e\u003ccabeca\u003e\u003ctitulo\u003eTeste\u003c/titulo\u003e\u003c/cabeca\u003e\u003ccorpo\u003eTeste\u003c/corpo\u003e\u003c/lmht\u003e\n});\n```\n\n### Versão 0.3.0 até versão 0.4.9\n\nOs métodos de conversão são síncronos:\n\n```js\nimport { ConversorLmht } from \"@designliquido/lmht-js\";\n\nconst conversorLmht = new ConversorLmht();\nconst resultado = conversorLmht.converterPorArquivo(\"meu-arquivo.lmht\");\nconsole.log(resultado);\n```\n\n```js\nimport { ConversorLmht } from \"@designliquido/lmht-js\";\n\nconst conversorLmht = new ConversorLmht();\nconst resultado = conversorLmht.converterPorTexto(\"\u003clmht\u003e\u003ccabeca\u003e\u003ctitulo\u003eTeste\u003c/titulo\u003e\u003c/cabeca\u003e\u003ccorpo\u003eTeste\u003c/corpo\u003e\u003c/lmht\u003e\");\nconsole.log(resultado); // Resultado: \u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTeste\u003c/title\u003e\u003c/head\u003e\u003cbody\u003eTeste\u003c/body\u003e\u003c/html\u003e\n```\n\n```js\nimport { ConversorHtml } from \"@designliquido/lmht-js\";\n\nconst conversorHtml = new ConversorHtml();\nconst resultado = conversorHtml.converterPorArquivo(\"meu-arquivo.html\");\nconsole.log(resultado);\n```\n\n```js\nimport { ConversorHtml } from \"@designliquido/lmht-js\";\n\nconst conversorHtml = new ConversorHtml();\nconst resultado = conversorHtml.converterPorTexto(\"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTeste\u003c/title\u003e\u003c/head\u003e\u003cbody\u003eTeste\u003c/body\u003e\u003c/html\u003e\");\nconsole.log(resultado); // Resultado: \u003clmht\u003e\u003ccabeca\u003e\u003ctitulo\u003eTeste\u003c/titulo\u003e\u003c/cabeca\u003e\u003ccorpo\u003eTeste\u003c/corpo\u003e\u003c/lmht\u003e\n```\n\n### Até a versão 0.2.0\n\nOs métodos de conversão são assíncronos.\n\n```js\nimport { ConversorLmht } from \"@designliquido/lmht-js\";\n\nconst conversorLmht = new ConversorLmht();\nconversorLmht.converterPorArquivo(\"meu-arquivo.lmht\").then(resultado =\u003e {\n    console.log(resultado);\n});\n```\n\n```js\nimport { ConversorHtml } from \"@designliquido/lmht-js\";\n\nconst conversorHtml = new ConversorHtml();\nconversorHtml.converterPorArquivo(\"meu-arquivo.lmht\").then(resultado =\u003e {\n    console.log(resultado);\n});\n```\n\n## Conformidade com especificação \n\n`lmht-js` segue a especificação mais recente de [LMHT](https://github.com/DesignLiquido/LMHT). O projeto da especificação é referenciado aqui como um [submódulo git](https://git-scm.com/docs/git-submodule/pt_BR). Para sincronizar a especificação, use o comando:\n\n```sh\ngit submodule update --init --recursive --remote\n```\n\n## Versões 0.3.0 até 0.4.9, usando `xslt-processor`, e mudanças na versão 0.5.0\n\nNa versão 0.3.0, tomamos a decisão de mudar para a biblioteca [`xslt-processor`](https://github.com/DesignLiquido/xslt-processor), 100% em código aberto, licença MIT, e mantida pela Design Líquido. Não apenas os _bugs_ que tínhamos com a biblioteca anterior, `saxon-js`, são totalmente evitados como também a implementação de `xslt-processor` privilegia o projeto de LMHT.\n\nIsso fez com que os métodos se tornassem síncronos. Depois da versão 3.0.0 de `xslt-processor`, em que o comando `\u003cxsl:include\u003e` foi implementado, o processamento de transformações XSLT passou a ser novamente assíncrono. O comando `\u003cxsl:include\u003e` exige um acesso a um sistema de arquivos ou um recurso na internet, o que pede para que todo o processo seja assíncrono. Para esta biblioteca, os comandos de conversão voltam a ser assíncronos na versão 0.5.0.\n\n## Versão 0.2.0 e `saxon-js`\n\nAté a versão 0.2.0, usávamos a biblioteca [`saxon-js`](https://www.npmjs.com/package/saxon-js). Essa biblioteca tornou-se um problema por alguns motivos:\n\n- Documentação incompleta, em inglês e de baixa qualidade: https://www.saxonica.com/saxon-js/documentation2/index.html;\n- [Apesar de ter uma licença gratuita](https://www.saxonica.com/saxon-js/documentation2/index.html#!conditions/public-license), os fontes não são abertos;\n- Escrita em JavaScript puro e tipagem fraca, além de ter uma parte compilada em C;\n- Não funciona se usada em uma extensão do Visual Studio Code, que em teoria é Node.js, mas algo acontece ao importarmos a dependência e um erro estranho aparece.\n\nMantemos o suporte a versões anteriores por questões de retrocompatibilidade. \n\n### Especificação e arquivos `.sef.json`\n\n`saxon-js` pede por arquivos `.sef.json`, que podem ser gerados pelos comandos abaixo:\n\nPowerShell:\n```powershell\nxslt3 -t \"-xsl:especificacao/lmht.xslt\" \"-export:lmht.sef.json\" -nogo -relocate\nxslt3 -t \"-xsl:especificacao/lmht-reverso-xml10.xslt\" \"-export:lmht-reverso-xml10.sef.json\" -nogo -relocate\n```\n\nbash, zsh:\n```sh\nxslt3 -t -xsl:especificacao/lmht.xslt -export:lmht.sef.json -nogo -relocate\nxslt3 -t -xsl:especificacao/lmht-reverso.xslt -export:lmht-reverso.sef.json -nogo -relocate\n```\n\nO arquivo XSLT da especificação ou da especificação reversa também podem ser usados, mas isso causa um atraso na carga de pelo menos 2 segundos por arquivo, que é o tempo que leva para compilar a especificação de XSLT para `.sef.json`. Para entender como isso funciona, verifique o fonte [`objeto-especificacao.ts`](https://github.com/DesignLiquido/lmht-js/blob/4260f8006a289d38f5447deac35d92e3a7d9af98/objeto-especificacao.ts). \n\nAssim sendo, os arquivos `.sef.json` correspondentes ao _commit_ apontado pelo submódulo são versionados neste diretório raiz, e distribuídos juntamente com o pacote NPM.\n\n### Compatibilidade com XML\n\nSaxonJS não trabalha com XML 1.1, e por isso a especificação com XML 1.0 é usada aqui.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesignliquido%2Flmht-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesignliquido%2Flmht-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesignliquido%2Flmht-js/lists"}