@@ -109,10 +109,12 @@ class Listener{
109109 /**
110110 * Executes command
111111 * @param {String } AICode
112+ * @param {boolean } [rawCode=false] Returns raw HTML
112113 * @returns {Array<boolean,string>|Boolean } Returns information on success
113114 */
114- render ( AICode ) {
115+ render ( AICode , rawCode = false ) {
115116 this . lineCode = [ ] ;
117+ this . endedElem = [ ] ;
116118 this . holder = - 1 ;
117119 let success = true ;
118120 AICode = AICode . split ( / (?< = } ) \| \| / g) . map ( ( x ) => { return x . replace ( / ^ { | } $ / g, '' ) } ) . filter ( ( x ) => { return x !== '' } ) ;
@@ -767,27 +769,31 @@ class Listener{
767769 elem . style . fontWeight = ( this . lineCode [ i ] . styles . fontWeight ? this . lineCode [ i ] . styles . fontWeight : '' ) ;
768770 elem . style . fontStyle = ( this . lineCode [ i ] . styles . fontStyle ? this . lineCode [ i ] . styles . fontStyle : '' ) ;
769771 elem . style . textDecoration = ( this . lineCode [ this . holder ] && this . lineCode [ this . holder ] . styles . textDecoration ? this . lineCode [ this . holder ] . styles . textDecoration : '' ) ;
772+ if ( ! rawCode ) {
770773 if ( this . lineCode [ i ] . location ) {
771774 if ( document . querySelector ( this . lineCode [ i ] . location ) . tagName . toLocaleLowerCase ( ) === 'body' ) {
772775 document . body . insertBefore ( elem , document . body . children [ this . placeOver ] ) ;
773776 this . placeOver += 1 ;
774777 } else
775778 document . querySelector ( this . lineCode [ i ] . location ) . appendChild ( elem ) ;
779+ } else {
780+ if ( elem . tagName . toLocaleLowerCase ( ) === 'link' )
781+ document . head . appendChild ( elem , document . head ) ;
782+ else {
783+ document . body . insertBefore ( elem , document . body . children [ this . placeOver ] ) ;
784+ this . placeOver += 1 ;
785+ }
786+ }
776787 } else {
777- if ( elem . tagName . toLocaleLowerCase ( ) === 'link' )
778- document . head . appendChild ( elem , document . head ) ;
779- else {
780- document . body . insertBefore ( elem , document . body . children [ this . placeOver ] ) ;
781- this . placeOver += 1 ;
782- }
783- }
788+ this . endedElem . push ( elem . outerHTML ) ;
789+ }
784790 }
785791 ( this . buildEvent !== null ? window . dispatchEvent ( this . buildEvent ) : '' ) ; this . buildEvent = null ;
786792 document . querySelectorAll ( 'code' ) . forEach ( ( e ) => {
787793 e . innerHTML = e . innerHTML . replaceAll ( '<br>' , '\n' ) ;
788794 } ) ;
789795 Prism . highlightAll ( ) ;
790- return this . lineCode ;
796+ return ( this . endedElem . length > 0 ? this . endedElem : this . lineCode ) ;
791797 } else {
792798 return false ;
793799 }
0 commit comments