<commit_before><?php
/**
 * Renderer for XHTML output
 *
 * @author <NAME> <<EMAIL>>
 */
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

// we inherit from the XHTML renderer instead directly of the base renderer
require_once DOKU_INC.'inc/parser/xhtml.php';

/**
 * The Renderer
 */
class renderer_plugin_revealjs extends Doku_Renderer_xhtml {
    var $slide_open = false;
    var $column_open = false;
    var $base='';
    var $tpl='';
    var $next_slide_with_background = false;
    var $background_image_url;

    public function add_background_to_next_slide($image_url){
        $this->background_image_url = $image_url;
        $this->next_slide_with_background = true;
    }

    /**
     * the format we produce
     */
    function getFormat(){
        // this should be 'revealjs' usally, but we inherit from the xhtml renderer
        // and produce XHTML as well, so we can gain magically compatibility
        // by saying we're the 'xhtml' renderer here.
        return 'xhtml';
    }


    /**
     * Initialize the rendering
     */
    function document_start() {
        global $ID;
        global $conf;
        global $lang;

        // call the parent
        parent::document_start();

        // store the content type headers in metadata
        $headers = array(
            'Content-Type' => 'text/html; charset=utf-8'
        );
       p_set_metadata($ID,array('format' => array('revealjs' => $headers) ));
        $this->base = DOKU_BASE.'lib/plugins/revealjs/';
       $this->doc = '
<!DOCTYPE html>
<html lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">

	<head>
		<meta charset="utf-8">

		<title>'.tpl_pagetitle($ID, true).'</title>

		<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
		<meta name="author" content="<NAME>">

		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">

                <link rel="stylesheet" href="'.$this->base.'css/reveal.css">
		<link rel="stylesheet" href="'.$this->base.'css/theme/'.$this->getConf('theme').'.css" id="theme">
                <link rel="stylesheet" href="'.$this->base.'doku-substitutes.css"> 

		<!-- Code syntax highlighting -->
		<link rel="stylesheet" href="'.$this->base.'lib/css/zenburn.css">

		<!-- Printing and PDF exports -->
		<script>
			var link = document.createElement( \'link\' );
			link.rel = \'stylesheet\';
			link.type = \'text/css\';
			link.href = window.location.search.match( /print-pdf/gi ) ? \''.$this->base.'css/print/pdf.css\' : \''.$this->base.'css/print/paper.css\';
			document.getElementsByTagName( \'head\' )[0].appendChild( link );
		</script>

		<!--[if lt IE 9]>
		<script src='.$this->base.'"lib/js/html5shiv.js"></script>
		<![endif]-->
	</head>
<body>

		<div class="reveal">

			<!-- Any section element inside of this container is displayed as a slide -->
			<div class="slides">
';
    }

 

    /**
     * Closes the document
     */
    function document_end(){
        // we don't care for footnotes and toc
        // but cleanup is nice
        $this->doc = preg_replace('#<p>\s*</p>#','',$this->doc);

        if($this->slide_open){
            $this->doc .= '</section>'.DOKU_LF; //close previous slide
            if ( $this->column_open ) { // close nested section
                      $this->doc .= '</section>'.DOKU_LF;
                      $this->column_open = false;
             }
        }
        $show_controls = $this->getConf('controls') ? 'true' : 'false';
        $this->doc .= '</div></div>
		<script src="'.$this->base.'lib/js/head.min.js"></script>
		<script src="'.$this->base.'js/reveal.js"></script>

		<script>

			// Full list of configuration options available here:
			// https://github.com/hakimel/reveal.js#configuration
			Reveal.initialize({
				controls: '. $show_controls .',
				progress: true,
				history: true,
				center: true,

				transition: \'slide\', // none/fade/slide/convex/concave/zoom
				math: {
                                   mathjax: \'//cdn.mathjax.org/mathjax/latest/MathJax.js\',
                                   config: \'TeX-AMS_HTML-full\'  // See http://docs.mathjax.org/en/latest/config-files.html
                                },

				dependencies: [
					{ src: \''.$this->base.'lib/js/classList.js\', condition: function() { return !document.body.classList; } },
					{ src: \''.$this->base.'plugin/markdown/marked.js\', condition: function() { return !!document.querySelector( \'[data-markdown]\' ); } },
					{ src: \''.$this->base.'plugin/markdown/markdown.js\', condition: function() { return !!document.querySelector( \'[data-markdown]\' ); } },
					{ src: \''.$this->base.'plugin/highlight/highlight.js\', async: true, condition: function() { return !!document.querySelector( \'pre code\' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
					{ src: \''.$this->base.'plugin/zoom-js/zoom.js\', async: true, condition: function() { return !!document.body.classList; } },
					{ src: \''.$this->base.'plugin/notes/notes.js\', async: true, condition: function() { return !!document.body.classList; } },

                                        // MathJax
                                       { src: \''.$this->base.'plugin/math/math.js\', async: true }
				]
			});

		</script>
         </body>
</html>';
    }

    /*
    *
     * Creates a new section possibliy including the background image.
     */
    function create_slide_section($with_backgound){
        $this->doc .= '<section';
        if ($this->next_slide_with_background && $with_backgound){
            $this->doc .= ' data-background="'.$this->background_image_url.'">';
            $this->next_slide_with_background = false;
        } else {
            $this->doc .= '>';
        }
        $this->doc .= DOKU_LF;
    }


    /**
     * This is what creates new slides
     *
     * A new column is started for each H1 or H2 header
     * A new vertical slide for each H3 header
     */
    function header($text, $level, $pos) {
        if($level <= 3){
            if($this->slide_open){
                $this->doc .= '</section>'.DOKU_LF; //close previous slide
                if ( ($this->column_open) && ($level <= 2) ) { // close nested section
                      $this->doc .= '</section>'.DOKU_LF;
                      $this->column_open = false;
                }
            }
            if ( $level <= 2 ) {   //first slide of possibly following nested ones if level is 2
                 $this->create_slide_section(false);
                 $this->column_open = true;
            }
            $this->create_slide_section(true); # always without background to not to have a background for a whole subsection
            $this->slide_open = true;
        }
        $this->doc .= '<h'.$level.'>';
        $this->doc .= $this->_xmlEntities($text);
        $this->doc .= '</h'.$level.'>'.DOKU_LF;
        if (strlen($text) == 0) {
            $this->doc .='.'; //firefox pdf print hack
        }
    }

    /**
     * Top-Level Sections are slides
     */
    function section_open($level) {
        if($level < 3){
           // $this->doc .= '<section>'.DOKU_LF;
        }else{
            //$this->doc .= '<section>'.DOKU_LF;
        }
        // we don't use it
    }

   function section_close() {
    
   }

    /**
     * Throw away footnote
     */
    function footnote_close() {
        // recover footnote into the stack and restore old content
        $footnote = $this->doc;<commit_msg>background image fix<commit_after><?php
/**
 * Renderer for XHTML output
 *
 * @author <NAME> <<EMAIL>>
 */
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

// we inherit from the XHTML renderer instead directly of the base renderer
require_once DOKU_INC.'inc/parser/xhtml.php';

/**
 * The Renderer
 */
class renderer_plugin_revealjs extends Doku_Renderer_xhtml {
    var $slide_open = false;
    var $column_open = false;
    var $base='';
    var $tpl='';
    var $next_slide_with_background = false;
    var $background_image_url;

    public function add_background_to_next_slide($image_url){
        $this->background_image_url = $image_url;
        $this->next_slide_with_background = true;
    }

    /**
     * the format we produce
     */
    function getFormat(){
        // this should be 'revealjs' usally, but we inherit from the xhtml renderer
        // and produce XHTML as well, so we can gain magically compatibility
        // by saying we're the 'xhtml' renderer here.
        return 'xhtml';
    }


    /**
     * Initialize the rendering
     */
    function document_start() {
        global $ID;
        global $conf;
        global $lang;

        // call the parent
        parent::document_start();

        // store the content type headers in metadata
        $headers = array(
            'Content-Type' => 'text/html; charset=utf-8'
        );
       p_set_metadata($ID,array('format' => array('revealjs' => $headers) ));
        $this->base = DOKU_BASE.'lib/plugins/revealjs/';
       $this->doc = '
<!DOCTYPE html>
<html lang="'.$conf['lang'].'" dir="'.$lang['direction'].'">

	<head>
		<meta charset="utf-8">

		<title>'.tpl_pagetitle($ID, true).'</title>

		<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
		<meta name="author" content="<NAME>">

		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">

                <link rel="stylesheet" href="'.$this->base.'css/reveal.css">
		<link rel="stylesheet" href="'.$this->base.'css/theme/'.$this->getConf('theme').'.css" id="theme">
                <link rel="stylesheet" href="'.$this->base.'doku-substitutes.css"> 

		<!-- Code syntax highlighting -->
		<link rel="stylesheet" href="'.$this->base.'lib/css/zenburn.css">

		<!-- Printing and PDF exports -->
		<script>
			var link = document.createElement( \'link\' );
			link.rel = \'stylesheet\';
			link.type = \'text/css\';
			link.href = window.location.search.match( /print-pdf/gi ) ? \''.$this->base.'css/print/pdf.css\' : \''.$this->base.'css/print/paper.css\';
			document.getElementsByTagName( \'head\' )[0].appendChild( link );
		</script>

		<!--[if lt IE 9]>
		<script src='.$this->base.'"lib/js/html5shiv.js"></script>
		<![endif]-->
	</head>
<body>

		<div class="reveal">

			<!-- Any section element inside of this container is displayed as a slide -->
			<div class="slides">
';
    }

 

    /**
     * Closes the document
     */
    function document_end(){
        // we don't care for footnotes and toc
        // but cleanup is nice
        $this->doc = preg_replace('#<p>\s*</p>#','',$this->doc);

        if($this->slide_open){
            $this->doc .= '</section>'.DOKU_LF; //close previous slide
            if ( $this->column_open ) { // close nested section
                      $this->doc .= '</section>'.DOKU_LF;
                      $this->column_open = false;
             }
        }
        $show_controls = $this->getConf('controls') ? 'true' : 'false';
        $this->doc .= '</div></div>
		<script src="'.$this->base.'lib/js/head.min.js"></script>
		<script src="'.$this->base.'js/reveal.js"></script>

		<script>

			// Full list of configuration options available here:
			// https://github.com/hakimel/reveal.js#configuration
			Reveal.initialize({
				controls: '. $show_controls .',
				progress: true,
				history: true,
				center: true,

				transition: \'slide\', // none/fade/slide/convex/concave/zoom
				math: {
                                   mathjax: \'//cdn.mathjax.org/mathjax/latest/MathJax.js\',
                                   config: \'TeX-AMS_HTML-full\'  // See http://docs.mathjax.org/en/latest/config-files.html
                                },

				dependencies: [
					{ src: \''.$this->base.'lib/js/classList.js\', condition: function() { return !document.body.classList; } },
					{ src: \''.$this->base.'plugin/markdown/marked.js\', condition: function() { return !!document.querySelector( \'[data-markdown]\' ); } },
					{ src: \''.$this->base.'plugin/markdown/markdown.js\', condition: function() { return !!document.querySelector( \'[data-markdown]\' ); } },
					{ src: \''.$this->base.'plugin/highlight/highlight.js\', async: true, condition: function() { return !!document.querySelector( \'pre code\' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
					{ src: \''.$this->base.'plugin/zoom-js/zoom.js\', async: true, condition: function() { return !!document.body.classList; } },
					{ src: \''.$this->base.'plugin/notes/notes.js\', async: true, condition: function() { return !!document.body.classList; } },

                                        // MathJax
                                       { src: \''.$this->base.'plugin/math/math.js\', async: true }
				]
			});

		</script>
         </body>
</html>';
    }

    /*
    *
     * Creates a new section possibliy including the background image.
     */
    function create_slide_section($with_backgound){
        $this->doc .= '<section';
        if ($this->next_slide_with_background && $with_backgound){
            $this->doc .= ' data-background="'.$this->background_image_url.'">';
            $this->next_slide_with_background = false;
        } else {
            $this->doc .= '>';
        }
        $this->doc .= DOKU_LF;
    }


    /**
     * This is what creates new slides
     *
     * A new column is started for each H1 or H2 header
     * A new vertical slide for each H3 header
     */
    function header($text, $level, $pos) {
        if($level <= 3){
            if($this->slide_open){
                $this->doc .= '</section>'.DOKU_LF; //close previous slide
                if ( ($this->column_open) && ($level <= 2) ) { // close nested section
                      $this->doc .= '</section>'.DOKU_LF;
                      $this->column_open = false;
                }
            }
            if ( $level <= 2 ) {   //first slide of possibly following nested ones if level is 2
                 $this->create_slide_section(false);
                 $this->column_open = true;
            }
            $this->create_slide_section(true); # always without background to not to have a background for a whole subsection
            $this->slide_open = true;
        }
        $this->doc .= '<h'.$level.'>';
        $this->doc .= $this->_xmlEntities($text);
        if (strlen($text) == 0) {
            $this->doc .='.'; //firefox pdf print hack
        }
        $this->doc .= '</h'.$level.'>'.DOKU_LF;
    }

    /**
     * Top-Level Sections are slides
     */
    function section_open($level) {
        if($level < 3){
           // $this->doc .= '<section>'.DOKU_LF;
        }else{
            //$this->doc .= '<section>'.DOKU_LF;
        }
        // we don't use it
    }

   function section_close() {
    
   }

    /**
     * Throw away footnote
     */
    function footnote_close() {
        // recover footnote into the stack and restore old content
        $footnote = $this->doc;
{'fraction_non_alphanumeric': 0.17470935896603235, 'fraction_numerical': 0.002338117815158797, 'mean_word_length': 2.179434234978319, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 225, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '597411', 'n_tokens_mistral': 5031, 'n_tokens_neox': 4657, 'n_words': 1025}