Skip to content

Instantly share code, notes, and snippets.

@Digitalsabre
Forked from passcod/data-markdown.user.js
Created November 9, 2011 02:26

Revisions

  1. Digitalsabre revised this gist Feb 24, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions readme.markdown
    Original file line number Diff line number Diff line change
    @@ -18,9 +18,11 @@ So the idea is you're operating in an HTML environment but a few shortcuts would
    ## This is a level two header (h2)
    * This is a list item (li) inside an unordered list (ul)
    * This is a list item inside the same unordered list. It contains an anchor tag (a) here --> [Some Link](http://www.example.com/)
    * This is a list item inside the same unordered list.
    It contains an anchor tag (a) here --> [Some Link](http://www.example.com/)
    * This is another list item inside the same unordered list.
    1. This list item is inside another list, this time ordered (ol), nested inside the previous list item, nested inside the previous unordered list.
    1. This list item is inside another list, this time ordered (ol), nested
    inside the previous list item, nested inside the previous unordered list.
    > Here's a blockquote with some **“stylistically offset” text.**
    </section>
  2. Digitalsabre revised this gist Feb 24, 2012. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions readme.markdown
    Original file line number Diff line number Diff line change
    @@ -15,12 +15,12 @@ So the idea is you're operating in an HTML environment but a few shortcuts would
    ```
    <div class="slide">
    <section class="hbox" data-markdown>
    ## This is an H2
    ## This is a level two header (h2)
    * This is an LI inside a UL
    * This is an LI inside the same UL. It contains an A here --&gt; [Some Link](http://www.example.com/)
    * This is another LI inside the same UL.
    * This LI is inside another UL, nested inside the previous LI, nested inside the previous UL.
    * This is a list item (li) inside an unordered list (ul)
    * This is a list item inside the same unordered list. It contains an anchor tag (a) here --&gt; [Some Link](http://www.example.com/)
    * This is another list item inside the same unordered list.
    1. This list item is inside another list, this time ordered (ol), nested inside the previous list item, nested inside the previous unordered list.
    > Here's a blockquote with some **“stylistically offset” text.**
    </section>
  3. Digitalsabre revised this gist Nov 9, 2011. 2 changed files with 4 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ==UserScript==
    // @name *[data-markdown]
    // @version 2.0
    // @version 2.0.2
    // @description Use Markdown, sometimes, in your HTML.
    // @author Paul Irish <http://paulirish.com/> and others
    // @include *
    4 changes: 3 additions & 1 deletion readme.markdown
    Original file line number Diff line number Diff line change
    @@ -30,4 +30,6 @@ So the idea is you're operating in an HTML environment but a few shortcuts would

    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_

    Editorial: PageDown is a more reliable Markdown parser outside of Github than Github Flavored Markdown.
    Editorial: PageDown is a more reliable Markdown parser outside of Github than Github Flavored Markdown.

    Revision 2: Changed PageDown URL to https to fix "insecure content" notifications in secure pages. Hope it works...
  4. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ var el;

    el = document.createElement("script");
    el.type = "application/javascript";
    el.src = "http://pagedown.googlecode.com/hg/Markdown.Converter.js";
    el.src = "https://pagedown.googlecode.com/hg/Markdown.Converter.js";
    document.body.appendChild(el);

    el = null;
  5. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 0 additions and 12 deletions.
    12 changes: 0 additions & 12 deletions example.html
    Original file line number Diff line number Diff line change
    @@ -1,12 +0,0 @@
    <div class="slide">
    <section class="hbox" data-markdown>
    ## This is an H2

    * This is an LI inside a UL
    * This is an LI inside the same UL. It contains an A here --&gt; [Some Link](http://www.example.com/)
    * This is another LI inside the same UL.
    * This LI is inside another UL, nested inside the previous LI, nested inside the previous UL.

    > Here's a blockquote with some **“stylistically offset” text.**
    </section>
    </div>
  6. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion readme.markdown
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,8 @@ So the idea is you're operating in an HTML environment but a few shortcuts would
    * It automatically adds [PageDown's Markdown Converter](http://pagedown.googlecode.com/hg/Markdown.Converter.js) to every page.
    2. Add `data-markdown` attributes to any tags where you're gonna use markdown within, like so:

    ```<div class="slide">
    ```
    <div class="slide">
    <section class="hbox" data-markdown>
    ## This is an H2
  7. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 15 additions and 1 deletion.
    16 changes: 15 additions & 1 deletion readme.markdown
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,21 @@ So the idea is you're operating in an HTML environment but a few shortcuts would

    1. Install this userscript (click the [`raw`](https://gist.github.com/raw/1350130/data-markdown.user.js) link for the user.js file below).
    * It automatically adds [PageDown's Markdown Converter](http://pagedown.googlecode.com/hg/Markdown.Converter.js) to every page.
    2. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)
    2. Add `data-markdown` attributes to any tags where you're gonna use markdown within, like so:

    ```<div class="slide">
    <section class="hbox" data-markdown>
    ## This is an H2
    * This is an LI inside a UL
    * This is an LI inside the same UL. It contains an A here --&gt; [Some Link](http://www.example.com/)
    * This is another LI inside the same UL.
    * This LI is inside another UL, nested inside the previous LI, nested inside the previous UL.
    > Here's a blockquote with some **“stylistically offset” text.**
    </section>
    </div>
    ```


    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_
  8. Digitalsabre revised this gist Nov 9, 2011. 3 changed files with 14 additions and 10 deletions.
    1 change: 1 addition & 0 deletions data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@
    // Thaddee Tyl <http://espadrine.github.com/>
    // Digitalsabre <https://github.com/Digitalsabre>
    // Félix Saparelli <http://passcod.net/>
    // The guys at StackExchange

    function X0() {
    if (!window.Markdown) {
    15 changes: 8 additions & 7 deletions example.html
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,12 @@
    <div class="slide">
    <section class="hbox" data-markdown>
    ## Who Am I?
    <section class="hbox" data-markdown>
    ## This is an H2

    * Lead developer of [Modernizr](//modernizr.com)
    * Project lead of [HTML5 Boilerplate](//h5bp.com)
    * I curate that [page of polyfills](//bit.ly/polyfills)
    * Member of jQuery Team
    * Developer Relations on Google Chrome team
    * This is an LI inside a UL
    * This is an LI inside the same UL. It contains an A here --&gt; [Some Link](http://www.example.com/)
    * This is another LI inside the same UL.
    * This LI is inside another UL, nested inside the previous LI, nested inside the previous UL.

    > Here's a blockquote with some **“stylistically offset” text.**
    </section>
    </div>
    8 changes: 5 additions & 3 deletions readme.markdown
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,11 @@ So the idea is you're operating in an HTML environment but a few shortcuts would

    ### To use:

    1. Install this userscript (click [the 'raw' link for the user.js file below](https://gist.github.com/raw/1349945/data-markdown.user.js)).
    * It automatically adds [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) to every page.
    1. Install this userscript (click the [`raw`](https://gist.github.com/raw/1350130/data-markdown.user.js) link for the user.js file below).
    * It automatically adds [PageDown's Markdown Converter](http://pagedown.googlecode.com/hg/Markdown.Converter.js) to every page.
    2. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)


    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_
    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_

    Editorial: PageDown is a more reliable Markdown parser outside of Github than Github Flavored Markdown.
  9. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -12,12 +12,12 @@
    // Félix Saparelli <http://passcod.net/>

    function X0() {
    if (!window.Showdown) {
    if (!window.Markdown) {
    setTimeout(X0, 200);
    } else {
    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){
    // strip leading whitespace so it isn't evaluated as code
    html = (new Showdown.converter()).makeHtml(elem.textContent);
    html = (new Markdown.Converter()).makeHtml(elem.textContent);

    // here, have sum HTML
    elem.innerHTML = html;
    @@ -29,7 +29,7 @@ var el;

    el = document.createElement("script");
    el.type = "application/javascript";
    el.src = "https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js";
    el.src = "http://pagedown.googlecode.com/hg/Markdown.Converter.js";
    document.body.appendChild(el);

    el = null;
  10. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ function X0() {
    } else {
    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){
    // strip leading whitespace so it isn't evaluated as code
    html = (new Showdown.converter()).makeHtml(elem.textcontent);
    html = (new Showdown.converter()).makeHtml(elem.textContent);

    // here, have sum HTML
    elem.innerHTML = html;
  11. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ function X0() {
    } else {
    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){
    // strip leading whitespace so it isn't evaluated as code
    html = (new Showdown.converter()).makeHtml(md);
    html = (new Showdown.converter()).makeHtml(elem.textcontent);

    // here, have sum HTML
    elem.innerHTML = html;
  12. Digitalsabre revised this gist Nov 9, 2011. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,7 @@ function X0() {
    } else {
    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){
    // strip leading whitespace so it isn't evaluated as code
    var md = elem.textContent.replace(/(^\s+)|(\n\s+)/g,'\n')
    , html = (new Showdown.converter()).makeHtml(md);
    html = (new Showdown.converter()).makeHtml(md);

    // here, have sum HTML
    elem.innerHTML = html;
  13. Félix Saparelli revised this gist Nov 9, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions readme.markdown
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@ So the idea is you're operating in an HTML environment but a few shortcuts would

    ### To use:

    1. Install this userscript
    * It automatically adds [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) if it's not already in.
    1. Install this userscript (click [the 'raw' link for the user.js file below](https://gist.github.com/raw/1349945/data-markdown.user.js)).
    * It automatically adds [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) to every page.
    2. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)


  14. Félix Saparelli revised this gist Nov 9, 2011. 2 changed files with 35 additions and 22 deletions.
    47 changes: 32 additions & 15 deletions data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,41 @@
    // ==UserScript==
    // @name Use Markdown, sometimes, in your HTML.
    // @author Paul Irish <http://paulirish.com/>
    // @link http://git.io/data-markdown
    // @match *
    // @name *[data-markdown]
    // @version 2.0
    // @description Use Markdown, sometimes, in your HTML.
    // @author Paul Irish <http://paulirish.com/> and others
    // @include *
    // ==/UserScript==

    // Contribs:
    // Thaddee Tyl <http://espadrine.github.com/>
    // Digitalsabre <https://github.com/Digitalsabre>
    // Félix Saparelli <http://passcod.net/>

    // If you're not using this as a userscript just delete from this line up. It's cool, homey.
    function X0() {
    if (!window.Showdown) {
    setTimeout(X0, 200);
    } else {
    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){
    // strip leading whitespace so it isn't evaluated as code
    var md = elem.textContent.replace(/(^\s+)|(\n\s+)/g,'\n')
    , html = (new Showdown.converter()).makeHtml(md);

    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){
    // here, have sum HTML
    elem.innerHTML = html;
    });
    }
    }

    if (!window.Showdown)
    document.write('<script src="https://raw.github.com/github/' +
    'github-flavored-markdown/gh-pages/scripts/showdown.js">\x3C/script>');
    var el;

    // strip leading whitespace so it isn't evaluated as code
    var md = elem.textContent.replace(/(^\s+)|(\n\s+)/g,'\n')
    , html = (new Showdown.converter()).makeHtml(md);
    el = document.createElement("script");
    el.type = "application/javascript";
    el.src = "https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js";
    document.body.appendChild(el);

    // here, have sum HTML
    elem.innerHTML = html;
    el = null;

    });
    el = document.createElement("script");
    el.type = "application/javascript";
    el.innerHTML = "(" + X0.toString() + ")();";
    document.body.appendChild(el);
    10 changes: 3 additions & 7 deletions readme.md → readme.markdown
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # *[data-markdown]
    # *[data-markdown] userscript

    ## I just put some markdown in ur HTML

    @@ -8,13 +8,9 @@ So the idea is you're operating in an HTML environment but a few shortcuts would

    ### To use:

    1. Add the following script into your HTML after the content, before other scripts
    1. Install this userscript
    * It automatically adds [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) if it's not already in.
    1. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)


    #### Userscript or script-script
    This script works fine in your page and can also be used as a userscript. Just click the `raw` link right below to install.
    2. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)


    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_
  15. @paulirish paulirish revised this gist Nov 7, 2011. 2 changed files with 5 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    // ==/UserScript==


    // this functions well
    // If you're not using this as a userscript just delete from this line up. It's cool, homey.

    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){

    5 changes: 4 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,9 @@ So the idea is you're operating in an HTML environment but a few shortcuts would
    * It automatically adds [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) if it's not already in.
    1. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)

    * This script works fine in your page and can also be used as a userscript. Just click the `raw` link right below to install.

    #### Userscript or script-script
    This script works fine in your page and can also be used as a userscript. Just click the `raw` link right below to install.


    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_
  16. @paulirish paulirish revised this gist Nov 7, 2011. 3 changed files with 27 additions and 13 deletions.
    11 changes: 0 additions & 11 deletions data-markdown.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +0,0 @@

    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){

    // strip leading whitespace so it isn't evaluated as code
    var md = elem.textContent.replace(/(^\s+)|(\n\s+)/g,'\n')
    , html = (new Showdown.converter()).makeHtml(md);

    // here, have sum HTML
    elem.innerHTML = html;

    });
    24 changes: 24 additions & 0 deletions data-markdown.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    // ==UserScript==
    // @name Use Markdown, sometimes, in your HTML.
    // @author Paul Irish <http://paulirish.com/>
    // @link http://git.io/data-markdown
    // @match *
    // ==/UserScript==


    // this functions well

    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){

    if (!window.Showdown)
    document.write('<script src="https://raw.github.com/github/' +
    'github-flavored-markdown/gh-pages/scripts/showdown.js">\x3C/script>');

    // strip leading whitespace so it isn't evaluated as code
    var md = elem.textContent.replace(/(^\s+)|(\n\s+)/g,'\n')
    , html = (new Showdown.converter()).makeHtml(md);

    // here, have sum HTML
    elem.innerHTML = html;

    });
    5 changes: 3 additions & 2 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,10 @@ So the idea is you're operating in an HTML environment but a few shortcuts would

    ### To use:

    1. Drop in [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) port of showdown.js into the page (after the content, before other scripts).
    1. Add the following script after that.
    1. Add the following script into your HTML after the content, before other scripts
    * It automatically adds [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) if it's not already in.
    1. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)

    * This script works fine in your page and can also be used as a userscript. Just click the `raw` link right below to install.

    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_
  17. @paulirish paulirish revised this gist Nov 6, 2011. 2 changed files with 5 additions and 3 deletions.
    1 change: 0 additions & 1 deletion gistfile1.js → data-markdown.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@


    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){

    // strip leading whitespace so it isn't evaluated as code
    7 changes: 5 additions & 2 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -2,12 +2,15 @@

    ## I just put some markdown in ur HTML

    In prototypes and HTML-based slide decks, it's pleasant to write in markdown sometimes. (This is not for production use.)
    In prototypes and HTML-based slide decks, it's pleasant to write in markdown sometimes and avoid all those angle brackets.

    So the idea is you're operating in an HTML environment but a few shortcuts would help so use markdown here and there.

    ### To use:

    1. Drop in [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) port of showdown.js into the page (after the content, before other scripts).
    1. Add the following script after that.
    1. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)
    1. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)


    _(As this requires some clientside js and can trigger FOUC, this is not for production use)_
  18. @paulirish paulirish created this gist Nov 6, 2011.
    11 changes: 11 additions & 0 deletions example.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <div class="slide">
    <section class="hbox" data-markdown>
    ## Who Am I?

    * Lead developer of [Modernizr](//modernizr.com)
    * Project lead of [HTML5 Boilerplate](//h5bp.com)
    * I curate that [page of polyfills](//bit.ly/polyfills)
    * Member of jQuery Team
    * Developer Relations on Google Chrome team
    </section>
    </div>
    12 changes: 12 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@


    [].forEach.call( document.querySelectorAll('[data-markdown]'), function(elem){

    // strip leading whitespace so it isn't evaluated as code
    var md = elem.textContent.replace(/(^\s+)|(\n\s+)/g,'\n')
    , html = (new Showdown.converter()).makeHtml(md);

    // here, have sum HTML
    elem.innerHTML = html;

    });
    13 changes: 13 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    # *[data-markdown]

    ## I just put some markdown in ur HTML

    In prototypes and HTML-based slide decks, it's pleasant to write in markdown sometimes. (This is not for production use.)

    So the idea is you're operating in an HTML environment but a few shortcuts would help so use markdown here and there.

    ### To use:

    1. Drop in [github flavored markdown's](https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js) port of showdown.js into the page (after the content, before other scripts).
    1. Add the following script after that.
    1. Add `data-markdown` attributes to any tags where you're gonna use markdown within. (see example)