Skip to content

Commit a291c15

Browse files
authored
feat(ios): add HTML renderer (#110)
* feat(renderer): add html/plaintext rendering pipeline * feat(example): add tabbed demo screens * feat(ios): expand native fragment handling * chore: update lockfiles * docs: add html renderer usage
1 parent 59e9588 commit a291c15

54 files changed

Lines changed: 6675 additions & 1100 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ export function SelectionExample() {
8383
}
8484
```
8585

86+
## HTML rendering
87+
88+
NitroText can parse HTML string children and inline CSS when you pass `renderer="html"`.
89+
90+
```tsx
91+
import { NitroText } from 'react-native-nitro-text'
92+
93+
export function HtmlExample() {
94+
const html = `
95+
<div>
96+
<h2>Renderer demo</h2>
97+
<p>This text comes from <strong>HTML</strong> with <em>semantic</em> tags.</p>
98+
<p><span style="color: #ff6347; font-weight: bold;">Inline CSS works too.</span></p>
99+
</div>
100+
`
101+
102+
return <NitroText renderer="html">{html}</NitroText>
103+
}
104+
```
105+
86106
## Platform Support
87107

88108
- iOS

bun.lock

Lines changed: 502 additions & 259 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp/NitroTextLogger.hpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//
2+
// NitroTextLogger.hpp
3+
//
4+
//
5+
6+
#pragma once
7+
8+
#include <string>
9+
#include <sstream>
10+
#include <iostream>
11+
12+
// Check if we're in debug mode
13+
#ifndef NDEBUG
14+
#define NITRO_TEXT_DEBUG_LOGGING 1
15+
#else
16+
#define NITRO_TEXT_DEBUG_LOGGING 0
17+
#endif
18+
19+
namespace margelo::nitro::nitrotext::logger {
20+
21+
/**
22+
* @brief Logs an informational message
23+
* @param message The message to log
24+
* @param tag Optional tag identifier for categorization
25+
*
26+
* Only logs in debug builds to avoid performance overhead in production
27+
*/
28+
inline void info(
29+
const std::string& message,
30+
const std::string& tag = "") {
31+
#if NITRO_TEXT_DEBUG_LOGGING
32+
std::ostringstream oss;
33+
oss << "[NitroText]";
34+
if (!tag.empty()) {
35+
oss << " [" << tag << "]";
36+
}
37+
oss << " " << message;
38+
std::cout << oss.str() << std::endl;
39+
#else
40+
// No-op in release builds
41+
(void)message;
42+
(void)tag;
43+
#endif
44+
}
45+
46+
/**
47+
* @brief Logs a warning message
48+
* @param message The warning message to log
49+
* @param tag Optional tag identifier for categorization
50+
*
51+
* Only logs in debug builds to avoid performance overhead in production
52+
*/
53+
inline void warn(
54+
const std::string& message,
55+
const std::string& tag = "") {
56+
#if NITRO_TEXT_DEBUG_LOGGING
57+
std::ostringstream oss;
58+
oss << "[NitroText] [WARN]";
59+
if (!tag.empty()) {
60+
oss << " [" << tag << "]";
61+
}
62+
oss << " " << message;
63+
std::cerr << oss.str() << std::endl;
64+
#else
65+
// No-op in release builds
66+
(void)message;
67+
(void)tag;
68+
#endif
69+
}
70+
71+
/**
72+
* @brief Logs an error message
73+
* @param message The error message to log
74+
* @param tag Optional tag identifier for categorization
75+
*
76+
* Only logs in debug builds to avoid performance overhead in production
77+
*/
78+
inline void error(
79+
const std::string& message,
80+
const std::string& tag = "") {
81+
#if NITRO_TEXT_DEBUG_LOGGING
82+
std::ostringstream oss;
83+
oss << "[NitroText] [ERROR]";
84+
if (!tag.empty()) {
85+
oss << " [" << tag << "]";
86+
}
87+
oss << " " << message;
88+
std::cerr << oss.str() << std::endl;
89+
#else
90+
// No-op in release builds
91+
(void)message;
92+
(void)tag;
93+
#endif
94+
}
95+
96+
} // namespace margelo::nitro::nitrotext::logger

0 commit comments

Comments
 (0)