File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ typedef struct __Node {
42
42
43
43
extern _RustString __liveview_native_core$Document$to_string (__Document doc );
44
44
45
+ extern _RustString __liveview_native_core$Document$node_to_string (__Document doc , NodeRef node );
46
+
45
47
extern __Document __liveview_native_core$Document$empty ();
46
48
47
49
extern void __liveview_native_core$Document$drop (__Document doc );
Original file line number Diff line number Diff line change @@ -557,7 +557,17 @@ impl Document {
557
557
558
558
/// Prints this document using the given writer and options
559
559
pub fn print ( & self , writer : & mut dyn fmt:: Write , options : PrintOptions ) -> fmt:: Result {
560
- let printer = Printer :: new ( self , self . root , options) ;
560
+ self . print_node ( self . root , writer, options)
561
+ }
562
+
563
+ /// Prints a node in this document using the given writer and options
564
+ pub fn print_node (
565
+ & self ,
566
+ node : NodeRef ,
567
+ writer : & mut dyn fmt:: Write ,
568
+ options : PrintOptions ,
569
+ ) -> fmt:: Result {
570
+ let printer = Printer :: new ( self , node, options) ;
561
571
printer. print ( writer)
562
572
}
563
573
}
Original file line number Diff line number Diff line change @@ -130,6 +130,15 @@ pub extern "C" fn document_to_string(doc: *mut dom::Document) -> RustString {
130
130
RustString :: from_string ( doc. to_string ( ) )
131
131
}
132
132
133
+ #[ export_name = "__liveview_native_core$Document$node_to_string" ]
134
+ pub extern "C" fn document_node_to_string ( doc : * mut dom:: Document , node : NodeRef ) -> RustString {
135
+ let doc = unsafe { & * doc } ;
136
+ let mut buf = String :: new ( ) ;
137
+ doc. print_node ( node, & mut buf, dom:: PrintOptions :: Pretty )
138
+ . expect ( "error printing node" ) ;
139
+ RustString :: from_string ( buf)
140
+ }
141
+
133
142
#[ export_name = "__liveview_native_core$Document$merge" ]
134
143
pub extern "C" fn document_merge ( doc : * mut dom:: Document , other : * const dom:: Document ) -> bool {
135
144
let doc = unsafe { & mut * doc } ;
You can’t perform that action at this time.
0 commit comments