Example #1
0
  componentDidUpdate() {
    if (this.refs.html) {
      hljs.highlightBlock(this.refs.html);
    }

    if (this.refs.javascript) {
      hljs.highlightBlock(this.refs.javascript);
    }
  }
Example #2
0
				[].slice.call(mut.addedNodes).forEach(function(el) {

					// Ignore unless added element is a PRE > CODE
					el = (el.tagName === 'PRE' && el.querySelector('code')) || el;
					if (el.tagName === 'CODE' && el.parentNode.tagName === 'PRE') {
						hljs.highlightBlock(el);
					}
				});
Example #3
0
  }, function(err, response) {
    if (err) return onerror(err)

    var $code = document.querySelector('#code-view code')
    $code.className = 'hljs'
    $code.innerHTML = response.body
    highlight.highlightBlock($code)
  })
Example #4
0
 targets.forEach((target) => {
   // if a value is directly assigned to the directive, use this
   // instead of the element content.
   if (binding.value) {
     target.textContent = binding.value
   }
   hljs.highlightBlock(target)
 })
                setTimeout(() => {
                    if (this._unmounted) return;
                    for (let i = 0; i < blocks.length; i++) {
                        if (SettingsStore.getValue("enableSyntaxHighlightLanguageDetection")) {
                            highlight.highlightBlock(blocks[i]);
                        } else {
                            // Only syntax highlight if there's a class starting with language-
                            const classes = blocks[i].className.split(/\s+/).filter(function(cl) {
                                return cl.startsWith('language-');
                            });

                            if (classes.length != 0) {
                                highlight.highlightBlock(blocks[i]);
                            }
                        }
                    }
                }, 10);
Example #6
0
 requestAnimationFrame(() => {
   const node = findDOMNode(this);
   const codeBlocks = node.getElementsByTagName('pre');
   for (let i = 0; i < codeBlocks.length; i++) {
     const codeBlock = codeBlocks[i];
     hljs.highlightBlock(codeBlock.firstChild);
   }
 });
Example #7
0
 _highlightCode() {
   let domNode = ReactDOM.findDOMNode(this);
   let nodes = domNode.querySelectorAll('pre code');
   if (nodes.length > 0) {
     for (let i = 0; i < nodes.length; i=i+1) {
       hljs.highlightBlock(nodes[i]);
     }
   }
 }
Example #8
0
 highlightCode: function highlightCode() {
   var domNode = ReactDOM.findDOMNode(this);
   var nodes = domNode.querySelectorAll('pre code');
   if (nodes.length > 0) {
     for (var i = 0; i < nodes.length; i = i + 1) {
       hljs.highlightBlock(nodes[i]);
     }
   }
 },
Example #9
0
async function processHighlight (node) {
	console.log('processHighlight');
	var codes = node.querySelectorAll('pre.code');
	for (var i = 0, it; (it = codes[i]); i++) {
		if (/lang-(\S+)/.test(it.className)) {
			console.log('highlightBlock', it);
			hljs.highlightBlock(it);
		}
	}
	return node;
}
Example #10
0
export function highlightCodeBlocks() {
  let blocks = document.querySelectorAll('pre code[class*="language-"]');

  // For local development.
  if (window.location.port == 4000) {
    blocks = document.querySelectorAll('pre code');
  }

  for (let i = 0; i < blocks.length; i++) {
    hljs.highlightBlock(blocks[i]);
  }
}
		window[callbackName] = function(content) {

			// Extract just the prettyprint bit, which can then use techdocs standard styling
			content = content.replace(/^[\s\S]*(<pre [^>]*>)([\s\S]*?<\/pre>)[\s\S]*$/, "<pre><code>$2");
			content = content.replace(/<\/pre>$/, "</code></pre>");

			el.innerHTML = content;
			window[callbackName] = undefined;

			// Re-run highlighter so that the new content is highlighted
			hljs.highlightBlock(el.querySelector('code'));
		};
Example #12
0
 $('.sample').each((ind, element) => {
   const codeElement = $(element).find('code')[0];
   let code = codeElement.textContent;
   const startIndex = code.indexOf(SAMPLE_START);
   const endIndex = code.indexOf(SAMPLE_END);
   if (startIndex > -1 && endIndex > -1) {
     code = code.substring(code.indexOf(SAMPLE_START) + SAMPLE_START.length + 1);
     code = code.substring(0, code.indexOf(SAMPLE_END));
     if (!code.charAt(0).trim()) code = code.split('\n').map(l => l.substring(4)).join("\n")
   }
   codeElement.textContent = code;
   hljs.highlightBlock(codeElement);
 });
Example #13
0
  componentUpdated: function componentUpdated(el) {
    // after an update, re-fill the content and then highlight
    var targets = el.querySelectorAll('code');
    var target;
    var i;

    for (i = 0; i < targets.length; i += 1) {
      target = targets[i];
      // if (typeof binding.value === 'string') {
      //   target.textContent = binding.value;
      hljs.highlightBlock(target);
      // }
    }
  }
Example #14
0
File: main.js Project: rooc/scraper
			function(data, textStatus, jqXHR) {
				toastr.info(jqXHR.status, "jqXHR.status");
				toastr.info(textStatus, "textStatus");
				var content = $(data.results[0]);
				loader.clean();
				if(content.find(selector).length) {
					var rawhtml = htmlcleaner(content.find(selector)[0].outerHTML);
				} else {
					toastr.error("I don't think that your selector is real", 'Inconceivable!')
				}
				$('#outhtml>code').text(rawhtml);
				hljs.highlightBlock($('#outhtml>code')[0]);
				htmlTree(rawhtml);
			},
Example #15
0
  bind: function bind(el, binding) {
    // on first bind, highlight all targets
    var targets = el.querySelectorAll('code');
    var target;
    var i;

    for (i = 0; i < targets.length; i += 1) {
      target = targets[i];

      if (typeof binding.value === 'string') {
        // if a value is directly assigned to the directive, use this
        // instead of the element content.
        target.textContent = binding.value;
      }

      hljs.highlightBlock(target);
    }
  },
Example #16
0
 $('[pikHighlight]').map((idx, el) => {
   var $contents;
   var $el = $(el);
   var lang = $el.attr('pikHighlight') || '';
   if($el.is('code')){
     $el.addClass('language-' + lang);
     hljs.highlightBlock($el.get(0));
   } else if($el.is('pre')){
     $contents = $el.contents().detach();
     var $wrapper = $('<code>')
       .addClass('language-' + lang)
       .appendTo($el);
     $contents.appendTo($wrapper);
   } else {
     $contents = $el.contents().detach();
     var $wrapperPre = $('<pre>').appendTo($el);
     var $wrapperCode = $('<code>')
       .addClass('language-' + lang)
       .appendTo($wrapperPre);
     $contents.appendTo($wrapperCode);
   }
 });
Example #17
0
 componentDidMount: function() {
   Utils.mountJsBin();
   hljs.highlightBlock(this.refs.code1.getDOMNode());
   hljs.highlightBlock(this.refs.code2.getDOMNode());
 },
Example #18
0
File: Code.js Project: ariesw/belle
 componentDidUpdate() {
   highlightJs.highlightBlock(ReactDOM.findDOMNode(this));
 }
Example #19
0
File: Code.js Project: ariesw/belle
 componentDidMount() {
   highlightJs.highlightBlock(ReactDOM.findDOMNode(this));
 }
Example #20
0
 targets.forEach((target) => {
   if (binding.value) {
     target.textContent = binding.value
     hljs.highlightBlock(target)
   }
 })
 Array.prototype.forEach.call(codeBlocks, function (code) {
   highlight.highlightBlock(code)
 })
 highlight () {
   let node = document.querySelector('[data-highlight-id="' + this.props._id + '"] code.example-code')
   if (node) {
     hljs.highlightBlock(node)
   }
 }
Example #23
0
 const xxx = jQuery('pre').each((inde, block) => {
   hljs.highlightBlock(block);
 });
Example #24
0
const routes = (
  <Router createElement={createElement}
          history={hashHistory}>
    <Route component={Container}
           path='/'>
      {Object.keys(routeMap).map(key => {
        const r = routeMap[key]
        return (<Route
                key={key}
                path={key}
                name={r.name}
                component={r.component} />)
      })}
      <IndexRoute component={routeMap['basic'].component} />
    </Route>
  </Router>
)

const mountNode = document.querySelector('#root')
if (mountNode) {
  ReactDOM.render(routes, mountNode);
} else {
  const hljs = require('highlight.js');

  const codes = document.querySelectorAll('pre code');
  for (var i = 0; i < codes.length; i++) {
    const block = codes[i]
    hljs.highlightBlock(block);
  }
}
Example #25
0
			content.find("pre").each(function() {
				hljs.highlightBlock(this);
			});
Example #26
0
 nodes.forEach(node => {
   hljs.highlightBlock(node);
 });
Example #27
0
        if (!jQuery('section .block-content button[name=save]').length) {
            return;
        }
        if (event.isUserInputHandled) {
            return;
        }
        event.isUserInputHandled = true;
        Backbone.trigger('preventnavigateto', !confirm('Es gibt nicht gespeicherte Änderungen. Möchten Sie die Seite trotzdem verlassen?'));
    },

    render() {
        return this;
    },

    postRender() {
        hljs.highlightBlock(this.$('.code-content-preview > pre > code')[0]);
    },
    
    updatePreview() {
        var $code_content = this.escapeHtml(this.$('textarea').val());
        var $code_lang = this.$(".code_lang").val();
        var $preview_block = this.$('.code-content-preview > pre > code');
        $preview_block.html($code_content);
        if ($code_lang !== "") {
            $preview_block.removeAttr('class');
            $preview_block.addClass("hljs");
            $preview_block.addClass($code_lang);
        } else {
            var $classes = $preview_block.attr('class').split(/\s+/);
            if ($classes.length > 1) {
                this.$(".code_lang").val($classes[1]);
 didInsertElement: function(){
   Highlight.highlightBlock(this.get('element'));
 },
Example #29
0
 $('pre code').each(function(i, block) {
   hljs.highlightBlock(block);
 });
Example #30
0
 document.querySelectorAll('pre.hl code').forEach(block => hljs.highlightBlock(block));