### Install Source: https://github.com/crosstype/node-html-markdown/blob/master/README.md Install the node-html-markdown package using yarn, npm, or pnpm. ```sh add node-html-markdown ``` -------------------------------- ### Example Usage Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/1de0efed4d661163ff8414e8ca69f45a49efd7edca19dc896ca0983a4bf41485.html Demonstrates how to use the node-html-markdown module to convert HTML to Markdown. ```javascript var html2markdown = require('node-html-markdown') var html = '

Hello World

This is a paragraph.

' var markdown = html2markdown.translate(html) // markdown == "# Hello World\n\nThis is a paragraph." ``` -------------------------------- ### Paragraph Spacing Example Source: https://github.com/crosstype/node-html-markdown/blob/master/README.md Demonstrates how HTML paragraphs are translated into Markdown with blank lines separating them. ```typescript const html = `

Hello

World

!

`; const markdown = NodeHtmlMarkdown.translate(html); console.log(markdown); // Output: // Hello // // World // // ! ``` -------------------------------- ### JavaScript Callback Example Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/0e55dcdbeb54c88ee87942b9fef7ea5398fa9a1e83493d55844b479506a80fd8.html This snippet shows a JavaScript callback function for handling audio menu updates and errors. ```javascript titleupdates==0 || oldvalue_audioislive!=audio_menu_is_live) { audio_menu_update_title(audio_menu_is_live); audio_menu_num_of_titleupdates=1; } }, function failCallbackAudio_AudioHighlightMenu(error){ // Hide the audio highlight on any error. $("#content_services_liveaudio1").hide(); $("#content_services_liveaudio2").hide(); $("#content_services_menuaudio1").show(); $("#content_services_menuaudio2").show(); $("#content_services_liveaudio1").html(""); $("#content_services_liveaudio2").html(""); $("#content_services_liveitv1").hide(); $("#content_services_liveitv2").hide(); $("#content_services_menuitv1").show(); $("#content_services_menuitv2").show(); $("#content_services_liveitv1").html(""); $("#content_services_liveitv2").html(""); } ); } }); //]]> ``` -------------------------------- ### jQuery and EMP Setup Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/5de3db78f95172797a51b3b3b2cdc4caeb63a4d7b709e4441510d2c1967e0e6f.html Sets up the Embedded Media Player (EMP) once jQuery is loaded, including custom logic for handling popout notifications and live stats. ```javascript require(['jquery-1'], function($){ var setUp = function(){ embeddedMedia.setPopoutUrl('/player/emp/2_0_55/popout/pop.stm'); var oldNotifyParent = embeddedMedia.console.notifyParent; embeddedMedia.console.notifyParent = function(childWin){ oldNotifyParent(childWin); var liveStatsUrl = bbc.fmtj.av.emp.liveStatsForPopout($('#livestats').attr('src')); var webBug = $('', { id: 'livestats', src: liveStatsUrl }); $(childWin.document).find('body').append(webBug); } } if(window.embeddedMedia && window.embeddedMedia.console){ setUp(); } else{ $(document).bind('empReady', function(){ setUp(); }); } }); ``` -------------------------------- ### Usage Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/README.md Command to run the benchmark tool. ```shell yarn run benchmark ``` -------------------------------- ### Installing CyanogenMod Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/74e8bc94abea7c60f022d8d3f672f80e59e3e126735fae0b5ee5914ff2fce48e.html A user suggests installing CyanogenMod 10.1 on a regular Galaxy S4 to save money. ```text or buy a regular GS4 and install Cyanogenmod 10.1 on it and call it $440 saved. ``` -------------------------------- ### Ad Global Configuration and Setup Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/61adb9c208d9c67253b4413ef7ec2d010edae448b8c832bff2254125e4b51d5f.html JavaScript code defining global ad variables and functions for ad registration and setup. ```javascript var cbsiadGlobal = {'SITE' : "175", 'BRAND' : "59", 'NCAT' : "22058:22226:22784:23636:", 'NODE' : "23636", 'PTYPE' : "6858", 'PGUID' : "Ua9G-wq0GVgAABV5VLU", 'CID' : "22247285", 'DVAR_SESSION' : (surround.cookie) ? surround.sessions[0] : 'off', 'DVAR_SUBSESSION' : (surround.cookie) ? surround.sessions[1] : 'off', 'cookiesOn' : (surround.cookie) ? 1 : 0, 'DVAR_EXCLUDE' : "golf",'DVAR_USER' : "anon",'lgnSts' : 0,'regSys' : "2",'STAGING' : 0 }; cbsiRegisterAdGlobals(cbsiadGlobal); cbsiSetAdvancedAsync("/ads/local-page2.html"); function cbsiSetUserGroup (values) { cbsiadGlobal.DVAR_USER_GROUP = values; cbsiRegisterAdGlobals(cbsiadGlobal); cbsiAdBehavioralSetup(); cbsiAdBehavioral(); }; cbsiRunApexTargets(cbsiadGlobal,1000); var dwTag = "SITE=175&BRAND=59&NCAT=22058:22226:22784:23636:&NODE=23636&PTYPE=6858&PGUID=Ua9G-wq0GVgAABV5VLU&CID=22247285&DVAR_EXCLUDE=golf&DVAR_USER=anon&lgnSts=0&STAGING=0&DVAR_SESSION=" +cbsiadGlobal.DVAR_SESSION +"&DVAR_SUBSESSION=" +cbsiadGlobal.DVAR_SUBSESSION +"&cookiesOn=" +cbsiadGlobal.cookiesOn; function getVideoAdSessionValues(videoId){return "adv="+cbsiadGlobal.DVAR_SESSION+";advsub="+cbsiadGlobal.DVAR_SUBSESSION+";"} if (!random) {var abc=Math.random() + ""; var random=abc.substring(2,abc.length);} var switchMadison="on"; var switchApexUser="on"; var switchApexSurvey="on"; var switchDl="on"; var adLookup="media/spln/golf/reg/free/stories"; var cbsiad80_100 = {'SP' : "80",'POS' : "100"};if (switchMadison != 'off') {cbsiGetAd(cbsiad80_100);} ``` -------------------------------- ### JavaScript Initialization for Sharing Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/5bc9df3a36efb57a22edf862cec6a28eb112e535559c194d7976fb664c922c13.html JavaScript code snippet for initializing sharing buttons and API keys. ```javascript (function() { window['shareButtonsId'] = 'sharebuttons'; window['apiKey'] = '2_nKMBZgQrmkb8Ztr4YKeWza4fVrbQ6fbya1o1fnuus-vUlNZPCB9fk5rItWha856u'; })(); ``` -------------------------------- ### Cookie Management and Signup Logic Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html JavaScript functions for managing cookies (get, create, remove) and a specific function to handle user signup for 'Dealchicken' by saving email and zip code in a cookie, with event listeners for input field blur events. ```javascript function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i ``` -------------------------------- ### Sidebar Ads Setup Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/60bccec4069d54a6889bfcda785c0f3066a70cb5fadeea81f28d371681a2dee8.html Configuration for responsive sidebar advertisements. ```javascript // Setup ads var sidebarAds, sidebarDesktopAd, sidebarTabletAd, sidebarMobileAd, highImpactS = responsiveAd.highImpact( "sidebar" ); sidebarDesktopAd = { type: 'desktop', min: 336, size: ["336x280", "300x250", "300x600", "468x648"] } sidebarTabletAd = { type: 'tablet', min: 366, size: ["336x280", "300x250", "300x600"] } sidebarMobileAd = { type: "mobile", size: "300x250", config: { zone: '124138', site: '28275', type: '7', min_size_x: '300', min_size_y: '50', size_x: '320', size_y: '320', type: '-1' } } sidebarAds = [ sidebarDesktopAd, sidebarTabletAd, sidebarMobileAd ]; responsiveAd({ className: "moving-markup", highImpact: 'sidebar', ads: sidebarAds, reloadable: false, delay: 500 }); ``` -------------------------------- ### Live Micro Player Initialization Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/60b8aff17382f2fd02584645ef66e517b41f764d5b4ca404c1ceff3fe22bdda8.html Initializes the live micro player module if the init function exists. ```javascript jsexec(39,"if",function(){if (dojo.getObject("dj.module.video.liveMicroPlayer", true).init) { dj.module.video.liveMicroPlayer.init(); }}}); ``` -------------------------------- ### Line Breaks Example Source: https://github.com/crosstype/node-html-markdown/blob/master/README.md Shows how HTML line breaks (
) are converted to Markdown line breaks. ```typescript // Using line breaks const html = `

Line 1
Line 2
Line 3

`; const markdown = NodeHtmlMarkdown.translate(html); console.log(markdown); // Output: // Line 1 // Line 2 // Line 3 ``` -------------------------------- ### Usage - Re-use (Instance Method) Source: https://github.com/crosstype/node-html-markdown/blob/master/README.md Demonstrates how to create an instance of `NodeHtmlMarkdown` for multiple conversions to save time. ```ts import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from 'node-html-markdown' /* ********************************************************* * * Re-use * If using it several times, creating an instance saves time * ********************************************************* */ const nhm = new NodeHtmlMarkdown( /* options (optional) */ {}, /* customTransformers (optional) */ undefined, /* customCodeBlockTranslators (optional) */ undefined ); // Single file nhm.translate(/* html */ `hello`); // Multiple Files nhm.translate( /* FileCollection */ { 'file1.html': `hello`, 'file2.html': `goodbye` }, ); ``` -------------------------------- ### GEL Initialization Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html Initializes the ArticleBreakout widget. ```javascript var filed = GEL.element("ody_filedunder"); if (typeof filed.element.innerHTML != "undefined") filed.element.lastChild.className="last-child"; GEL.thepage.initializer.addInitRoutine({ name: "widget.ArticleBreakout", priority: 35, namespace: ["widget.ArticleBreakout"], callback: function(){artBreakout=new ArticleBreakout();} }); ``` -------------------------------- ### JavaScript Example Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/8cbf3b144736ffc4adda5fe7105e7fd1413dcc1955110829d849a658aa722bea.html A simple JavaScript function that returns true. ```javascript ble = function(){ return true; } ``` -------------------------------- ### VigLink API Initialization Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/2dbf7cd4444617cc60f0e2d2c95b20a535979a32972f5005e2af577b37980e48.html Initializes the VigLink API with a specific API URL and key. ```javascript var vglnk = { api_url: '//api.viglink.com/api', key: '2b0adaafa9ad8a29fede7758fada1730' }; (function(d, t) { var s = d.createElement(t); s.type = 'text/javascript'; s.async = true; s.src = ('https:' == document.location.protocol ? vglnk.api_url : '//cdn.viglink.com/api') + '/vglnk.js'; var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r); window.vglnk = vglnk; }(document, 'script')); ``` -------------------------------- ### Pagination Widget Initialization Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html Initializes the PaginationWidget and related components. ```javascript (function(){ GEL.register("widget.PaginationWidget", { type: "script", depends: ["widget"], requires: ["util.Selector"], path: "widgets/pagination/paginationController.js" }); GEL.thepage.initializer.addInitRoutine({ name: "pagination", callback: initPaginator, namespace: ["widget.GELTabs", "widget.AdBanner", "anim.YUIAnimator", "analytics","widget.PaginationWidget"], priority: 20 }); function initPaginator(){ GEL.thepage.artpg= new GEL.widget.GELTabs("artpagination", { changeEvent: "click", viewtrackevent: "paneChange", wrap: false, scrollAnchor: document.body, autoRotate:false, positionBanners: true, activeIndex:0 }); var _bannerLocator= GEL.thepage.bannerLocator, _a= _bannerLocator.findBanners(GEL.ement("remnantad")), _l= _a.length ; for(var i=0;i<_l;i++){ _a[i].config.reload= false; } GEL.thepage.artpg.init(); GEL.thepage.artpgController = new GEL.widget.artPagination("artpagination"); GEL.thepage.artpgController.init(); } })(); ``` -------------------------------- ### Document Ready and Slideshow Initialization Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/5bc9df3a36efb57a22edf862cec6a28eb112e535559c194d7976fb664c922c13.html This JavaScript code initializes the slideshow functionality when the document is ready. ```javascript $(document).ready(function() { slideshowInit(16); }); ``` -------------------------------- ### Chartbeat Configuration and Loading Script Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/20f1955819dc2b50d2d10788f73adc72bceb491a03ed608debb72a90bce65c50.html Configuration and script to load Chartbeat analytics. ```javascript var _sf_async_config={}; /** CONFIGURATION START **/ _sf_async_config.uid = 11173; _sf_async_config.domain = 'venturebeat.com'; _sf_async_config.sections = 'business'; _sf_async_config.authors = 'Ricardo Bilton'; /** CONFIGURATION END **/ (function(){ function loadChartbeat() { window._sf_endpt=(new Date()).getTime(); var e = document.createElement('script'); e.setAttribute('language', 'javascript'); e.setAttribute('type', 'text/javascript'); e.setAttribute('src', (('https:' == document.location.protocol) ? 'https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/' : 'http://static.chartbeat.com/') + 'js/chartbeat.js'); document.body.appendChild(e); } var oldonload = window.onload; window.onload = (typeof window.onload != 'function') ? loadChartbeat : function() { oldonload(); loadChartbeat(); }; })(); ``` -------------------------------- ### Configuration Settings Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html Sets configuration values for auto-refresh and other features. ```javascript var cfg= GEL.namespace("config"); /*gdn_auto_refresh*/ cfg.gdn_auto_refresh = true; /*I don;t think this is needed anymore*/ }); ``` -------------------------------- ### Pinterest Pin It Button Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html Generates and embeds a Pinterest Pin It button. ```javascript var encodeURL; var urlEnd = escape(''); var descEnc = 'Horse gets encephalitis, West Nile' if(urlEnd === '') { encodeURL = 'http://www.dailyworld.com/odygci/firefly/pinterest/DH.jpg'; } else { encodeURL = urlEnd; } document.write(''); (function(d){ var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT'); p.type = 'text/javascript'; p.async = true; p.src = '//assets.pinterest.com/js/pinit.js'; f.parentNode.insertBefore(p, f); }(document)); ``` -------------------------------- ### Map and View Loading Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/7e54e701ac39a9046d6eeb0ae75d2138733b66b30b5211e7f3245dd6dc3ca36c.html Loads a JavaScript map file and a BBC fmtj view. ```javascript $useMap({map:"http://news.bbcimg.co.uk/js/map/map_0_0_33.js"}); $loadView("0.0",["bbc.fmtj.view"]); $render("livestats-heatmap"); ``` -------------------------------- ### Advert Script Loading Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/7e54e701ac39a9046d6eeb0ae75d2138733b66b30b5211e7f3245dd6dc3ca36c.html Dynamically writes the advert script tag based on test environment or standard configuration. ```javascript if(/[\]?|&]metadata=yes(&|$)/.test(window.location.search)){document.write("http://www.test.bbc.com/wwscripts/metadata?bbcdotcom_asset="+window.location.hostname+window.location.pathname)}; if(typeof BBC.adverts != 'undefined' && ``` -------------------------------- ### GPS Source Extraction Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html Extracts the 'gps-source' query parameter from the URL. ```javascript GEL.thepage.pageinfo.gps_source=(function(){ function getUrlVars(){ var vars = {}; var parts = window.location.href.replace(/\(?:\[?&(?!\])(?:[^&=]+)=?([^&]*?)(?:&|$)|([^&=]*?)$)/gi, function($0, $1, $2) { if ($1) vars[$0.replace(/.*=/, '')] = $1; else vars[$0] = $2; }); return vars; }; var _gps_value = getUrlVars()["gps-source"]; return _gps_value; })(); ``` -------------------------------- ### Disqus Reply Count Script Source: https://github.com/crosstype/node-html-markdown/blob/master/benchmark/files/20f1955819dc2b50d2d10788f73adc72bceb491a03ed608debb72a90bce65c50.html JavaScript code to get the number of replies from Disqus using WPID. ```javascript var links = document.getElementsByTagName('a'); var query = '&'; for(var i = 0; i < links.length; i++) { if(links[i].href.indexOf('#disqus_thread') >= 0) { links[i].innerHTML = 'Add a Comment'; query += 'wpid' + i + '=' + encodeURIComponent(links[i].getAttribute('wpid')) + '&'; } } document.write('