{"id":17749711,"url":"https://github.com/stscoundrel/harlaw","last_synced_at":"2025-08-24T22:05:01.707Z","repository":{"id":38819300,"uuid":"296670538","full_name":"stscoundrel/harlaw","owner":"stscoundrel","description":"Transform DSL files to JSON. Formatting options available for custom output.","archived":false,"fork":false,"pushed_at":"2025-02-01T22:10:18.000Z","size":1659,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T07:38:21.703Z","etag":null,"topics":["dictionary","dsl","dsl-files","javascript","json","lingvo","nodejs","utility"],"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/stscoundrel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-18T16:13:21.000Z","updated_at":"2024-11-19T17:32:24.000Z","dependencies_parsed_at":"2024-01-06T09:24:25.509Z","dependency_job_id":"10b00ad4-6cb3-4c52-a694-d52590d1340a","html_url":"https://github.com/stscoundrel/harlaw","commit_stats":{"total_commits":235,"total_committers":4,"mean_commits":58.75,"dds":0.2595744680851064,"last_synced_commit":"7fe8b88ac3d15b74304dc1369fd53679ec32ddec"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stscoundrel%2Fharlaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stscoundrel%2Fharlaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stscoundrel%2Fharlaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stscoundrel%2Fharlaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stscoundrel","download_url":"https://codeload.github.com/stscoundrel/harlaw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620224,"owners_count":20806722,"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":["dictionary","dsl","dsl-files","javascript","json","lingvo","nodejs","utility"],"created_at":"2024-10-26T11:24:34.661Z","updated_at":"2025-04-01T16:30:33.069Z","avatar_url":"https://github.com/stscoundrel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Harlaw\n\nTransform DSL (Lingvo Dictionary File) files to JSON. Formatting options available for custom output.\n\nThere are many dictionaries available as .dsl, but very few in easily consumable formats. Harlaw formats the dsl files to json with decent search/replace/remove options.\n\nAlso available for [Rust](https://github.com/stscoundrel/harlaw-rs)\n\n### Install\n\n`npm install harlaw`\n\n### Usage\n\n\nWith default settings:\n\n```javascript\nimport { toJson } from 'harlaw';\n\nconst input = `${__dirname}/dsl/myDictionary.dsl`\nconst output = `${__dirname}/json/myResult.json`\n\nawait toJson(input, output);\n\n```\nBy default, Harlaw performs HTML transform to Lingvo markup. For example, `[b]` becomes `\u003cstrong/\u003e` and `[i]` becomes `\u003ci\u003e`.\n\nYou can also pass on settings array to remove all extra markup:\n\n```javascript\nimport { toJson, noMarkupSettings } from 'harlaw'\n\nconst input = `${__dirname}/dsl/myDictionary.dsl`\nconst output = `${__dirname}/json/myResult.json`\n\nawait toJson(input, output, noMarkupSettings)\n\n```\n\nFor custom formatting needs, you can also pass on completely custom settings object:\n\n```javascript\nimport { toJson } from 'harlaw';\n\nconst input = `${__dirname}/dsl/myDictionary.dsl`\nconst output = `${__dirname}/json/myResult.json`\n\nconst mySettings = {\n  replaces: [ // Any key \u0026 value pair you with replaced.\n    { search: '[b]', replace: '\u003cstrong\u003e' },\n    { search: '[/b]', replace: '\u003c/strong\u003e' },\n    { search: '[i]', replace: '\u003ci\u003e' },\n    { search: '[/i]', replace: '\u003c/i\u003e' },\n    { search: '[p]', replace: '\u003cspan\u003e' },\n    { search: '[/p]', replace: '\u003c/span\u003e' },\n    { search: '{-}', replace: '-' },\n    { search: '[ref]', replace: '\u003cspan class=\"reference\"\u003e' },\n    { search: '[/ref]', replace: '\u003c/span\u003e' },\n  ],\n  removes: [ // Any elements to be replaced with ''\n    '\\\\', '[/m]', '[m1]', '[m2]', '[m3]', '[m4]', '[m5]', '[m6]', '[m7]', '[m8]', '[m9]', '[m10]', '\\t', '[u]', '[/u]',\n  ],\n}\n\nawait toJson(input, output, mySettings)\n\n```\n\n\nIf you don't want physical json file, but would rather just do something with data, use `toArray`\n\n```javascript\nimport { toArray } from 'harlaw';\n\nconst input = `${__dirname}/dsl/myDictionary.dsl`\n\nconst mySettings = {\n\t//optional\n}\n\nconst dictionary = await toArray(input, mySettings)\n\nconsole.log(dictionary)\n\n```\n\n### Custom read settings.\n\nSometimes default settings for Node do not parse files correctly. For example, the file might be encoded in non-standard format. This might mean you need to pass custom settings for file reading.\n\nYou can use custom read options by passing readOptions object to settings. It will be passed to [createReadStream](https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options).\n\n\n```javascript\nimport { toJson, toArray } from 'harlaw';\n\nconst input = `${__dirname}/dsl/myDictionary.dsl`\nconst output = `${__dirname}/json/myResult.json`\n\nconst mySettings = {\n  replaces: { /* optional */ },\n  removes: { /* optional */ },\n  readSettings: {\n    encoding: 'utf16le',\n    // any other valid option.\n  },\n}\n\n// Works with JSON.\nawait toJson(input, output, mySettings)\n\n// ...And with array.\nconst dictionary = await toArray(input, mySettings)\n\nconsole.log(dictionary)\n\n```\n\n\n#### What's in the name?\n\nIn G.R.R Martins \"A Song Of Ice And Fire\", there is a character named Rodrik Harlaw. He is mockingly called \"The Reader\". That is what my Harlaw does too; reads things no one else cares about.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstscoundrel%2Fharlaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstscoundrel%2Fharlaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstscoundrel%2Fharlaw/lists"}