@siladev/qalam 0.4.0 → 0.4.2

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.
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # @siladev/qalam
2
+
3
+ Islamic content editor with Quran verse references, hadith, poetry, and inline quotes. Built on Tiptap/React, RTL-first.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @siladev/qalam
9
+ ```
10
+
11
+ ## Editor
12
+
13
+ ```tsx
14
+ import { QalamEditor } from "@siladev/qalam";
15
+ import "@siladev/qalam/styles.css";
16
+
17
+ // Load quran data first
18
+ import { loadQuranData } from "@siladev/qalam";
19
+ const data = await fetch("/quran-data.json").then(r => r.json());
20
+ loadQuranData(data);
21
+
22
+ function App() {
23
+ const [doc, setDoc] = useState(initialContent);
24
+ return (
25
+ <QalamEditor
26
+ content={doc} // initial content (remount with key to replace)
27
+ onChange={setDoc}
28
+ repeat={true} // enable repeat controls
29
+ dir="rtl"
30
+ />
31
+ );
32
+ }
33
+ ```
34
+
35
+ ## Renderer
36
+
37
+ ```tsx
38
+ import { QalamRenderer, resolveAST } from "@siladev/qalam";
39
+
40
+ const resolved = resolveAST(doc); // needs quran data loaded
41
+ <QalamRenderer doc={resolved} dir="rtl" />
42
+ ```
43
+
44
+ ## Markdown
45
+
46
+ Bidirectional JSON <-> Markdown conversion.
47
+
48
+ ```typescript
49
+ import { docToMarkdown, markdownToDoc, resolvedDocToMarkdown, markdownToResolvedDoc } from "@siladev/qalam";
50
+
51
+ // Source markdown (for editing, LLM pipelines)
52
+ const md = docToMarkdown(doc);
53
+ const doc = markdownToDoc(md);
54
+
55
+ // Resolved markdown (for rendering without quran data)
56
+ const compiledMd = resolvedDocToMarkdown(resolvedDoc);
57
+ const resolvedDoc = markdownToResolvedDoc(compiledMd);
58
+ ```
59
+
60
+ ### Markdown Syntax
61
+
62
+ #### Inline nodes
63
+
64
+ ```markdown
65
+ :quran[2:البَقَرَة:255]
66
+ :quran[2:البَقَرَة:255]{basmalah nocite}
67
+ :quran[2:البَقَرَة:255:3-7x3,256]{basmalah}
68
+
69
+ :hadith[narration ^^prophetic speech^^ text]{cite="البخاري" grade="صحيح"}
70
+
71
+ :quote[quoted text]{cite="المصدر"}
72
+ ```
73
+
74
+ #### Marks
75
+
76
+ ```markdown
77
+ **bold** *italic* [link](url)
78
+ ^^prophetic speech^^
79
+ {x3:repeated text}
80
+ ```
81
+
82
+ #### Blocks
83
+
84
+ ```markdown
85
+ # Heading 1
86
+ ## Heading 2
87
+ ### Heading 3
88
+
89
+ Paragraph text {x3}
90
+
91
+ > Blockquote text
92
+ > {cite="المصدر" x=2}
93
+
94
+ - Bullet list
95
+ 1. Ordered list
96
+ أ. Abjad list
97
+
98
+ :::poem{cite="الشاعر"}
99
+ صدر | عجز
100
+ صدر | عجز {x3}
101
+ ***
102
+ صدر | شطر ثاني | شطر ثالث
103
+ :::
104
+ ```
105
+
106
+ ### Escaping
107
+
108
+ - `\]` inside `:name[content]` — literal `]`
109
+ - `\"` inside `{key="value"}` — literal `"`
110
+ - `\{` at start of blockquote line — literal, not metadata
111
+
112
+ ### Known Limitations
113
+
114
+ - `^^` inside propheticSpeech mark content is not safe
115
+ - `}` inside inline-repeat mark content is not safe
116
+ - `\]` in directive content loses the backslash
117
+ - Blockquote line exactly matching `{key="value"}` is consumed as metadata
118
+
119
+ These do not affect Arabic Islamic content.
120
+
121
+ ## Schema Types
122
+
123
+ ```typescript
124
+ import type { QalamDoc, QalamDocResolved, QalamBlock, QalamInline } from "@siladev/qalam";
125
+ ```
126
+
127
+ ## Standalone Markdown Manager
128
+
129
+ ```typescript
130
+ import { createMarkdownManager } from "@siladev/qalam";
131
+
132
+ const manager = createMarkdownManager();
133
+ const json = manager.parse(markdown);
134
+ const md = manager.serialize(json);
135
+ ```