{"id":18973609,"url":"https://github.com/anishmprasad/mathex","last_synced_at":"2026-04-07T23:30:17.783Z","repository":{"id":98776681,"uuid":"142573291","full_name":"anishmprasad/MathEx","owner":"anishmprasad","description":"A Mathematical Expression Composer for CKEditor","archived":false,"fork":false,"pushed_at":"2021-01-16T17:27:57.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T08:42:07.090Z","etag":null,"topics":["ckeditor","ckeditor-plugin","ckeditor4","mathex"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anishmprasad.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":"2018-07-27T12:16:37.000Z","updated_at":"2021-01-16T17:27:59.000Z","dependencies_parsed_at":"2023-05-25T07:30:37.924Z","dependency_job_id":null,"html_url":"https://github.com/anishmprasad/MathEx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishmprasad%2FMathEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishmprasad%2FMathEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishmprasad%2FMathEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anishmprasad%2FMathEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anishmprasad","download_url":"https://codeload.github.com/anishmprasad/MathEx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239970677,"owners_count":19727014,"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":["ckeditor","ckeditor-plugin","ckeditor4","mathex"],"created_at":"2024-11-08T15:12:38.008Z","updated_at":"2026-04-07T23:30:17.736Z","avatar_url":"https://github.com/anishmprasad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MathEx\n\nA CKEditor Plugin for MathML and Latex Mathemathical Expressions\n\nEditor accepted string format from input\n\nDownload mathex plugin from [CKEditor Addons](https://ckeditor.com/cke4/addon/MathEx)\n\ndefault class was math if you change this you need to configure through ``` mathexClass ```\n\n```html\n\n\u003cspan class=\"math\"\u003e\\({ MathML or Tex Mathemathical expressions }\\)\u003c/span\u003e\n\n```\n\nEncoder Helper\n\n``` let str = \"\u003cspan class=\"math\"\u003e\u003cmath\u003e\u003cmrow\u003e\u003cmsup\u003e\u003cmfenced\u003e\u003cmrow\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003c/mrow\u003e\u003c/mfenced\u003e\u003cmn\u003e2\u003c/mn\u003e\u003c/msup\u003e\u003c/mrow\u003e\u003c/math\u003e\u003c/span\u003e\" ```\n\n``` this helper function added escape character before \u003cmath /\u003e and html Decode for editor readable format  ```\n\n``` decoder(str) // \u003cspan class=\"math\"\u003e\\( \u0026gt;math\u0026lt;\u0026gt;mrow\u0026lt;\u0026gt;msup\u0026lt;\u0026gt;mfenced\u0026lt;\u0026gt;mrow\u0026lt;\u0026gt;mi\u0026lt;a\u0026gt;/mi\u0026lt;\u0026gt;mo\u0026lt;+\u0026gt;/mo\u0026lt;\u0026gt;mi\u0026lt;b\u0026gt;/mi\u0026lt;\u0026gt;/mrow\u0026lt;\u0026gt;/mfenced\u0026lt;\u0026gt;mn\u003e2\u0026gt/mn\u0026lt;\u0026gt;/msup\u0026lt;\u0026gt;/mrow\u0026lt;\u0026gt;/math\u003e \\) \u003c/span\u003e ```\n\n```javascript\n\n    function encoder(text){\n        if (text){\n            var myregexp = /\u003cspan[^\u003e]+?class=\"math\".*?\u003e([\\s\\S]*?)\u003c\\/span\u003e/g;\n            return text.replace(myregexp, function replacer(match) {\n                return match.replace(/\u003cmath\u003e([\\s\\S]*?)\u003c\\/math\u003e/g , function replacerData(match) {\n                    let tempString = match.replace(/\u003cmath\u003e/g, \"\\\\(\u003cmath\u003e\");\n                    return this.htmlEncode(tempString.replace(/\u003c\\/math\u003e/g, \"\u003c/math\u003e\\\\)\"))\n                }.bind(this))\n            }.bind(this))\n        }\n    }\n\n```\n\nDecoder Helper\n\n``` let str = \"\u003cspan class=\"math\"\u003e\\({ MathML or Tex Mathemathical expressions }\\)\u003c/span\u003e\" ```\n\n``` this helper function removed escape character before \u003cmath /\u003e ```\n\n``` decoder(str) // \u003cspan class=\"math\"\u003e MathML or Tex Mathemathical expressions \u003c/span\u003e ```\n\n```javascript\n\n    function decoder(str) {\n        let tempString = str.replace(/\\\\\\(\u003cmath\u003e/g, \"\u003cmath\u003e\");\n        return tempString.replace(/\u003c\\/math\u003e\\\\\\)/g, \"\u003c/math\u003e\");\n    }\n\n```\n\nhtmlEncode Helper\n\n``` htmlEncode( 'A \u003e B \u0026 C \u003c D' )  // 'A \u0026gt; B \u0026amp; C \u0026lt; D' ```\n\n```javascript\n\n    var ampRegex = /\u0026/g,\n    gtRegex = /\u003e/g,\n    ltRegex = /\u003c/g,\n    quoteRegex = /\"/g,\n    tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789',\n\n/**\n     * Replaces special HTML characters in a string with their relative HTML\n     * entity values.\n     *\n     *\t\tconsole.log( htmlEncode( 'A \u003e B \u0026 C \u003c D' ) ); // 'A \u0026gt; B \u0026amp; C \u0026lt; D'\n     *\n     * @param {String} text The string to be encoded.\n     * @returns {String} The encoded string.\n     */\n    htmlEncode = text =\u003e {\n        // Backwards compatibility - accept also non-string values (casting is done below).\n        // Since 4.4.8 we return empty string for null and undefined because these values make no sense.\n        if (text === undefined || text === null) {\n            return '';\n        }\n\n        return String(text).replace(ampRegex, '\u0026amp;').replace(gtRegex, '\u0026gt;').replace(ltRegex, '\u0026lt;');\n    }\n\n\n```\n\nhtmlDecode Helper\n\n``` htmlDecode( '\u0026lt;a \u0026amp; b \u0026gt;' ) // '\u003ca \u0026 b \u003e' ```\n\n```javascript\n\n    var ampRegex = /\u0026/g,\n    gtRegex = /\u003e/g,\n    ltRegex = /\u003c/g,\n    quoteRegex = /\"/g,\n    tokenCharset = 'abcdefghijklmnopqrstuvwxyz0123456789',\n\n    allEscRegex = /\u0026(lt|gt|amp|quot|nbsp|shy|#\\d{1,5});/g,\n    namedEntities = {\n        lt: '\u003c',\n        gt: '\u003e',\n        amp: '\u0026',\n        quot: '\"',\n        nbsp: '\\u00a0',\n        shy: '\\u00ad'\n    }\n\n    allEscDecode(match, code) {\n        if (code[0] == '#') {\n            return String.fromCharCode(parseInt(code.slice(1), 10));\n        } else {\n            return namedEntities[code];\n        }\n    }\n\n    /**\n      * Decodes HTML entities that browsers tend to encode when used in text nodes.\n      *\n      *\t\tconsole.log( htmlDecode( '\u0026lt;a \u0026amp; b \u0026gt;' ) ); // '\u003ca \u0026 b \u003e'\n      *\n      * Read more about chosen entities in the [research].\n      *\n      * @param {String} The string to be decoded.\n      * @returns {String} The decoded string.\n      */\n    htmlDecode = text =\u003e {\n        // See:\n        // * http://jsperf.com/wth-is-going-on-with-jsperf JSPerf has some serious problems, but you can observe\n        // that combined regexp tends to be quicker (except on V8). It will also not be prone to fail on '\u0026amp;lt;'\n        return text.replace(allEscRegex, this.allEscDecode);\n    }\n\n```\n### Licence\nGPL 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanishmprasad%2Fmathex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanishmprasad%2Fmathex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanishmprasad%2Fmathex/lists"}