-
-
Save atomize/31fba13f3c3c064f07082f1412e29c37 to your computer and use it in GitHub Desktop.
Revisions
-
paulirish revised this gist
Mar 14, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ if (!window.Showdown){ var scr = document.createElement('script'); scr.onload = boom; scr.src = 'https://cdn.rawgit.com/showdownjs/showdown/master/src/showdown.js'; document.body.appendChild(scr); return; } -
paulirish revised this gist
Apr 24, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ [].forEach.call( document.querySelectorAll('[data-markdown]'), function fn(elem){ // strip leading whitespace so it isn't evaluated as code var text = elem.innerHTML.replace(/\n\s*\n/g,'\n'), // set indentation level so your markdown can be indented within your HTML leadingws = text.match(/^\n?(\s*)/)[1].length, regex = new RegExp('\\n?\\s{' + leadingws + '}','g'), -
paulirish revised this gist
Feb 12, 2012 . 2 changed files with 27 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,17 +8,29 @@ // If you're not using this as a userscript just delete from this line up. It's cool, homey. (function boom(){ if (!window.Showdown){ var scr = document.createElement('script'); scr.onload = boom; scr.src = 'https://raw.github.com/github/github-flavored-markdown/gh-pages/scripts/showdown.js'; document.body.appendChild(scr); return; } [].forEach.call( document.querySelectorAll('[data-markdown]'), function fn(elem){ // strip leading whitespace so it isn't evaluated as code var text = elem.textContent.replace(/\n\s*\n/g,'\n'), // set indentation level so your markdown can be indented within your HTML leadingws = text.match(/^\n?(\s*)/)[1].length, regex = new RegExp('\\n?\\s{' + leadingws + '}','g'), md = text.replace(regex,'\n'), html = (new Showdown.converter()).makeHtml(md); // here, have sum HTML elem.innerHTML = html; }); }()); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,8 @@ * Member of jQuery Team * Developer Relations on Google Chrome team </section> </div> <script src="data-markdown.user.js"></script> -
paulirish revised this gist
Nov 7, 2011 . 2 changed files with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ // ==/UserScript== // 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){ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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) #### 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)_ -
paulirish revised this gist
Nov 7, 2011 . 3 changed files with 27 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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. 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)_ -
paulirish revised this gist
Nov 6, 2011 . 2 changed files with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 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) _(As this requires some clientside js and can trigger FOUC, this is not for production use)_ -
paulirish created this gist
Nov 6, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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; }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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)