@@ -2,7 +2,7 @@ import van from "vanjs-core";
2
2
import * as htmlparser2 from "htmlparser2" ;
3
3
import { svg as example } from "./example" ;
4
4
5
- const { h1, code, button, div, pre, textarea, p } = van . tags ;
5
+ const { h1, code, button, div, pre, input , textarea, p, label } = van . tags ;
6
6
7
7
const html2tree = ( str ) => {
8
8
let res = `` ;
@@ -21,9 +21,10 @@ const html2tree = (str) => {
21
21
22
22
const App = ( ) => {
23
23
const html_input = van . state ( example ) ;
24
+ const add_xmlns = van . state ( true ) ;
24
25
const output_tree = van . derive (
25
26
( ) =>
26
- `\\xmlns:html{http://www.w3.org/1999/xhtml}\n\n` +
27
+ ( add_xmlns . val ? `\\xmlns:html{http://www.w3.org/1999/xhtml}\n\n` : `` ) +
27
28
html2tree ( html_input . val )
28
29
) ;
29
30
@@ -32,6 +33,14 @@ const App = () => {
32
33
p (
33
34
`Put HTML into the textarea, then copy the forester tree right hand side.`
34
35
) ,
36
+ input ( {
37
+ type : `checkbox` ,
38
+ id : `add-namespace` ,
39
+ onclick : ( ) => {
40
+ add_xmlns . val = ! add_xmlns . val ;
41
+ } ,
42
+ } ) ,
43
+ label ( { for : `add-namespace` } , `disable inserted namespace` ) ,
35
44
div (
36
45
textarea ( {
37
46
value : html_input ,
@@ -43,10 +52,10 @@ const App = () => {
43
52
{
44
53
onclick : ( ) => {
45
54
navigator . clipboard . writeText ( output_tree . val ) ;
46
- alert ( " copied!" ) ;
55
+ alert ( ` copied!` ) ;
47
56
} ,
48
57
} ,
49
- " copy"
58
+ ` copy`
50
59
)
51
60
)
52
61
)
0 commit comments