textile to slides

    @@ -7,7 +7,7 @@ * @require http://html5slides.googlecode.com/svn/trunk/slides.js */ -function textiletoslide(){ +function textiletoslides(){ var content = document.getElementsByTagName('pre')[0]; content.innerHTML = convert(content.innerHTML); content.style.display = "none"; @@ -17,24 +17,20 @@ document.body.appendChild(slides); var article = null; - - for(var c=0; c<content.childNodes.length; c++){ - var child = content.childNodes[c]; + while(child = content.childNodes.item()){ if( ["H1", "H2", "H3"].indexOf(child.tagName) > -1 ){ // is H1,2,3 - if( article != null ){ - slides.appendChild(article); - } article = document.createElement('article'); article.appendChild(child); + slides.appendChild(article); } else { if( article == null ){ article = document.createElement('article'); + slides.appendChild(article); } article.appendChild(child); } } - handleDomLoaded(); } -textiletoslide(); +textiletoslides();
  • /*
     * @title textile to slides
     * @description textileフォーマットのテキストをhtml5slidesにするブックマークレット
     * @include http://*
     * @license MIT License
     * @require http://www.ben-daglish.net/textile/textile.js
     * @require http://html5slides.googlecode.com/svn/trunk/slides.js
     */
    
    function textiletoslides(){
      var content = document.getElementsByTagName('pre')[0];
      content.innerHTML = convert(content.innerHTML);
      content.style.display = "none";
    
      var slides = document.createElement('section');
      slides.className = "slides layout-regular template-default";
      document.body.appendChild(slides);
    
      var article = null;
      while(child = content.childNodes.item()){
        if( ["H1", "H2", "H3"].indexOf(child.tagName) > -1 ){ // is H1,2,3
          article = document.createElement('article');
          article.appendChild(child);
          slides.appendChild(article);
        } else {
          if( article == null ){
            article = document.createElement('article');
            slides.appendChild(article);
          }
          article.appendChild(child);
        }
      }
      handleDomLoaded();
    }
    
    textiletoslides();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2012/06/02 13:51:39 - 2012-06-02
  2. 2012/06/02 13:31:19 - 2012-06-02
  3. 2012/06/02 00:56:28 - 2012-06-02
  4. 2012/06/02 00:49:31 - 2012-06-02
  5. 2012/06/02 00:49:07 - 2012-06-02
  6. 2012/06/02 00:46:59 - 2012-06-02
  7. 2012/06/02 00:34:17 - 2012-06-02
  8. 2012/06/02 00:33:31 - 2012-06-02