mirror of
https://github.com/openwrt/luci.git
synced 2026-02-04 12:06:01 +08:00
contrib: introduce ucode-mod-html
The ucode-mod-html library provides assorted utility functions for dealing
with HTML markup data.
Example usage:
#!/usr/bin/ucode
'use strict';
import { tokenize, striptags, entitydecode, entityencode,
OPEN, ATTR, TEXT, CLOSE, RAW, COMMENT, CDATA, PROCINST, EOF } from 'html';
tokenize('<div class="example">Hello world!</div>...',
function(type, text, value) {
switch (type) {
case OPEN: print(`Opening tag: ${text}\n`); break;
case ATTR: print(`Attribute: ${text}${value ? `=${value}`}\n`; break;
case TEXT: print(`Text data: ${text}\n`); break;
case CLOSE: print(`Closing tag: ${text}\n`); break;
case RAW: print(`Script/CSS: ${text}\n`); break;
case COMMENT: print(`Comment: ${text}\n`); break;
case CDATA: print(`CDATA text: ${text}\n`); break;
case PROCINST: print(`<!...> tag: ${text}\n`); break;
case EOF: print(`End of input\n`); break;
}
}
);
print(striptags('<p>This is some <b>text</b> with <br> markup</p>\n'));
print(entitydecode('<   & ä'));
print(entityencode('1 < 2 && "foo"'));
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
31
contrib/package/ucode-mod-html/Makefile
Normal file
31
contrib/package/ucode-mod-html/Makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ucode-mod-html
|
||||
PKG_RELEASE:=1
|
||||
PKG_LICENSE:=ISC
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ucode-mod-html
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=ucode HTML utility library
|
||||
DEPENDS:=+libucode
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-html/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(CP) $(PKG_BUILD_DIR)/html.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(FPIC) \
|
||||
-Wall -ffunction-sections -Wl,--gc-sections -shared \
|
||||
-o $(PKG_BUILD_DIR)/html.so $(PKG_BUILD_DIR)/html.c
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ucode-mod-html))
|
||||
2793
contrib/package/ucode-mod-html/src/html.c
Normal file
2793
contrib/package/ucode-mod-html/src/html.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user