| Prop | Type | Default | Description |
|---|---|---|---|
html |
string |
- | HTML 字符串(必填) |
removeAllClass |
boolean |
true |
删除所有 class 属性 |
removeAllStyle |
boolean |
false |
删除所有 style 属性 |
styleMode |
'inline' | 'css-class' |
'inline' |
样式模式 |
rootClassName |
string |
'lynx-html-renderer' |
根容器类名 |
darkMode |
boolean |
false |
CSS 类模式下启用暗色主题类名 |
linkStyle |
Record<string, string | number> |
- | 自定义链接样式,仅 inline 模式生效 |
debug |
boolean |
false |
启用 transform 调试日志 |
adapterRegistry |
AdapterRegistry |
全局默认注册表 | 为该组件指定独立的渲染适配器 |
plugins |
PluginConfig |
- | 添加、替换或禁用 Transform 插件 |
tagMappings |
TransformOptions['tagMappings'] |
- | 自定义或覆盖 HTML 标签映射 |
unknownTagPolicy |
'drop' | 'unwrap' | 'fallback' |
'drop' |
未知标签的处理策略 |
HTMLRenderer 与 renderHTMLDirect 接受相同的属性。扩展方式及未知标签策略见 插件文档。
| HTML Tag | Lynx Component | Notes |
|---|---|---|
div |
<view> |
Default block container |
p |
<text> |
Paragraph with margin |
h1-h6 |
<text> |
Heading levels |
section |
<view> |
Section container |
article |
<view> |
Article container |
header |
<view> |
Header container |
footer |
<view> |
Footer container |
nav |
<view> |
Navigation container |
aside |
<view> |
Aside container |
blockquote |
<view> |
Block quote with border |
pre |
<text> |
Preformatted text |
hr |
<view> |
Horizontal divider |
| HTML Tag | Lynx Component | Notes |
|---|---|---|
span |
<text> |
Inline text container |
strong |
<text> |
Bold text (via marks) |
b |
<text> |
Bold text (via marks) |
em |
<text> |
Italic text (via marks) |
i |
<text> |
Italic text (via marks) |
u |
<text> |
Underlined text (via marks) |
code |
<text> |
Inline code style |
a |
<text> |
Link with data-href attribute |
| HTML Tag | Lynx Component | Notes |
|---|---|---|
img |
<image> |
Image element |
| HTML Tag | Lynx Component | Notes |
|---|---|---|
ul |
<view> |
Unordered list |
ol |
<view> |
Ordered list |
li |
<view> |
List item |
| HTML Tag | Lynx Component | Notes |
|---|---|---|
table |
<view> |
Table container |
thead |
<view> |
Table header |
tbody |
<view> |
Table body |
tfoot |
<view> |
Table footer |
tr |
<view> |
Table row (role: row) |
th |
<view> |
Table header cell (role: cell) |
td |
<view> |
Table cell (role: cell) |
| HTML Tag | Lynx Component | Notes |
|---|---|---|
br |
\n |
Line break |
All text properties are supported on <text> elements:
| Property | Type | Description |
|---|---|---|
color |
string |
Text color |
fontFamily |
string |
Font family |
fontSize |
string | number |
Font size |
fontWeight |
string | number |
Font weight |
fontStyle |
string |
Font style (normal, italic) |
lineHeight |
string | number |
Line height |
textAlign |
string |
Text alignment |
textDecoration |
string |
Text decoration |
textShadow |
string |
Text shadow (Lynx specific) |
textStroke |
string |
Text stroke (Lynx specific) |
textIndent |
string | number |
Text indent |
letterSpacing |
string | number |
Letter spacing |
wordSpacing |
string | number |
Word spacing |
wordBreak |
string |
Word break behavior |
whiteSpace |
string |
White space handling |
direction |
string |
Text direction (ltr, rtl) |
| Property | Type | Description |
|---|---|---|
display |
string |
Display mode |
flexDirection |
string |
Flex direction |
justifyContent |
string |
Justify content |
alignItems |
string |
Align items |
flexWrap |
string |
Flex wrap |
gap |
string | number |
Gap |
margin* |
string | number |
Margin properties |
padding* |
string | number |
Padding properties |
width |
string | number |
Width |
height |
string | number |
Height |
minWidth |
string | number |
Minimum width |
maxWidth |
string | number |
Maximum width |
minHeight |
string | number |
Minimum height |
maxHeight |
string | number |
Maximum height |
| Property | Description |
|---|---|
-x-flex-direction |
Flex direction (vendor prefix) |
-x-transform |
CSS transform |
-x-animation |
CSS animation |
-x-transition |
CSS transition |
Render HTML to React elements without hooks:
Parse HTML to LynxNodes:
Note: rootClassName is a renderer-only option (HTMLRenderer) and is ignored by transformHTML.
| Code | Description |
|---|---|
PARSE_ERROR |
HTML parsing failed |
UNSUPPORTED_TAG |
Unsupported HTML tag |
STYLE_ERROR |
Style parsing failed |
PLUGIN_ERROR |
Plugin execution failed |
VALIDATION_ERROR |
Validation error |
RENDER_ERROR |
Rendering error |