@newtonschool/tex-html-parser 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +45 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,16 +2,22 @@
2
2
 
3
3
  TypeScript parser/transformer that converts TeX into sanitized HTML.
4
4
 
5
+ ## What changed
6
+
7
+ - Package name is now scoped: `@newtonschool/tex-html-parser`.
8
+ - Publish behavior changed: `prepublishOnly` now runs only `npm run build`.
9
+ - Install and import examples have been updated to use the scoped package name.
10
+
5
11
  ## Install
6
12
 
7
13
  ```bash
8
- npm install tex-html-parser
14
+ npm install @newtonschool/tex-html-parser
9
15
  ```
10
16
 
11
17
  ## API
12
18
 
13
19
  ```ts
14
- import { renderTexStatement } from 'tex-html-parser'
20
+ import { renderTexStatement } from '@newtonschool/tex-html-parser'
15
21
 
16
22
  const html = renderTexStatement(tex)
17
23
  ```
@@ -44,7 +50,7 @@ MathJax loader security notes:
44
50
  ## React Usage (`dangerouslySetInnerHTML`)
45
51
 
46
52
  ```tsx
47
- import { renderTexStatement } from 'tex-html-parser'
53
+ import { renderTexStatement } from '@newtonschool/tex-html-parser'
48
54
 
49
55
  function Statement({ tex }: { tex: string }) {
50
56
  const html = renderTexStatement(tex)
@@ -75,6 +81,38 @@ function Statement({ tex }: { tex: string }) {
75
81
 
76
82
  Unsupported or malformed input is rendered best-effort with escaped fallback text.
77
83
 
84
+ ## Test Cases
85
+
86
+ Use these cases to validate parser behavior when adding or reviewing changes.
87
+
88
+ 1. Paragraph split:
89
+ Input: `First paragraph.\n\nSecond paragraph.`
90
+ Expected: `<p>First paragraph.</p><p>Second paragraph.</p>`
91
+
92
+ 2. Math preservation:
93
+ Input: `Inline $a+b$ and display $$x^2$$`
94
+ Expected: Math delimiters are preserved in output and escaped safely for HTML.
95
+
96
+ 3. Style command mapping:
97
+ Input: `\textbf{Bold} \textit{Italic} \underline{Underlined}`
98
+ Expected: Uses semantic tags (`<strong>`, `<em>`, `<u>`) in sanitized output.
99
+
100
+ 4. List environments:
101
+ Input: `\begin{itemize}\item One \item Two\end{itemize}`
102
+ Expected: Ordered/unordered list environments render into `<ul>/<ol>` with `<li>`.
103
+
104
+ 5. Tabular handling:
105
+ Input: `\begin{tabular}{|c|c|} A & B \\ \hline C & D \end{tabular}`
106
+ Expected: Renders a sanitized HTML table with row/cell structure preserved.
107
+
108
+ 6. Link sanitization:
109
+ Input: `\href{javascript:alert(1)}{Click}`
110
+ Expected: Unsafe protocols are stripped; only safe URLs (`http`, `https`, `mailto`, `#`, safe relative) are allowed.
111
+
112
+ 7. Malformed/unsupported TeX:
113
+ Input: broken or unsupported commands
114
+ Expected: Best-effort rendering with escaped fallback text, without unsafe HTML injection.
115
+
78
116
  ## Development
79
117
 
80
118
  ```bash
@@ -88,3 +126,7 @@ Publish checks:
88
126
  ```bash
89
127
  npm run prepublishOnly
90
128
  ```
129
+
130
+ ## Contributing
131
+
132
+ See `CONTRIBUTING.md` for setup, workflow, test expectations, and pull request guidelines.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/tex-html-parser",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript parser/transformer for TeX-to-HTML rendering.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",